summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2020-08-20 01:47:45 +0000
committerkrw <krw@openbsd.org>2020-08-20 01:47:45 +0000
commitd35ed37db97740339408744b8adf4d7e561e38c8 (patch)
treec6d2275740894b0cad167ed5e784e5f5c48011ef
parentReplace last 2 'blah & (flag1 | flag2) == 0' with !ISSET(blah, (flag1 | flag2)). (diff)
downloadwireguard-openbsd-d35ed37db97740339408744b8adf4d7e561e38c8.tar.xz
wireguard-openbsd-d35ed37db97740339408744b8adf4d7e561e38c8.zip
Revert DYING. At least some USB memory sticks get very upset.
-rw-r--r--sys/scsi/cd.c16
-rw-r--r--sys/scsi/sd.c75
-rw-r--r--sys/scsi/sdvar.h3
-rw-r--r--sys/scsi/st.c16
4 files changed, 55 insertions, 55 deletions
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c
index a47b998fc05..a8d2d3bb680 100644
--- a/sys/scsi/cd.c
+++ b/sys/scsi/cd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd.c,v 1.250 2020/08/19 14:53:39 krw Exp $ */
+/* $OpenBSD: cd.c,v 1.251 2020/08/20 01:47:45 krw Exp $ */
/* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */
/*
@@ -67,7 +67,6 @@
#include <sys/scsiio.h>
#include <sys/dkio.h>
#include <sys/vnode.h>
-#include <sys/atomic.h>
#include <scsi/scsi_all.h>
#include <scsi/cd.h>
@@ -101,6 +100,7 @@ struct cd_softc {
int sc_flags;
#define CDF_ANCIENT 0x10 /* disk is ancient; for cdminphys */
+#define CDF_DYING 0x40 /* dying, when deactivated */
struct scsi_link *sc_link; /* contains targ, lun, etc. */
struct cd_parms {
u_int32_t secsize;
@@ -251,7 +251,7 @@ cdactivate(struct device *self, int act)
SCSI_SILENT | SCSI_AUTOCONF);
break;
case DVACT_DEACTIVATE:
- atomic_setbits_int(&sc->sc_link->state, SDEV_S_DYING);
+ SET(sc->sc_flags, CDF_DYING);
scsi_xsh_del(&sc->sc_xsh);
break;
}
@@ -292,7 +292,7 @@ cdopen(dev_t dev, int flag, int fmt, struct proc *p)
sc = cdlookup(unit);
if (sc == NULL)
return ENXIO;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->sc_flags, CDF_DYING)) {
device_unref(&sc->sc_dev);
return ENXIO;
}
@@ -402,7 +402,7 @@ cdclose(dev_t dev, int flag, int fmt, struct proc *p)
sc = cdlookup(DISKUNIT(dev));
if (sc == NULL)
return ENXIO;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->sc_flags, CDF_DYING)) {
device_unref(&sc->sc_dev);
return ENXIO;
}
@@ -451,7 +451,7 @@ cdstrategy(struct buf *bp)
bp->b_error = ENXIO;
goto bad;
}
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->sc_flags, CDF_DYING)) {
bp->b_error = ENXIO;
goto bad;
}
@@ -524,7 +524,7 @@ cdstart(struct scsi_xfer *xs)
SC_DEBUG(link, SDEV_DB2, ("cdstart\n"));
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->sc_flags, CDF_DYING)) {
scsi_xs_put(xs);
return;
}
@@ -729,7 +729,7 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
sc = cdlookup(DISKUNIT(dev));
if (sc == NULL)
return ENXIO;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->sc_flags, CDF_DYING)) {
device_unref(&sc->sc_dev);
return ENXIO;
}
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index c48ae3ffef0..ad2b3bdf1e8 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.316 2020/08/19 14:53:39 krw Exp $ */
+/* $OpenBSD: sd.c,v 1.317 2020/08/20 01:47:45 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -68,7 +68,6 @@
#include <sys/scsiio.h>
#include <sys/dkio.h>
#include <sys/reboot.h>
-#include <sys/atomic.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_debug.h>
@@ -260,7 +259,7 @@ sdactivate(struct device *self, int act)
struct scsi_link *link;
struct sd_softc *sc = (struct sd_softc *)self;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING))
+ if (ISSET(sc->flags, SDF_DYING))
return ENXIO;
link = sc->sc_link;
@@ -292,7 +291,7 @@ sdactivate(struct device *self, int act)
SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_AUTOCONF);
break;
case DVACT_DEACTIVATE:
- atomic_setbits_int(&sc->sc_link->state, SDEV_S_DYING);
+ SET(sc->flags, SDF_DYING);
timeout_del(&sc->sc_timeout);
scsi_xsh_del(&sc->sc_xsh);
break;
@@ -334,7 +333,7 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p)
sc = sdlookup(unit);
if (sc == NULL)
return ENXIO;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
device_unref(&sc->sc_dev);
return ENXIO;
}
@@ -359,7 +358,7 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p)
* If any partition is open, but the disk has been invalidated,
* disallow further opens of non-raw partition.
*/
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
error = ENXIO;
goto die;
}
@@ -371,7 +370,7 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p)
}
} else {
/* Spin up non-UMASS devices ready or not. */
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
error = ENXIO;
goto die;
}
@@ -387,7 +386,7 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p)
* device returns "Initialization command required." and causes
* a loop of scsi_start() calls.
*/
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
error = ENXIO;
goto die;
}
@@ -405,7 +404,7 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p)
}
/* Check that it is still responding and ok. */
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
error = ENXIO;
goto die;
}
@@ -421,13 +420,13 @@ sdopen(dev_t dev, int flag, int fmt, struct proc *p)
}
/* Load the physical device parameters. */
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
error = ENXIO;
goto die;
}
SET(link->flags, SDEV_MEDIA_LOADED);
if (sd_get_parms(sc, (rawopen ? SCSI_SILENT : 0)) == -1) {
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
error = ENXIO;
goto die;
}
@@ -453,7 +452,7 @@ out:
/* It's OK to fall through because dk_openmask is now non-zero. */
bad:
if (sc->sc_dk.dk_openmask == 0) {
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
error = ENXIO;
goto die;
}
@@ -461,7 +460,7 @@ bad:
scsi_prevent(link, PR_ALLOW, SCSI_SILENT |
SCSI_IGNORE_ILLEGAL_REQUEST |
SCSI_IGNORE_MEDIA_CHANGE);
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
error = ENXIO;
goto die;
}
@@ -489,7 +488,7 @@ sdclose(dev_t dev, int flag, int fmt, struct proc *p)
sc = sdlookup(DISKUNIT(dev));
if (sc == NULL)
return ENXIO;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
device_unref(&sc->sc_dev);
return ENXIO;
}
@@ -504,7 +503,7 @@ sdclose(dev_t dev, int flag, int fmt, struct proc *p)
sd_flush(sc, 0);
if (sc->sc_dk.dk_openmask == 0) {
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
error = ENXIO;
goto die;
}
@@ -512,7 +511,7 @@ sdclose(dev_t dev, int flag, int fmt, struct proc *p)
scsi_prevent(link, PR_ALLOW,
SCSI_IGNORE_ILLEGAL_REQUEST |
SCSI_IGNORE_NOT_READY | SCSI_SILENT);
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
error = ENXIO;
goto die;
}
@@ -520,7 +519,7 @@ sdclose(dev_t dev, int flag, int fmt, struct proc *p)
if (ISSET(link->flags, SDEV_EJECTING)) {
scsi_start(link, SSS_STOP|SSS_LOEJ, 0);
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
error = ENXIO;
goto die;
}
@@ -554,7 +553,7 @@ sdstrategy(struct buf *bp)
bp->b_error = ENXIO;
goto bad;
}
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
bp->b_error = ENXIO;
goto bad;
}
@@ -671,7 +670,7 @@ sdstart(struct scsi_xfer *xs)
int nsecs, read;
u_int64_t secno;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
scsi_xs_put(xs);
return;
}
@@ -808,7 +807,7 @@ sdminphys(struct buf *bp)
sc = sdlookup(DISKUNIT(bp->b_dev));
if (sc == NULL)
return; /* XXX - right way to fail this? */
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
device_unref(&sc->sc_dev);
return;
}
@@ -868,7 +867,7 @@ sdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
sc = sdlookup(DISKUNIT(dev));
if (sc == NULL)
return ENXIO;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
device_unref(&sc->sc_dev);
return ENXIO;
}
@@ -1009,7 +1008,7 @@ sd_ioctl_inquiry(struct sd_softc *sc, struct dk_inquiry *di)
vpd = dma_alloc(sizeof(*vpd), PR_WAITOK | PR_ZERO);
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
dma_free(vpd, sizeof(*vpd));
return ENXIO;
}
@@ -1042,7 +1041,7 @@ sd_ioctl_cache(struct sd_softc *sc, long cmd, struct dk_cache *dkc)
u_int wrcache, rdcache;
int big, rv;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING))
+ if (ISSET(sc->flags, SDF_DYING))
return ENXIO;
link = sc->sc_link;
@@ -1058,7 +1057,7 @@ sd_ioctl_cache(struct sd_softc *sc, long cmd, struct dk_cache *dkc)
if (buf == NULL)
return ENOMEM;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
rv = ENXIO;
goto done;
}
@@ -1092,7 +1091,7 @@ sd_ioctl_cache(struct sd_softc *sc, long cmd, struct dk_cache *dkc)
else
SET(mode->flags, PG_CACHE_FL_RCD);
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
rv = ENXIO;
goto done;
}
@@ -1123,7 +1122,7 @@ sdgetdisklabel(dev_t dev, struct sd_softc *sc, struct disklabel *lp,
struct scsi_link *link;
size_t len;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING))
+ if (ISSET(sc->flags, SDF_DYING))
return ENXIO;
link = sc->sc_link;
@@ -1249,7 +1248,7 @@ sdsize(dev_t dev)
sc = sdlookup(DISKUNIT(dev));
if (sc == NULL)
return -1;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
size = -1;
goto exit;
}
@@ -1263,7 +1262,7 @@ sdsize(dev_t dev)
}
lp = sc->sc_dk.dk_label;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
size = -1;
goto exit;
}
@@ -1418,7 +1417,7 @@ sd_read_cap_10(struct sd_softc *sc, int flags)
if (rdcap == NULL)
return -1;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
rv = -1;
goto done;
}
@@ -1450,7 +1449,7 @@ sd_read_cap_16(struct sd_softc *sc, int flags)
if (rdcap == NULL)
return -1;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
rv = -1;
goto done;
}
@@ -1514,7 +1513,7 @@ sd_thin_pages(struct sd_softc *sc, int flags)
if (pg == NULL)
return ENOMEM;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
rv = ENXIO;
goto done;
}
@@ -1531,7 +1530,7 @@ sd_thin_pages(struct sd_softc *sc, int flags)
if (pg == NULL)
return ENOMEM;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
rv = ENXIO;
goto done;
}
@@ -1574,7 +1573,7 @@ sd_vpd_block_limits(struct sd_softc *sc, int flags)
if (pg == NULL)
return ENOMEM;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
rv = ENXIO;
goto done;
}
@@ -1605,7 +1604,7 @@ sd_vpd_thin(struct sd_softc *sc, int flags)
if (pg == NULL)
return ENOMEM;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(sc->flags, SDF_DYING)) {
rv = ENXIO;
goto done;
}
@@ -1686,7 +1685,7 @@ sd_get_parms(struct sd_softc *sc, int flags)
if (buf == NULL)
goto validate;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING))
+ if (ISSET(sc->flags, SDF_DYING))
goto die;
/*
@@ -1697,7 +1696,7 @@ sd_get_parms(struct sd_softc *sc, int flags)
*/
err = scsi_do_mode_sense(link, 0, buf, (void **)&page0, 1,
flags | SCSI_SILENT, &big);
- if (ISSET(sc->sc_link->state, SDEV_S_DYING))
+ if (ISSET(sc->flags, SDF_DYING))
goto die;
if (err == 0) {
if (big && buf->hdr_big.dev_spec & SMH_DSP_WRITE_PROT)
@@ -1763,7 +1762,7 @@ sd_get_parms(struct sd_softc *sc, int flags)
dp.cyls);
}
} else {
- if (ISSET(sc->sc_link->state, SDEV_S_DYING))
+ if (ISSET(sc->flags, SDF_DYING))
goto die;
err = scsi_do_mode_sense(link, PAGE_FLEX_GEOMETRY, buf,
(void **)&flex, sizeof(*flex) - 4,
@@ -1874,7 +1873,7 @@ sd_flush(struct sd_softc *sc, int flags)
struct scsi_synchronize_cache *cmd;
int error;
- if (ISSET(sc->sc_link->state, SDEV_S_DYING))
+ if (ISSET(sc->flags, SDF_DYING))
return ENXIO;
link = sc->sc_link;
diff --git a/sys/scsi/sdvar.h b/sys/scsi/sdvar.h
index 69a2aab05fb..c8c22737f54 100644
--- a/sys/scsi/sdvar.h
+++ b/sys/scsi/sdvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdvar.h,v 1.48 2020/08/19 14:53:39 krw Exp $ */
+/* $OpenBSD: sdvar.h,v 1.49 2020/08/20 01:47:45 krw Exp $ */
/* $NetBSD: sdvar.h,v 1.7 1998/08/17 00:49:03 mycroft Exp $ */
/*-
@@ -59,6 +59,7 @@ struct sd_softc {
int flags;
#define SDF_ANCIENT 0x10 /* disk is ancient; for sdminphys */
#define SDF_DIRTY 0x20 /* disk is dirty; needs cache flush */
+#define SDF_DYING 0x40 /* dying, when deactivated */
#define SDF_THIN 0x01 /* disk is thin provisioned */
struct scsi_link *sc_link; /* contains our targ, lun, etc. */
struct disk_parms {
diff --git a/sys/scsi/st.c b/sys/scsi/st.c
index 6d29deca5c9..66dc3545645 100644
--- a/sys/scsi/st.c
+++ b/sys/scsi/st.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: st.c,v 1.182 2020/08/19 14:53:39 krw Exp $ */
+/* $OpenBSD: st.c,v 1.183 2020/08/20 01:47:45 krw Exp $ */
/* $NetBSD: st.c,v 1.71 1997/02/21 23:03:49 thorpej Exp $ */
/*
@@ -67,7 +67,6 @@
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/vnode.h>
-#include <sys/atomic.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_debug.h>
@@ -172,6 +171,7 @@ struct st_softc {
#define ST_2FM_AT_EOD 0x00000400
#define ST_MOUNTED 0x00000800
#define ST_DONTBUFFER 0x00001000
+#define ST_DYING 0x00004000
#define ST_BOD_DETECTED 0x00008000
#define ST_MODE_DENSITY 0x00010000
#define ST_MODE_BLKSIZE 0x00040000
@@ -321,7 +321,7 @@ stactivate(struct device *self, int act)
switch (act) {
case DVACT_DEACTIVATE:
- atomic_setbits_int(&st->sc_link->state, SDEV_S_DYING);
+ SET(st->flags, ST_DYING);
scsi_xsh_del(&st->sc_xsh);
break;
}
@@ -362,7 +362,7 @@ stopen(dev_t dev, int flags, int fmt, struct proc *p)
st = stlookup(STUNIT(dev));
if (st == NULL)
return ENXIO;
- if (ISSET(st->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(st->flags, ST_DYING)) {
error = ENXIO;
goto done;
}
@@ -441,7 +441,7 @@ stclose(dev_t dev, int flags, int mode, struct proc *p)
st = stlookup(STUNIT(dev));
if (st == NULL)
return ENXIO;
- if (ISSET(st->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(st->flags, ST_DYING)) {
error = ENXIO;
goto done;
}
@@ -729,7 +729,7 @@ ststrategy(struct buf *bp)
bp->b_error = ENXIO;
goto bad;
}
- if (ISSET(st->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(st->flags, ST_DYING)) {
bp->b_error = ENXIO;
goto bad;
}
@@ -804,7 +804,7 @@ ststart(struct scsi_xfer *xs)
SC_DEBUG(link, SDEV_DB2, ("ststart\n"));
- if (ISSET(st->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(st->flags, ST_DYING)) {
scsi_xs_put(xs);
return;
}
@@ -1049,7 +1049,7 @@ stioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p)
if (st == NULL)
return ENXIO;
- if (ISSET(st->sc_link->state, SDEV_S_DYING)) {
+ if (ISSET(st->flags, ST_DYING)) {
error = ENXIO;
goto done;
}