Module Name:    src
Committed By:   riz
Date:           Sun Nov 21 18:50:17 UTC 2010

Modified Files:
        src/sys/dev/dkwedge [netbsd-5]: dk.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #1435):
        sys/dev/dkwedge/dk.c: revision 1.57
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


To generate a diff of this commit:
cvs rdiff -u -r1.42.6.2 -r1.42.6.3 src/sys/dev/dkwedge/dk.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/dev/dkwedge/dk.c
diff -u src/sys/dev/dkwedge/dk.c:1.42.6.2 src/sys/dev/dkwedge/dk.c:1.42.6.3
--- src/sys/dev/dkwedge/dk.c:1.42.6.2	Sat Jan 30 19:00:46 2010
+++ src/sys/dev/dkwedge/dk.c	Sun Nov 21 18:50:17 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: dk.c,v 1.42.6.2 2010/01/30 19:00:46 snj Exp $	*/
+/*	$NetBSD: dk.c,v 1.42.6.3 2010/11/21 18:50:17 riz 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.42.6.2 2010/01/30 19:00:46 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.42.6.3 2010/11/21 18:50:17 riz Exp $");
 
 #include "opt_dkwedge.h"
 
@@ -476,17 +476,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. */
@@ -968,7 +969,6 @@
 	KASSERT(sc->sc_dk.dk_openmask != 0);
 
 	mutex_enter(&sc->sc_dk.dk_openlock);
-	mutex_enter(&sc->sc_parent->dk_rawlock);
 
 	if (fmt == S_IFCHR)
 		sc->sc_dk.dk_copenmask &= ~1;
@@ -978,15 +978,17 @@
 	    sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;
 
 	if (sc->sc_dk.dk_openmask == 0) {
+		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);
 			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);
 	}
 
-	mutex_exit(&sc->sc_parent->dk_rawlock);
 	mutex_exit(&sc->sc_dk.dk_openlock);
 
 	return (error);

Reply via email to