summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2013-09-15 13:44:53 +0000
committerkrw <krw@openbsd.org>2013-09-15 13:44:53 +0000
commit2e7ffe50de05ce0b04344474408e6f3bcb6c99ea (patch)
treec1d837b131601400e5d953253b20f82181f72a12
parentMention the SBus slot #2 in sun4e is `slave only', just as slot #3 in sun4c. (diff)
downloadwireguard-openbsd-2e7ffe50de05ce0b04344474408e6f3bcb6c99ea.tar.xz
wireguard-openbsd-2e7ffe50de05ce0b04344474408e6f3bcb6c99ea.zip
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.c17
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;