aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2022-03-07 11:40:04 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2022-03-19 10:46:40 +0000
commit1cb0045c971be75bea76e4aa3e1df2f92f1978bc (patch)
tree0e51c8205652041d3398562580a18afe1f9d38f9
parent2218070b2c3c32b1574f3f3b2d0579b2d4826554 (diff)
downloadsrc-1cb0045c971be75bea76e4aa3e1df2f92f1978bc.tar.gz
src-1cb0045c971be75bea76e4aa3e1df2f92f1978bc.zip
vfs: add MNTK_UNLOCKED_INSMNTQUE
Can be used when the fs at hand can synchronize insmntque with other means than the vnode lock. Reviewed by: markj Tested by: pho (previous version) Differential Revision: https://reviews.freebsd.org/D34466
-rw-r--r--sys/kern/vfs_subr.c11
-rw-r--r--sys/sys/mount.h2
2 files changed, 10 insertions, 3 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index c184530bbda6..7442153371a6 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1965,7 +1965,13 @@ insmntque1_int(struct vnode *vp, struct mount *mp, bool dtr)
KASSERT(vp->v_mount == NULL,
("insmntque: vnode already on per mount vnode list"));
VNASSERT(mp != NULL, vp, ("Don't call insmntque(foo, NULL)"));
- ASSERT_VOP_ELOCKED(vp, "insmntque: non-locked vp");
+ if ((mp->mnt_kern_flag & MNTK_UNLOCKED_INSMNTQUE) == 0) {
+ ASSERT_VOP_ELOCKED(vp, "insmntque: non-locked vp");
+ } else {
+ KASSERT(!dtr,
+ ("%s: can't have MNTK_UNLOCKED_INSMNTQUE and cleanup",
+ __func__));
+ }
/*
* We acquire the vnode interlock early to ensure that the
@@ -4400,6 +4406,7 @@ DB_SHOW_COMMAND(mount, db_show_mount)
MNT_KERN_FLAG(MNTK_RECURSE);
MNT_KERN_FLAG(MNTK_UPPER_WAITER);
MNT_KERN_FLAG(MNTK_LOOKUP_EXCL_DOTDOT);
+ MNT_KERN_FLAG(MNTK_UNLOCKED_INSMNTQUE);
MNT_KERN_FLAG(MNTK_USES_BCACHE);
MNT_KERN_FLAG(MNTK_FPLOOKUP);
MNT_KERN_FLAG(MNTK_TASKQUEUE_WAITER);
@@ -5031,7 +5038,7 @@ vfs_allocate_syncvnode(struct mount *mp)
vp->v_type = VNON;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
vp->v_vflag |= VV_FORCEINSMQ;
- error = insmntque(vp, mp);
+ error = insmntque1(vp, mp);
if (error != 0)
panic("vfs_allocate_syncvnode: insmntque() failed");
vp->v_vflag &= ~VV_FORCEINSMQ;
diff --git a/sys/sys/mount.h b/sys/sys/mount.h
index ae3eebd94c53..15aa7dff1e27 100644
--- a/sys/sys/mount.h
+++ b/sys/sys/mount.h
@@ -487,7 +487,7 @@ struct mntoptnames {
#define MNTK_RECURSE 0x00000200 /* pending recursive unmount */
#define MNTK_UPPER_WAITER 0x00000400 /* waiting to drain MNTK_UPPER_PENDING */
#define MNTK_LOOKUP_EXCL_DOTDOT 0x00000800
-/* UNUSED 0x00001000 */
+#define MNTK_UNLOCKED_INSMNTQUE 0x00001000 /* fs does not lock the vnode for insmntque */
#define MNTK_UNMAPPED_BUFS 0x00002000
#define MNTK_USES_BCACHE 0x00004000 /* FS uses the buffer cache. */
/* UNUSED 0x00008000 */