Source-Changes-HG archive

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

[src/trunk]: src/sys/kern vrelel(): No need to test usecount if VGET marker i...



details:   https://anonhg.NetBSD.org/src/rev/72eebaa37725
branches:  trunk
changeset: 363915:72eebaa37725
user:      hannken <hannken%NetBSD.org@localhost>
date:      Tue Mar 15 15:27:43 2022 +0000

description:
vrelel(): No need to test usecount if VGET marker is clear.
Assert "usecount == 1" instead.

diffstat:

 sys/kern/vfs_vnode.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (44 lines):

diff -r a8b96e2b5b6b -r 72eebaa37725 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c      Tue Mar 15 13:00:44 2022 +0000
+++ b/sys/kern/vfs_vnode.c      Tue Mar 15 15:27:43 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_vnode.c,v 1.136 2022/03/12 15:32:32 riastradh Exp $        */
+/*     $NetBSD: vfs_vnode.c,v 1.137 2022/03/15 15:27:43 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.136 2022/03/12 15:32:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.137 2022/03/15 15:27:43 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -914,9 +914,10 @@
 
        /* If the node gained another reference, retry. */
        use = atomic_load_relaxed(&vp->v_usecount);
-       if ((use & VUSECOUNT_VGET) != 0 || (use & VUSECOUNT_MASK) != 1) {
+       if ((use & VUSECOUNT_VGET) != 0) {
                goto retry;
        }
+       KASSERT((use & VUSECOUNT_MASK) == 1);
 
        if ((vp->v_iflag & (VI_TEXT|VI_EXECMAP|VI_WRMAP)) != 0 ||
            (vp->v_vflag & VV_MAPPED) != 0) {
@@ -967,11 +968,11 @@
        if (recycle) {
                VSTATE_CHANGE(vp, VS_LOADED, VS_BLOCKED);
                use = atomic_load_relaxed(&vp->v_usecount);
-               if ((use & VUSECOUNT_VGET) != 0 ||
-                   (use & VUSECOUNT_MASK) != 1) {
+               if ((use & VUSECOUNT_VGET) != 0) {
                        VSTATE_CHANGE(vp, VS_BLOCKED, VS_LOADED);
                        goto retry;
                }
+               KASSERT((use & VUSECOUNT_MASK) == 1);
        }
 
        /*



Home | Main Index | Thread Index | Old Index