* Do a lazy sync of the filesystem. */
| 5038 | * Do a lazy sync of the filesystem. |
| 5039 | */ |
| 5040 | static int |
| 5041 | sync_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. |
nothing calls this directly
no test coverage detected