summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2019-01-20 03:28:20 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2019-01-20 03:28:20 +0000
commit266f1fd54025aeb23ac8f5c70997abcd45bee2cd (patch)
tree16fe0864dda58bf2acdc31248fbff02edaafa02f /sys/scsi
parent145437242b0cda5f4644f33b6b86e0c0e08ff95a (diff)
When retiring a SCSI request, sometimes the buf's b_error value is
forcibly set to a value. Make sure that in all those cases the B_ERROR flag is cleared (if b_error is being set to 0) or set (if b_error is being set to non-zero) appropriately. ok dlg@ jmatthew@
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/cd.c10
-rw-r--r--sys/scsi/sd.c11
-rw-r--r--sys/scsi/st.c14
3 files changed, 21 insertions, 14 deletions
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c
index 7e0ea441142..d8b60247f2f 100644
--- a/sys/scsi/cd.c
+++ b/sys/scsi/cd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd.c,v 1.222 2017/12/30 23:08:29 guenther Exp $ */
+/* $OpenBSD: cd.c,v 1.223 2019/01/20 03:28:19 krw Exp $ */
/* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */
/*
@@ -483,9 +483,9 @@ cdstrategy(struct buf *bp)
return;
bad:
- bp->b_flags |= B_ERROR;
+ SET(bp->b_flags, B_ERROR);
bp->b_resid = bp->b_bcount;
- done:
+done:
s = splbio();
biodone(bp);
splx(s);
@@ -616,6 +616,7 @@ cd_buf_done(struct scsi_xfer *xs)
switch (xs->error) {
case XS_NOERROR:
bp->b_error = 0;
+ CLR(bp->b_flags, B_ERROR);
bp->b_resid = xs->resid;
break;
@@ -627,6 +628,7 @@ cd_buf_done(struct scsi_xfer *xs)
error = cd_interpret_sense(xs);
if (error == 0) {
bp->b_error = 0;
+ CLR(bp->b_flags, B_ERROR);
bp->b_resid = xs->resid;
break;
}
@@ -651,7 +653,7 @@ retry:
default:
bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
+ SET(bp->b_flags, B_ERROR);
bp->b_resid = bp->b_bcount;
break;
}
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index a02d787c960..6839e6605fa 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.275 2017/12/30 23:08:29 guenther Exp $ */
+/* $OpenBSD: sd.c,v 1.276 2019/01/20 03:28:19 krw Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -601,9 +601,9 @@ sdstrategy(struct buf *bp)
return;
bad:
- bp->b_flags |= B_ERROR;
+ SET(bp->b_flags, B_ERROR);
bp->b_resid = bp->b_bcount;
- done:
+done:
s = splbio();
biodone(bp);
splx(s);
@@ -759,6 +759,7 @@ sd_buf_done(struct scsi_xfer *xs)
switch (xs->error) {
case XS_NOERROR:
bp->b_error = 0;
+ CLR(bp->b_flags, B_ERROR);
bp->b_resid = xs->resid;
break;
@@ -770,11 +771,13 @@ sd_buf_done(struct scsi_xfer *xs)
error = sd_interpret_sense(xs);
if (error == 0) {
bp->b_error = 0;
+ CLR(bp->b_flags, B_ERROR);
bp->b_resid = xs->resid;
break;
}
if (error != ERESTART) {
bp->b_error = error;
+ SET(bp->b_flags, B_ERROR);
xs->retries = 0;
}
goto retry;
@@ -797,7 +800,7 @@ retry:
default:
if (bp->b_error == 0)
bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
+ SET(bp->b_flags, B_ERROR);
bp->b_resid = bp->b_bcount;
break;
}
diff --git a/sys/scsi/st.c b/sys/scsi/st.c
index 3f88efd1c58..0335175bd03 100644
--- a/sys/scsi/st.c
+++ b/sys/scsi/st.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: st.c,v 1.134 2017/09/08 05:36:53 deraadt Exp $ */
+/* $OpenBSD: st.c,v 1.135 2019/01/20 03:28:19 krw Exp $ */
/* $NetBSD: st.c,v 1.71 1997/02/21 23:03:49 thorpej Exp $ */
/*
@@ -883,7 +883,7 @@ ststrategy(struct buf *bp)
device_unref(&st->sc_dev);
return;
bad:
- bp->b_flags |= B_ERROR;
+ SET(bp->b_flags, B_ERROR);
done:
/* Set b_resid to indicate no xfer was done. */
bp->b_resid = bp->b_bcount;
@@ -948,7 +948,7 @@ ststart(struct scsi_xfer *xs)
* Back up over filemark
*/
if (st_space(st, 0, SP_FILEMARKS, 0)) {
- bp->b_flags |= B_ERROR;
+ SET(bp->b_flags, B_ERROR);
bp->b_resid = bp->b_bcount;
bp->b_error = EIO;
s = splbio();
@@ -959,7 +959,7 @@ ststart(struct scsi_xfer *xs)
} else {
bp->b_resid = bp->b_bcount;
bp->b_error = 0;
- bp->b_flags &= ~B_ERROR;
+ CLR(bp->b_flags, B_ERROR);
st->flags &= ~ST_AT_FILEMARK;
s = splbio();
biodone(bp);
@@ -977,7 +977,7 @@ ststart(struct scsi_xfer *xs)
bp->b_resid = bp->b_bcount;
if (st->flags & ST_EIO_PENDING) {
bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
+ SET(bp->b_flags, B_ERROR);
}
st->flags &= ~(ST_EOM_PENDING | ST_EIO_PENDING);
s = splbio();
@@ -1052,6 +1052,7 @@ st_buf_done(struct scsi_xfer *xs)
switch (xs->error) {
case XS_NOERROR:
bp->b_error = 0;
+ CLR(bp->b_flags, B_ERROR);
bp->b_resid = xs->resid;
break;
@@ -1063,6 +1064,7 @@ st_buf_done(struct scsi_xfer *xs)
error = st_interpret_sense(xs);
if (error == 0) {
bp->b_error = 0;
+ CLR(bp->b_flags, B_ERROR);
bp->b_resid = xs->resid;
break;
}
@@ -1087,7 +1089,7 @@ retry:
default:
bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
+ SET(bp->b_flags, B_ERROR);
bp->b_resid = bp->b_bcount;
break;
}