diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-09-15 13:44:54 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-09-15 13:44:54 +0000 |
commit | 7f7d775155b9933eeb3b036d749137be5a37a556 (patch) | |
tree | 94dcd1f5ea5fd322197a2c40e83cff0125fa0ae3 | |
parent | 6544d87f9995cfd60d56390d488c7809bbcf5932 (diff) |
Make it clearer that sc_wdc_bio.blkno is actuall a disk hardware
address by using the DL_BLKTOSEC() and DL_SECTOBLK() defines rather
than handrolling the equivalent. Fixes current addition of a 512-byte
block value (b_blkno) to a disk hardware address (DL_GETPOFFSET()).
Tested on real wd(4) hardware by guenther@.
-rw-r--r-- | sys/dev/ata/wd.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index c88468be074..8a9fc58a8bb 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wd.c,v 1.110 2013/06/11 16:42:14 deraadt Exp $ */ +/* $OpenBSD: wd.c,v 1.111 2013/09/15 13:44:53 krw Exp $ */ /* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */ /* @@ -465,11 +465,12 @@ wdstart(void *arg) void __wdstart(struct wd_softc *wd, struct buf *bp) { - daddr_t nblks; + struct disklabel *lp; + u_int64_t nsecs; - wd->sc_wdc_bio.blkno = bp->b_blkno + - DL_GETPOFFSET(&wd->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)]); - wd->sc_wdc_bio.blkno /= (wd->sc_dk.dk_label->d_secsize / DEV_BSIZE); + lp = wd->sc_dk.dk_label; + wd->sc_wdc_bio.blkno = DL_BLKTOSEC(lp, bp->b_blkno + DL_SECTOBLK(lp, + DL_GETPOFFSET(&lp->d_partitions[DISKPART(bp->b_dev)]))); wd->sc_wdc_bio.blkdone =0; wd->sc_bp = bp; /* @@ -481,11 +482,11 @@ __wdstart(struct wd_softc *wd, struct buf *bp) wd->sc_wdc_bio.flags = ATA_SINGLE; else wd->sc_wdc_bio.flags = 0; - nblks = bp->b_bcount / wd->sc_dk.dk_label->d_secsize; + nsecs = howmany(bp->b_bcount, lp->d_secsize); if ((wd->sc_flags & WDF_LBA48) && /* use LBA48 only if really need */ - ((wd->sc_wdc_bio.blkno + nblks - 1 >= LBA48_THRESHOLD) || - (nblks > 0xff))) + ((wd->sc_wdc_bio.blkno + nsecs - 1 >= LBA48_THRESHOLD) || + (nsecs > 0xff))) wd->sc_wdc_bio.flags |= ATA_LBA48; if (wd->sc_flags & WDF_LBA) wd->sc_wdc_bio.flags |= ATA_LBA; |