MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sync_fsync

Function sync_fsync

freebsd/kern/vfs_subr.c:5040–5083  ·  view source on GitHub ↗

* Do a lazy sync of the filesystem. */

Source from the content-addressed store, hash-verified

5038 * Do a lazy sync of the filesystem.
5039 */
5040static int
5041sync_fsync(struct vop_fsync_args *ap)
5042{
5043 struct vnode *syncvp = ap->a_vp;
5044 struct mount *mp = syncvp->v_mount;
5045 int error, save;
5046 struct bufobj *bo;
5047
5048 /*
5049 * We only need to do something if this is a lazy evaluation.
5050 */
5051 if (ap->a_waitfor != MNT_LAZY)
5052 return (0);
5053
5054 /*
5055 * Move ourselves to the back of the sync list.
5056 */
5057 bo = &syncvp->v_bufobj;
5058 BO_LOCK(bo);
5059 vn_syncer_add_to_worklist(bo, syncdelay);
5060 BO_UNLOCK(bo);
5061
5062 /*
5063 * Walk the list of vnodes pushing all that are dirty and
5064 * not already on the sync list.
5065 */
5066 if (vfs_busy(mp, MBF_NOWAIT) != 0)
5067 return (0);
5068 if (vn_start_write(NULL, &mp, V_NOWAIT) != 0) {
5069 vfs_unbusy(mp);
5070 return (0);
5071 }
5072 save = curthread_pflags_set(TDP_SYNCIO);
5073 /*
5074 * The filesystem at hand may be idle with free vnodes stored in the
5075 * batch. Return them instead of letting them stay there indefinitely.
5076 */
5077 vfs_periodic(mp, MNT_NOWAIT);
5078 error = VFS_SYNC(mp, MNT_LAZY);
5079 curthread_pflags_restore(save);
5080 vn_finished_write(mp);
5081 vfs_unbusy(mp);
5082 return (error);
5083}
5084
5085/*
5086 * The syncer vnode is no referenced.

Callers

nothing calls this directly

Calls 8

vfs_busyFunction · 0.85
vn_start_writeFunction · 0.85
vfs_unbusyFunction · 0.85
curthread_pflags_setFunction · 0.85
vfs_periodicFunction · 0.85
curthread_pflags_restoreFunction · 0.85
vn_finished_writeFunction · 0.85

Tested by

no test coverage detected