diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-06 04:49:37 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-06 04:49:37 +0000 |
commit | 51c6c9b181971ccd9a6d6f7f9dd1fa5dc8df1c23 (patch) | |
tree | 9e6859366146d5377f6e62a5adfeca45f358d3ad /sys/scsi/sd.c | |
parent | 9f81aca0122f901a2f924a0d3d759a2d37d682de (diff) |
Eliminate redundant buf validation checks in xxstrategy() methods now
that they're implemented consistently in bounds_check_with_label().
Also, per krw's request, change bounds_check_with_label() to return 0
if the checks succeed, and change the drivers to test == -1 instead of
<= 0. (Man page update to follow; intentionally omitting
arch/vax/mba/hp.c from this commit because it doesn't even build
currently and miod@ promises to kill it soon.)
ok krw@
Diffstat (limited to 'sys/scsi/sd.c')
-rw-r--r-- | sys/scsi/sd.c | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 2222e4a1493..59379bd9da8 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.232 2011/07/03 15:47:18 matthew Exp $ */ +/* $OpenBSD: sd.c,v 1.233 2011/07/06 04:49:36 matthew Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -517,24 +517,9 @@ sdstrategy(struct buf *bp) bp->b_error = ENODEV; goto bad; } - /* - * If it's a null transfer, return immediately - */ - if (bp->b_bcount == 0) - goto done; - /* - * The transfer must be a whole number of sectors. - */ - if ((bp->b_bcount % sc->sc_dk.dk_label->d_secsize) != 0) { - bp->b_error = EINVAL; - goto bad; - } - /* - * Do bounds checking, adjust transfer. if error, process. - * If end of partition, just return. - */ - if (bounds_check_with_label(bp, sc->sc_dk.dk_label) <= 0) + /* Validate the request. */ + if (bounds_check_with_label(bp, sc->sc_dk.dk_label) == -1) goto done; /* Place it in the queue of disk activities for this disk. */ @@ -549,13 +534,10 @@ sdstrategy(struct buf *bp) device_unref(&sc->sc_dev); return; -bad: + bad: bp->b_flags |= B_ERROR; -done: - /* - * Correctly set the buf to indicate a completed xfer - */ bp->b_resid = bp->b_bcount; + done: s = splbio(); biodone(bp); splx(s); |