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.
This commit is contained in:
parent
a5eec8cb2f
commit
9c2d6869ce
|
@ -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 *va, size_t size)
|
|||
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 *va, size_t size)
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue