Module Name: src
Committed By: hannken
Date: Wed Mar 9 08:43:28 UTC 2022
Modified Files:
src/sys/kern: vfs_vnode.c
Log Message:
vrelel(): after all locks are in place check for new reference again.
Should fix assertion "vp->v_iflag & VI_TEXT" under load.
To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/kern/vfs_vnode.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.134 src/sys/kern/vfs_vnode.c:1.135
--- src/sys/kern/vfs_vnode.c:1.134 Mon Feb 28 08:44:04 2022
+++ src/sys/kern/vfs_vnode.c Wed Mar 9 08:43:28 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnode.c,v 1.134 2022/02/28 08:44:04 hannken Exp $ */
+/* $NetBSD: vfs_vnode.c,v 1.135 2022/03/09 08:43:28 hannken Exp $ */
/*-
* Copyright (c) 1997-2011, 2019, 2020 The NetBSD Foundation, Inc.
@@ -148,7 +148,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.134 2022/02/28 08:44:04 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.135 2022/03/09 08:43:28 hannken Exp $");
#ifdef _KERNEL_OPT
#include "opt_pax.h"
@@ -898,6 +898,12 @@ retry:
}
KASSERT(lktype == LK_EXCLUSIVE);
+ /* If the node gained another reference, retry. */
+ use = atomic_load_relaxed(&vp->v_usecount);
+ if ((use & VUSECOUNT_VGET) != 0 || (use & VUSECOUNT_MASK) != 1) {
+ goto retry;
+ }
+
if ((vp->v_iflag & (VI_TEXT|VI_EXECMAP|VI_WRMAP)) != 0 ||
(vp->v_vflag & VV_MAPPED) != 0) {
/* Take care of space accounting. */