Module Name: src Committed By: riastradh Date: Mon Aug 22 00:19:22 UTC 2022
Modified Files: src/sys/dev/dkwedge: dk.c Log Message: dk(4): Move lock release out of dklastclose into caller. No longer necessary to have this unbalanced logic now that dk_close_parent correctly happens under the lock in order to serialize with dk_open_parent. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 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.113 src/sys/dev/dkwedge/dk.c:1.114 --- src/sys/dev/dkwedge/dk.c:1.113 Mon Aug 22 00:19:12 2022 +++ src/sys/dev/dkwedge/dk.c Mon Aug 22 00:19:22 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: dk.c,v 1.113 2022/08/22 00:19:12 riastradh Exp $ */ +/* $NetBSD: dk.c,v 1.114 2022/08/22 00:19:22 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.113 2022/08/22 00:19:12 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.114 2022/08/22 00:19:22 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_dkwedge.h" @@ -589,7 +589,9 @@ dkwedge_cleanup_parent(struct dkwedge_so mutex_exit(&dk->dk_openlock); } else { mutex_enter(&sc->sc_parent->dk_rawlock); - rc = dklastclose(sc); /* releases locks */ + rc = dklastclose(sc); + mutex_exit(&sc->sc_parent->dk_rawlock); + mutex_exit(&sc->sc_dk.dk_openlock); } return rc; @@ -1224,9 +1226,6 @@ dklastclose(struct dkwedge_softc *sc) dk_close_parent(vp, mode); } - mutex_exit(&sc->sc_parent->dk_rawlock); - mutex_exit(&sc->sc_dk.dk_openlock); - return error; } @@ -1259,7 +1258,9 @@ dkclose(dev_t dev, int flags, int fmt, s sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask; if (sc->sc_dk.dk_openmask == 0) { - error = dklastclose(sc); /* releases locks */ + error = dklastclose(sc); + mutex_exit(&sc->sc_parent->dk_rawlock); + mutex_exit(&sc->sc_dk.dk_openlock); } else { mutex_exit(&sc->sc_parent->dk_rawlock); mutex_exit(&sc->sc_dk.dk_openlock);