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): Omit needless locking in dksize, dkdump.



details:   https://anonhg.NetBSD.org/src/rev/bef443bffa87
branches:  trunk
changeset: 374392:bef443bffa87
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Apr 21 18:44:58 2023 +0000

description:
dk(4): Omit needless locking in dksize, dkdump.

All the members these use are stable after initialization, except for
the wedge size, which dkwedge_size safely reads a snapshot of without
locking in the caller.

diffstat:

 sys/dev/dkwedge/dk.c |  16 ++--------------
 1 files changed, 2 insertions(+), 14 deletions(-)

diffs (58 lines):

diff -r 22c475dd81d7 -r bef443bffa87 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Fri Apr 21 18:44:18 2023 +0000
+++ b/sys/dev/dkwedge/dk.c      Fri Apr 21 18:44:58 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.145 2023/04/21 18:44:18 riastradh Exp $       */
+/*     $NetBSD: dk.c,v 1.146 2023/04/21 18:44:58 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.145 2023/04/21 18:44:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.146 2023/04/21 18:44:58 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1809,9 +1809,6 @@ dksize(dev_t dev)
        if (sc->sc_state != DKW_STATE_RUNNING)
                return -1;
 
-       mutex_enter(&sc->sc_dk.dk_openlock);
-       mutex_enter(&sc->sc_parent->dk_rawlock);
-
        /* Our content type is static, no need to open the device. */
 
        p_size = dkwedge_size(sc) << sc->sc_parent->dk_blkshift;
@@ -1823,9 +1820,6 @@ dksize(dev_t dev)
                        rv = (int)p_size;
        }
 
-       mutex_exit(&sc->sc_parent->dk_rawlock);
-       mutex_exit(&sc->sc_dk.dk_openlock);
-
        return rv;
 }
 
@@ -1847,9 +1841,6 @@ dkdump(dev_t dev, daddr_t blkno, void *v
        if (sc->sc_state != DKW_STATE_RUNNING)
                return ENXIO;
 
-       mutex_enter(&sc->sc_dk.dk_openlock);
-       mutex_enter(&sc->sc_parent->dk_rawlock);
-
        /* Our content type is static, no need to open the device. */
 
        if (strcmp(sc->sc_ptype, DKW_PTYPE_SWAP) != 0 &&
@@ -1878,9 +1869,6 @@ dkdump(dev_t dev, daddr_t blkno, void *v
        rv = (*bdev->d_dump)(sc->sc_pdev, blkno + p_offset, va, size);
 
 out:
-       mutex_exit(&sc->sc_parent->dk_rawlock);
-       mutex_exit(&sc->sc_dk.dk_openlock);
-
        return rv;
 }
 



Home | Main Index | Thread Index | Old Index