git: d04c7f10d43b - main - vfs: make delmntque return with the interlock held
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 14 Sep 2022 23:33:16 UTC
The branch main has been updated by mjg:
URL: https://cgit.FreeBSD.org/src/commit/?id=d04c7f10d43b121acac4c03d348d8aef193f89bc
commit d04c7f10d43b121acac4c03d348d8aef193f89bc
Author: Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-09-14 23:08:08 +0000
Commit: Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2022-09-14 23:30:19 +0000
vfs: make delmntque return with the interlock held
saves on relocking dance -- the lock is taken immediately
afterwards anyway.
---
sys/kern/vfs_subr.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 739d22089f97..62430f4aaf39 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1944,18 +1944,19 @@ delmntque(struct vnode *vp)
VNPASS((vp->v_mflag & VMP_LAZYLIST) == 0, vp);
mp = vp->v_mount;
- if (mp == NULL)
- return;
MNT_ILOCK(mp);
VI_LOCK(vp);
vp->v_mount = NULL;
- VI_UNLOCK(vp);
VNASSERT(mp->mnt_nvnodelistsize > 0, vp,
("bad mount point vnode list size"));
TAILQ_REMOVE(&mp->mnt_nvnodelist, vp, v_nmntvnodes);
mp->mnt_nvnodelistsize--;
MNT_REL(mp);
MNT_IUNLOCK(mp);
+ /*
+ * The caller expects the interlock to be still held.
+ */
+ ASSERT_VI_LOCKED(vp, __func__);
}
static int
@@ -4110,17 +4111,23 @@ vgonel(struct vnode *vp)
/*
* Clear the advisory locks and wake up waiting threads.
*/
- (void)VOP_ADVLOCKPURGE(vp);
- vp->v_lockf = NULL;
+ if (vp->v_lockf != NULL) {
+ (void)VOP_ADVLOCKPURGE(vp);
+ vp->v_lockf = NULL;
+ }
/*
* Delete from old mount point vnode list.
*/
- delmntque(vp);
+ if (vp->v_mount == NULL) {
+ VI_LOCK(vp);
+ } else {
+ delmntque(vp);
+ ASSERT_VI_LOCKED(vp, "vgonel 2");
+ }
/*
* Done with purge, reset to the standard lock and invalidate
* the vnode.
*/
- VI_LOCK(vp);
vp->v_vnlock = &vp->v_lock;
vp->v_op = &dead_vnodeops;
vp->v_type = VBAD;