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): Narrow scope of dk_rawlock on close t...



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

description:
dk(4): Narrow scope of dk_rawlock on close to dklastclose.

No need to take it if we're not actually going to close the parent.

No functional change intended; dk_rawlock is only supposed to
serialize dk_rawopens access and open/close of the parent, after all.

diffstat:

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

diffs (39 lines):

diff -r 32ae27234e4b -r 0cc2346d602e sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Mon Aug 22 00:19:33 2022 +0000
+++ b/sys/dev/dkwedge/dk.c      Mon Aug 22 00:19:43 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.115 2022/08/22 00:19:33 riastradh Exp $       */
+/*     $NetBSD: dk.c,v 1.116 2022/08/22 00:19:43 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.115 2022/08/22 00:19:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.116 2022/08/22 00:19:43 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1246,7 +1246,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;
@@ -1256,10 +1255,11 @@
            sc->sc_dk.dk_copenmask | sc->sc_dk.dk_bopenmask;
 
        if (sc->sc_dk.dk_openmask == 0) {
+               mutex_enter(&sc->sc_parent->dk_rawlock);
                error = dklastclose(sc);
+               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