Module Name: src
Committed By: riastradh
Date: Mon Mar 28 12:37:18 UTC 2022
Modified Files:
src/sys/miscfs/specfs: spec_vnops.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.204 -r1.205 src/sys/miscfs/specfs/spec_vnops.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/miscfs/specfs/spec_vnops.c
diff -u src/sys/miscfs/specfs/spec_vnops.c:1.204 src/sys/miscfs/specfs/spec_vnops.c:1.205
--- src/sys/miscfs/specfs/spec_vnops.c:1.204 Mon Mar 28 12:37:09 2022
+++ src/sys/miscfs/specfs/spec_vnops.c Mon Mar 28 12:37:18 2022
@@ -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 @@ spec_node_revoke(vnode_t *vp)
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);
}