git: ed1bb254101e - main - mntfs: change mntfs_allocvp API to relock on its own

From: Mateusz Guzik <mjg_at_FreeBSD.org>
Date: Mon, 26 Dec 2022 18:29:19 UTC
The branch main has been updated by mjg:

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

commit ed1bb254101ec3107d00257209204f8497fb0c1e
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-12-19 14:42:04 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2022-12-26 17:34:49 +0000

    mntfs: change mntfs_allocvp API to relock on its own
    
    Reviewed by:    kib
    Tested by:      pho
    Differential Revision: https://reviews.freebsd.org/D37759
---
 sys/fs/mntfs/mntfs_vnops.c      | 2 ++
 sys/fs/msdosfs/msdosfs_vfsops.c | 2 --
 sys/ufs/ffs/ffs_vfsops.c        | 2 --
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sys/fs/mntfs/mntfs_vnops.c b/sys/fs/mntfs/mntfs_vnops.c
index 4eb12a679590..0360262ce191 100644
--- a/sys/fs/mntfs/mntfs_vnops.c
+++ b/sys/fs/mntfs/mntfs_vnops.c
@@ -83,6 +83,8 @@ mntfs_allocvp(struct mount *mp, struct vnode *ovp)
 	dev_ref(dev);
 	vp->v_rdev = dev;
 
+	VOP_UNLOCK(ovp);
+	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	return (vp);
 }
 
diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c
index dfe31ca18b9a..b6f8c29d9162 100644
--- a/sys/fs/msdosfs/msdosfs_vfsops.c
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c
@@ -431,8 +431,6 @@ mountmsdosfs(struct vnode *odevvp, struct mount *mp)
 	ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
 
 	devvp = mntfs_allocvp(mp, odevvp);
-	VOP_UNLOCK(odevvp);
-	vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
 	dev = devvp->v_rdev;
 	if (atomic_cmpset_acq_ptr((uintptr_t *)&dev->si_mountpt, 0,
 	    (uintptr_t)mp) == 0) {
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 54a24b7058f8..cec03a3beb0d 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -925,8 +925,6 @@ ffs_mountfs(struct vnode *odevvp, struct mount *mp, struct thread *td)
 	ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
 
 	devvp = mntfs_allocvp(mp, odevvp);
-	VOP_UNLOCK(odevvp);
-	vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
 	KASSERT(devvp->v_type == VCHR, ("reclaimed devvp"));
 	dev = devvp->v_rdev;
 	KASSERT(dev->si_snapdata == NULL, ("non-NULL snapshot data"));