summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2020-09-14 18:44:55 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2020-09-14 18:44:55 +0000
commit615c44e01091463bc4820459a47c2bf9a1d4f1ce (patch)
tree543b6bd84447fa50844237338e200789cd73b3f5
parent7acbda27ee6c4cc0adc2996db60816a0466527ed (diff)
No need to check for SDEV_DYING as the first thing in both branches of an
if/else. Just do it once before the if. Move the SC_DEBUG() documenting entry into sdopen() to before the various error bailouts.
-rw-r--r--sys/scsi/sd.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index 141f62fc250..152cd6f3572 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.327 2020/09/13 14:26:56 krw Exp $ */
+/* $OpenBSD: sd.c,v 1.328 2020/09/14 18:44:54 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -315,6 +315,10 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p)
unit = DISKUNIT(dev);
part = DISKPART(dev);
+ SC_DEBUG(link, SDEV_DB1,
+ ("sdopen: dev=0x%x (unit %d (of %d), partition %d)\n", dev, unit,
+ sd_cd.cd_ndevs, part));
+
rawopen = (part == RAW_PART) && (fmt == S_IFCHR);
sc = sdlookup(unit);
@@ -330,25 +334,20 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p)
device_unref(&sc->sc_dev);
return EACCES;
}
-
- SC_DEBUG(link, SDEV_DB1,
- ("sdopen: dev=0x%x (unit %d (of %d), partition %d)\n", dev, unit,
- sd_cd.cd_ndevs, part));
-
if ((error = disk_lock(&sc->sc_dk)) != 0) {
device_unref(&sc->sc_dev);
return error;
}
+ if (ISSET(sc->flags, SDF_DYING)) {
+ error = ENXIO;
+ goto die;
+ }
if (sc->sc_dk.dk_openmask != 0) {
/*
* If any partition is open, but the disk has been invalidated,
* disallow further opens of non-raw partition.
*/
- if (ISSET(sc->flags, SDF_DYING)) {
- error = ENXIO;
- goto die;
- }
if (!ISSET(link->flags, SDEV_MEDIA_LOADED)) {
if (rawopen)
goto out;
@@ -357,10 +356,6 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p)
}
} else {
/* Spin up non-UMASS devices ready or not. */
- if (ISSET(sc->flags, SDF_DYING)) {
- error = ENXIO;
- goto die;
- }
if (!ISSET(link->flags, SDEV_UMASS))
scsi_start(link, SSS_START, (rawopen ? SCSI_SILENT :
0) | SCSI_IGNORE_ILLEGAL_REQUEST |