Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs/specfs specfs: Wait for last close in spec_node_r...



details:   https://anonhg.NetBSD.org/src/rev/f2b7cdfcfb1a
branches:  trunk
changeset: 364516:f2b7cdfcfb1a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Mar 28 12:37:18 2022 +0000

description:
specfs: Wait for last close in spec_node_revoke.

Otherwise, revoke -- and vdevgone, in the detach path of removable
devices -- may complete while I/O operations are still running
concurrently.

diffstat:

 sys/miscfs/specfs/spec_vnops.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (35 lines):

diff -r 5937d1a6daa7 -r f2b7cdfcfb1a sys/miscfs/specfs/spec_vnops.c
--- a/sys/miscfs/specfs/spec_vnops.c    Mon Mar 28 12:37:09 2022 +0000
+++ b/sys/miscfs/specfs/spec_vnops.c    Mon Mar 28 12:37:18 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spec_vnops.c,v 1.204 2022/03/28 12:37:09 riastradh Exp $       */
+/*     $NetBSD: spec_vnops.c,v 1.205 2022/03/28 12:37:18 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.204 2022/03/28 12:37:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.205 2022/03/28 12:37:18 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -597,6 +597,16 @@
                mutex_enter(&device_lock);
                KASSERT(sn->sn_opencnt == 0);
        }
+
+       /*
+        * We may have revoked the vnode in this thread while another
+        * thread was in the middle of spec_close, in the window when
+        * spec_close releases the vnode lock to call .d_close for the
+        * last close.  In that case, wait for the concurrent
+        * spec_close to complete.
+        */
+       while (sd->sd_closing)
+               cv_wait(&specfs_iocv, &device_lock);
        mutex_exit(&device_lock);
 }
 



Home | Main Index | Thread Index | Old Index