Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/dkwedge dk(4): Serialize closing parent's dk_rawvp w...
details: https://anonhg.NetBSD.org/src/rev/e0c4183c2754
branches: trunk
changeset: 369567:e0c4183c2754
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Aug 22 00:19:12 2022 +0000
description:
dk(4): Serialize closing parent's dk_rawvp with opening it.
Otherwise, the following events might happen:
- process 123 had /dev/rdkN open, starts close, enters dk_close_parent
- process 456 opens /dev/rdkM (same parent, different wedge), calls
dk_open_parent
At this point, the block device hasn't yet closed, so dk_open_parent
will fail with EBUSY. This is incorrect -- the chardev is never
supposed to fail with EBUSY, and dkopen/dkclose carefully manage
state to avoid opening the block device while it's still open. The
problem is that dkopen in process 456 didn't wait for vn_close
in process 123 to finish before calling VOP_OPEN.
(Note: If it were the _same_ chardev /dev/rdkN in both processes,
then spec_open/close would prevent this. But since it's a
_different_ chardev, spec_open/close assume that concurrency is OK,
and it's the driver's responsibility to serialize access to the
parent disk which, unbeknownst to spec_open/close, is shared between
dkN and dkM.)
It appears that the vn_close call was previously moved outside
dk_rawlock in 2010 to work around an unrelated bug in raidframe that
had already been fixed in HEAD:
Crash pointing to dk_rawlock and raidclose:
https://mail-index.netbsd.org/tech-kern/2010/07/27/msg008612.html
Change working around that crash:
https://mail-index.netbsd.org/source-changes/2010/08/04/msg012270.html
Change removing raidclose -> mutex_destroy(&dk_rawlock) path:
https://mail-index.netbsd.org/source-changes/2009/07/23/msg223381.html
diffstat:
sys/dev/dkwedge/dk.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diffs (35 lines):
diff -r 3db9db5769d2 -r e0c4183c2754 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c Sun Aug 21 22:28:26 2022 +0000
+++ b/sys/dev/dkwedge/dk.c Mon Aug 22 00:19:12 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dk.c,v 1.112 2022/06/11 18:17:00 martin Exp $ */
+/* $NetBSD: dk.c,v 1.113 2022/08/22 00:19:12 riastradh Exp $ */
/*-
* Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.112 2022/06/11 18:17:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.113 2022/08/22 00:19:12 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_dkwedge.h"
@@ -1220,13 +1220,13 @@
}
}
- mutex_exit(&sc->sc_parent->dk_rawlock);
- mutex_exit(&sc->sc_dk.dk_openlock);
-
if (vp) {
dk_close_parent(vp, mode);
}
+ mutex_exit(&sc->sc_parent->dk_rawlock);
+ mutex_exit(&sc->sc_dk.dk_openlock);
+
return error;
}
Home |
Main Index |
Thread Index |
Old Index