From 3d68c4e17578684cfdfd002fb6ab8554df525963 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Fri, 21 Jan 2022 17:42:28 +0200 Subject: [PATCH] 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 --- sys/kern/vfs_subr.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 3218a3f7b6a..839282fe318 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -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); }