Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern vrelel(): after all locks are in place check for ne...



details:   https://anonhg.NetBSD.org/src/rev/d6db57d08c47
branches:  trunk
changeset: 363391:d6db57d08c47
user:      hannken <hannken%NetBSD.org@localhost>
date:      Wed Mar 09 08:43:28 2022 +0000

description:
vrelel(): after all locks are in place check for new reference again.

Should fix assertion "vp->v_iflag & VI_TEXT" under load.

diffstat:

 sys/kern/vfs_vnode.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (31 lines):

diff -r dadff06f1c23 -r d6db57d08c47 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c      Wed Mar 09 00:20:48 2022 +0000
+++ b/sys/kern/vfs_vnode.c      Wed Mar 09 08:43:28 2022 +0000
@@ -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 @@
        }
        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. */



Home | Main Index | Thread Index | Old Index