git: 7782d7167190 - stable/13 - syncer VOP_FSYNC(): unlock syncer vnode around call to VFS_SYNC()

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 07 Feb 2022 09:50:52 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=7782d71671908886b88a4d1d50732ab8bc95385e

commit 7782d71671908886b88a4d1d50732ab8bc95385e
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-01-21 15:42:28 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-02-07 09:38:50 +0000

    syncer VOP_FSYNC(): unlock syncer vnode around call to VFS_SYNC()
    
    (cherry picked from commit 3d68c4e17578684cfdfd002fb6ab8554df525963)
---
 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 f56bedecaf15..a7a432d31a55 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -5107,10 +5107,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
@@ -5119,7 +5116,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);
 }