syncer VOP_FSYNC(): unlock syncer vnode around call to VFS_SYNC()

The lock is unneccessary since the mount point is busied, which prevents
unmount and syncer vnode deallocation.  Having the vnode locked causes
innocent LoRs and complicates debugging.

Also stop starting write accounting around it.  Any caller of
VOP_FSYNC() must do it already, and sync_vnode() does.

Reported and tested by:	pho
Reviewed by:	markj, mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34072
This commit is contained in:
Konstantin Belousov 2022-01-21 17:42:28 +02:00
parent 5875b94c74
commit 3d68c4e175

View File

@ -5059,10 +5059,7 @@ sync_fsync(struct vop_fsync_args *ap)
*/
if (vfs_busy(mp, MBF_NOWAIT) != 0)
return (0);
if (vn_start_write(NULL, &mp, V_NOWAIT) != 0) {
vfs_unbusy(mp);
return (0);
}
VOP_UNLOCK(syncvp);
save = curthread_pflags_set(TDP_SYNCIO);
/*
* The filesystem at hand may be idle with free vnodes stored in the
@ -5071,7 +5068,7 @@ sync_fsync(struct vop_fsync_args *ap)
vfs_periodic(mp, MNT_NOWAIT);
error = VFS_SYNC(mp, MNT_LAZY);
curthread_pflags_restore(save);
vn_finished_write(mp);
vn_lock(syncvp, LK_EXCLUSIVE | LK_RETRY);
vfs_unbusy(mp);
return (error);
}