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 VOP_UNLOCK() with v_interlock or vmobj...



details:   https://anonhg.NetBSD.org/src/rev/58967030b523
branches:  trunk
changeset: 362468:58967030b523
user:      hannken <hannken%NetBSD.org@localhost>
date:      Mon Feb 28 08:44:04 2022 +0000

description:
vrelel(): no VOP_UNLOCK() with v_interlock or vmobjlock held.

diffstat:

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

diffs (60 lines):

diff -r eec12ea3e61b -r 58967030b523 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c      Sun Feb 27 22:46:04 2022 +0000
+++ b/sys/kern/vfs_vnode.c      Mon Feb 28 08:44:04 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_vnode.c,v 1.133 2022/02/17 14:39:51 hannken Exp $  */
+/*     $NetBSD: vfs_vnode.c,v 1.134 2022/02/28 08:44:04 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.133 2022/02/17 14:39:51 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.134 2022/02/28 08:44:04 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -801,16 +801,16 @@
         */
        for (use = atomic_load_relaxed(&vp->v_usecount);; use = next) {
                if (__predict_false((use & VUSECOUNT_MASK) > 1)) {
+                       if (objlock_held) {
+                               objlock_held = false;
+                               rw_exit(vp->v_uobj.vmobjlock);
+                       }
                        if (lktype != LK_NONE) {
                                mutex_exit(vp->v_interlock);
                                lktype = LK_NONE;
                                VOP_UNLOCK(vp);
                                mutex_enter(vp->v_interlock);
                        }
-                       if (objlock_held) {
-                               objlock_held = false;
-                               rw_exit(vp->v_uobj.vmobjlock);
-                       }
                        if (vtryrele(vp)) {
                                mutex_exit(vp->v_interlock);
                                return;
@@ -843,6 +843,10 @@
         * deactivate this node.
         */
        if (VSTATE_GET(vp) == VS_RECLAIMED) {
+               if (objlock_held) {
+                       objlock_held = false;
+                       rw_exit(vp->v_uobj.vmobjlock);
+               }
                if (lktype != LK_NONE) {
                        mutex_exit(vp->v_interlock);
                        lktype = LK_NONE;
@@ -884,7 +888,9 @@
                 * clean it here.  We donate it our last reference.
                 */
                if (lktype != LK_NONE) {
+                       mutex_exit(vp->v_interlock);
                        VOP_UNLOCK(vp);
+                       mutex_enter(vp->v_interlock);
                }
                lru_requeue(vp, &lru_list[LRU_VRELE]);
                mutex_exit(vp->v_interlock);



Home | Main Index | Thread Index | Old Index