Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/dkwedge Make sure to release sc_parent->dk_rawlock b...
details: https://anonhg.NetBSD.org/src/rev/93c229ca0a08
branches: trunk
changeset: 756816:93c229ca0a08
user: bouyer <bouyer%NetBSD.org@localhost>
date: Wed Aug 04 12:34:00 2010 +0000
description:
Make sure to release sc_parent->dk_rawlock before calling
vn_close(sc->sc_parent->dk_rawvp). Avoids a lockdebug panic:
error: mutex_destroy: assertion failed: !MUTEX_OWNED(mtx->mtx_owner) && !MUTEX_HAS_WAITERS(mtx)
when the parent is a raidframe device.
See also:
http://mail-index.netbsd.org/tech-kern/2010/07/27/msg008612.html
diffstat:
sys/dev/dkwedge/dk.c | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diffs (86 lines):
diff -r 0c984f9379ed -r 93c229ca0a08 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c Wed Aug 04 11:39:14 2010 +0000
+++ b/sys/dev/dkwedge/dk.c Wed Aug 04 12:34:00 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dk.c,v 1.56 2010/06/24 13:03:08 hannken Exp $ */
+/* $NetBSD: dk.c,v 1.57 2010/08/04 12:34:00 bouyer 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.56 2010/06/24 13:03:08 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.57 2010/08/04 12:34:00 bouyer Exp $");
#ifdef _KERNEL_OPT
#include "opt_dkwedge.h"
@@ -511,14 +511,14 @@
rc = 0;
mutex_enter(&dk->dk_openlock);
- mutex_enter(&sc->sc_parent->dk_rawlock);
if (dk->dk_openmask == 0)
; /* nothing to do */
else if ((flags & DETACH_FORCE) == 0)
rc = EBUSY;
- else
- rc = dklastclose(sc);
- mutex_exit(&sc->sc_parent->dk_rawlock);
+ else {
+ mutex_enter(&sc->sc_parent->dk_rawlock);
+ rc = dklastclose(sc); /* releases dk_rawlock */
+ }
mutex_exit(&dk->dk_openlock);
return rc;
@@ -577,17 +577,18 @@
/* Clean up the parent. */
mutex_enter(&sc->sc_dk.dk_openlock);
- mutex_enter(&sc->sc_parent->dk_rawlock);
if (sc->sc_dk.dk_openmask) {
+ mutex_enter(&sc->sc_parent->dk_rawlock);
if (sc->sc_parent->dk_rawopens-- == 1) {
KASSERT(sc->sc_parent->dk_rawvp != NULL);
+ mutex_exit(&sc->sc_parent->dk_rawlock);
(void) vn_close(sc->sc_parent->dk_rawvp, FREAD | FWRITE,
NOCRED);
sc->sc_parent->dk_rawvp = NULL;
- }
+ } else
+ mutex_exit(&sc->sc_parent->dk_rawlock);
sc->sc_dk.dk_openmask = 0;
}
- mutex_exit(&sc->sc_parent->dk_rawlock);
mutex_exit(&sc->sc_dk.dk_openlock);
/* Announce our departure. */
@@ -1050,10 +1051,12 @@
if (sc->sc_parent->dk_rawopens-- == 1) {
KASSERT(sc->sc_parent->dk_rawvp != NULL);
+ mutex_exit(&sc->sc_parent->dk_rawlock);
error = vn_close(sc->sc_parent->dk_rawvp,
FREAD | FWRITE, NOCRED);
sc->sc_parent->dk_rawvp = NULL;
- }
+ } else
+ mutex_exit(&sc->sc_parent->dk_rawlock);
return error;
}
@@ -1081,9 +1084,10 @@
sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;
if (sc->sc_dk.dk_openmask == 0)
- error = dklastclose(sc);
+ error = dklastclose(sc); /* releases dk_rawlock */
+ else
+ mutex_exit(&sc->sc_parent->dk_rawlock);
- mutex_exit(&sc->sc_parent->dk_rawlock);
mutex_exit(&sc->sc_dk.dk_openlock);
return (error);
Home |
Main Index |
Thread Index |
Old Index