summaryrefslogtreecommitdiffstats
path: root/sys/scsi
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1998-07-29 11:15:54 +0000
committerbde <bde@FreeBSD.org>1998-07-29 11:15:54 +0000
commit57a5f9023d7ba6eb9c0fe02789312a0d6ae4e363 (patch)
tree4afbc549527fb0b6e26795be8cee174ce0d65c5a /sys/scsi
parent4a3c46b3596a248587fc4fd2fdfe53f2443eded9 (diff)
downloadFreeBSD-src-57a5f9023d7ba6eb9c0fe02789312a0d6ae4e363.zip
FreeBSD-src-57a5f9023d7ba6eb9c0fe02789312a0d6ae4e363.tar.gz
Centralized and optimized handling of large sectors. Centralized
checking of transfer sizes and alignments. Old version tested with 2K-sectors on od disks by: Shunsuke Akiyama <akiyama@kme.mei.co.jp>.
Diffstat (limited to 'sys/scsi')
-rw-r--r--sys/scsi/od.c57
-rw-r--r--sys/scsi/sd.c60
2 files changed, 7 insertions, 110 deletions
diff --git a/sys/scsi/od.c b/sys/scsi/od.c
index 1dc817e..4769406 100644
--- a/sys/scsi/od.c
+++ b/sys/scsi/od.c
@@ -28,7 +28,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: od.c,v 1.42 1998/07/13 09:53:11 bde Exp $
+ * $Id: od.c,v 1.43 1998/07/28 18:59:49 bde Exp $
*/
/*
@@ -456,7 +456,6 @@ od_strategy(struct buf *bp, struct scsi_link *sc_link)
u_int32_t opri;
struct scsi_data *od;
u_int32_t unit;
- int secsize;
odstrats++;
unit = ODUNIT((bp->b_dev));
@@ -471,62 +470,10 @@ od_strategy(struct buf *bp, struct scsi_link *sc_link)
}
/*
- * Odd number of bytes or negative offset
- */
- if (bp->b_blkno < 0 ) {
- bp->b_error = EINVAL;
- printf("od_strategy: Negative block number: 0x%x\n", bp->b_blkno);
- goto bad;
- }
-
-
- secsize = od->params.secsiz;
-
- /* make sure the blkno is scalable */
- if( (bp->b_blkno % (secsize/DEV_BSIZE)) != 0 ) {
- bp->b_error = EINVAL;
- printf("od_strategy: Block number is not multiple of sector size (2): 0x%x\n", bp->b_blkno);
- goto bad;
- }
-
- /* make sure that the transfer size is a multiple of the sector size */
- if( (bp->b_bcount % secsize) != 0 ) {
- bp->b_error = EINVAL;
- printf(
- "od_strategy: Invalid b_bcount %ld at block number: 0x%lx\n",
- bp->b_bcount, (long)bp->b_blkno);
- goto bad;
- }
-
- /*
* Do bounds checking, adjust transfer, and set b_pblkno.
*/
- {
- int status;
- int sec_blk_ratio = secsize/DEV_BSIZE;
- /* save original block number and size */
- int b_blkno = bp->b_blkno;
- int b_bcount = bp->b_bcount;
-
- /* replace with scaled values */
- bp->b_blkno /= sec_blk_ratio;
- bp->b_bcount /= sec_blk_ratio;
-
- /* have dscheck enforce limits and map to physical block number */
- status = dscheck(bp, od->dk_slices);
-
- /* restore original values to prevent bad side effects in block system */
- bp->b_blkno = b_blkno;
- bp->b_bcount = b_bcount;
- /* scale resid */
- bp->b_resid *= sec_blk_ratio;
-
- /* see if the mapping failed */
- if (status <= 0)
- {
+ if (dscheck(bp, od->dk_slices) <= 0)
goto done; /* XXX check b_resid */
- }
- }
opri = SPLOD();
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index c7e191b..8043704 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -14,7 +14,7 @@
*
* Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992
*
- * $Id: sd.c,v 1.135 1998/07/14 11:34:22 bde Exp $
+ * $Id: sd.c,v 1.136 1998/07/28 18:59:49 bde Exp $
*/
#include "opt_bounce.h"
@@ -559,7 +559,7 @@ sd_strategy(struct buf *bp, struct scsi_link *sc_link)
{
u_int32_t opri;
struct scsi_data *sd;
- u_int32_t unit, secsize;
+ u_int32_t unit;
sdstrats++;
unit = SDUNIT((bp->b_dev));
@@ -578,60 +578,10 @@ sd_strategy(struct buf *bp, struct scsi_link *sc_link)
scsi_minphys(bp,&sd_switch);
/*
- * Odd number of bytes or negative offset
+ * Do bounds checking, adjust transfer, and set b_pbklno.
*/
- if (bp->b_blkno < 0 ) {
- bp->b_error = EINVAL;
- printf("sd_strategy: Negative block number: 0x%x\n",
- bp->b_blkno);
- goto bad;
- }
-
- secsize = sd->params.secsiz;
-
- /* make sure the blkno is scalable */
- if( (bp->b_blkno % (secsize/DEV_BSIZE)) != 0 ) {
- bp->b_error = EINVAL;
- printf("sd_strategy: Block number is not multiple of sector size (2): 0x%x\n", bp->b_blkno);
- goto bad;
- }
-
- /* make sure that the transfer size is a multiple of the sector size */
- if( (bp->b_bcount % secsize) != 0 ) {
- bp->b_error = EINVAL;
- printf(
- "sd_strategy: Invalid b_bcount %ld at block number: 0x%lx\n",
- bp->b_bcount, (long)bp->b_blkno);
- goto bad;
- }
-
- /*
- * Do bounds checking, adjust transfer, set b_cylin and b_pbklno.
- */
- {
- int status;
- int sec_blk_ratio = secsize/DEV_BSIZE;
- int b_blkno = bp->b_blkno;
-
- /* Replace blkno and count with scaled values. */
- bp->b_blkno /= sec_blk_ratio;
- bp->b_bcount /= sec_blk_ratio;
-
- /* enforce limits and map to physical block number */
- status = dscheck(bp, sd->dk_slices);
-
- /*
- * Restore blkno and unscale the values set by dscheck(),
- * except for b_pblkno.
- */
- bp->b_blkno = b_blkno;
- bp->b_bcount *= sec_blk_ratio;
- bp->b_resid *= sec_blk_ratio;
-
- /* see if the mapping failed */
- if (status <= 0)
- goto done; /* XXX check b_resid */
- }
+ if (dscheck(bp, sd->dk_slices) <= 0)
+ goto done; /* XXX check b_resid */
opri = SPLSD();
/*
OpenPOWER on IntegriCloud