Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/scsipi avoid division and remainder operations for d...
details: https://anonhg.NetBSD.org/src/rev/d4c615b69dfa
branches: trunk
changeset: 499577:d4c615b69dfa
user: chs <chs%NetBSD.org@localhost>
date: Fri Nov 24 00:17:35 2000 +0000
description:
avoid division and remainder operations for devices where
the sector size is DEV_BSIZE (ie. practically everything).
diffstat:
sys/dev/scsipi/sd.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diffs (55 lines):
diff -r f2e9337b2f62 -r d4c615b69dfa sys/dev/scsipi/sd.c
--- a/sys/dev/scsipi/sd.c Thu Nov 23 23:22:58 2000 +0000
+++ b/sys/dev/scsipi/sd.c Fri Nov 24 00:17:35 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sd.c,v 1.165 2000/11/22 00:32:24 soren Exp $ */
+/* $NetBSD: sd.c,v 1.166 2000/11/24 00:17:35 chs Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -555,6 +555,7 @@
struct disklabel *lp;
daddr_t blkno;
int s;
+ boolean_t sector_aligned;
SC_DEBUG(sd->sc_link, SDEV_DB2, ("sdstrategy "));
SC_DEBUG(sd->sc_link, SDEV_DB1,
@@ -577,8 +578,12 @@
* The transfer must be a whole number of blocks, offset must not be
* negative.
*/
- if ((bp->b_bcount % lp->d_secsize) != 0 ||
- bp->b_blkno < 0) {
+ if (lp->d_secsize == DEV_BSIZE) {
+ sector_aligned = (bp->b_bcount & (DEV_BSIZE - 1)) == 0;
+ } else {
+ sector_aligned = (bp->b_bcount % lp->d_secsize) == 0;
+ }
+ if (!sector_aligned || bp->b_blkno < 0) {
bp->b_error = EINVAL;
goto bad;
}
@@ -601,7 +606,9 @@
* Now convert the block number to absolute and put it in
* terms of the device's logical block size.
*/
- if (lp->d_secsize >= DEV_BSIZE)
+ if (lp->d_secsize == DEV_BSIZE)
+ blkno = bp->b_blkno;
+ else if (lp->d_secsize > DEV_BSIZE)
blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
else
blkno = bp->b_blkno * (DEV_BSIZE / lp->d_secsize);
@@ -708,7 +715,10 @@
* We have a buf, now we should make a command.
*/
- nblks = howmany(bp->b_bcount, lp->d_secsize);
+ if (lp->d_secsize == DEV_BSIZE)
+ nblks = bp->b_bcount >> DEV_BSHIFT;
+ else
+ nblks = howmany(bp->b_bcount, lp->d_secsize);
#if NSD_SCSIBUS > 0
/*
Home |
Main Index |
Thread Index |
Old Index