Current-Users archive

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

Re: specfs/spec_vnops.c diagnostic assertion panic



Can you try the attached patch and see if (a) it still panics, or if
(b) there are any other adverse consequences like fsck failing?
From 7ade169092246e8870aaab2973d8bb252e625d89 Mon Sep 17 00:00:00 2001
From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
Date: Fri, 12 Aug 2022 20:01:50 +0000
Subject: [PATCH] specfs: Refuse to open a closing-in-progress block device.

We could wait for close to complete, but let's test to see if this is
what is leading to the inconsistent states and later figure out
whether blocking or immediate failure is better.
---
 sys/miscfs/specfs/spec_vnops.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c
index 8b4ed335880a..e6295f9786de 100644
--- a/sys/miscfs/specfs/spec_vnops.c
+++ b/sys/miscfs/specfs/spec_vnops.c
@@ -789,8 +789,13 @@ spec_open(void *v)
 		 *
 		 * Treat zero opencnt with non-NULL mountpoint as open.
 		 * This may happen after forced detach of a mounted device.
+		 *
+		 * Also treat sd_closing, meaning there is a concurrent
+		 * close in progress, as still open.
 		 */
-		if (sd->sd_opencnt != 0 || sd->sd_mountpoint != NULL) {
+		if (sd->sd_opencnt != 0 ||
+		    sd->sd_mountpoint != NULL ||
+		    sd->sd_closing) {
 			error = EBUSY;
 			break;
 		}


Home | Main Index | Thread Index | Old Index