| 2554 | SYSINIT(syncer, SI_SUB_KTHREAD_UPDATE, SI_ORDER_FIRST, kproc_start, &up_kp); |
| 2555 | |
| 2556 | static int |
| 2557 | sync_vnode(struct synclist *slp, struct bufobj **bo, struct thread *td) |
| 2558 | { |
| 2559 | struct vnode *vp; |
| 2560 | struct mount *mp; |
| 2561 | |
| 2562 | *bo = LIST_FIRST(slp); |
| 2563 | if (*bo == NULL) |
| 2564 | return (0); |
| 2565 | vp = bo2vnode(*bo); |
| 2566 | if (VOP_ISLOCKED(vp) != 0 || VI_TRYLOCK(vp) == 0) |
| 2567 | return (1); |
| 2568 | /* |
| 2569 | * We use vhold in case the vnode does not |
| 2570 | * successfully sync. vhold prevents the vnode from |
| 2571 | * going away when we unlock the sync_mtx so that |
| 2572 | * we can acquire the vnode interlock. |
| 2573 | */ |
| 2574 | vholdl(vp); |
| 2575 | mtx_unlock(&sync_mtx); |
| 2576 | VI_UNLOCK(vp); |
| 2577 | if (vn_start_write(vp, &mp, V_NOWAIT) != 0) { |
| 2578 | vdrop(vp); |
| 2579 | mtx_lock(&sync_mtx); |
| 2580 | return (*bo == LIST_FIRST(slp)); |
| 2581 | } |
| 2582 | vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); |
| 2583 | (void) VOP_FSYNC(vp, MNT_LAZY, td); |
| 2584 | VOP_UNLOCK(vp); |
| 2585 | vn_finished_write(mp); |
| 2586 | BO_LOCK(*bo); |
| 2587 | if (((*bo)->bo_flag & BO_ONWORKLST) != 0) { |
| 2588 | /* |
| 2589 | * Put us back on the worklist. The worklist |
| 2590 | * routine will remove us from our current |
| 2591 | * position and then add us back in at a later |
| 2592 | * position. |
| 2593 | */ |
| 2594 | vn_syncer_add_to_worklist(*bo, syncdelay); |
| 2595 | } |
| 2596 | BO_UNLOCK(*bo); |
| 2597 | vdrop(vp); |
| 2598 | mtx_lock(&sync_mtx); |
| 2599 | return (0); |
| 2600 | } |
| 2601 | |
| 2602 | static int first_printf = 1; |
| 2603 |
no test coverage detected