git: cf8da8b04fe4 - stable/13 - ffs_syncvnode(): avoid a LoR for SU

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 22 Jan 2023 09:19:15 UTC
The branch stable/13 has been updated by kib:

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

commit cf8da8b04fe4b2b4c616060463db14281d9e4434
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-01-07 12:22:18 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-01-22 09:18:09 +0000

    ffs_syncvnode(): avoid a LoR for SU
    
    Tested by:      pho
    
    (cherry picked from commit 6e1eabadcb1d554ab6c0ad8ce1d82f6748cc80b4)
---
 sys/ufs/ffs/ffs_softdep.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index 5b489d4bad36..d784d8d0fd1a 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -12758,9 +12758,15 @@ restart:
 					pagedep_new_block = pagedep->pd_state & NEWBLOCK;
 					FREE_LOCK(ump);
 					locked = 0;
-					if (pagedep_new_block && (error =
-					    ffs_syncvnode(pvp, MNT_WAIT, 0))) {
+					if (pagedep_new_block) {
+						VOP_UNLOCK(vp);
+						error = ffs_syncvnode(pvp,
+						    MNT_WAIT, 0);
+						if (error == 0)
+							error = ERELOOKUP;
 						vput(pvp);
+						vn_lock(vp, LK_EXCLUSIVE |
+						    LK_RETRY);
 						return (error);
 					}
 				}