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): Move lock release out of dklastclose ...



details:   https://anonhg.NetBSD.org/src/rev/0848c9aebaea
branches:  trunk
changeset: 369568:0848c9aebaea
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 22 00:19:22 2022 +0000

description:
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.

diffstat:

 sys/dev/dkwedge/dk.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (50 lines):

diff -r e0c4183c2754 -r 0848c9aebaea sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Mon Aug 22 00:19:12 2022 +0000
+++ b/sys/dev/dkwedge/dk.c      Mon Aug 22 00:19:22 2022 +0000
@@ -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 @@
                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 @@
                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 @@
            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);



Home | Main Index | Thread Index | Old Index