From: krw Date: Sat, 12 Jul 2014 20:36:45 +0000 (+0000) Subject: Calculate i/o starts and sizes in 'proper' sectors rather assuming X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e2c089e98696337290fae92c508517b8eebdaf30;p=openbsd Calculate i/o starts and sizes in 'proper' sectors rather assuming 512-byte sectors. Unlikely to affect CF's in the near future. ok pirofti@ --- diff --git a/sys/arch/octeon/dev/octcf.c b/sys/arch/octeon/dev/octcf.c index 4f7b75ed621..4787dbed9d7 100644 --- a/sys/arch/octeon/dev/octcf.c +++ b/sys/arch/octeon/dev/octcf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: octcf.c,v 1.15 2014/07/12 18:44:42 tedu Exp $ */ +/* $OpenBSD: octcf.c,v 1.16 2014/07/12 20:36:45 krw Exp $ */ /* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */ /* @@ -367,13 +367,14 @@ octcfstart(void *arg) void _octcfstart(struct octcf_softc *wd, struct buf *bp) { - uint32_t blkno; - uint32_t nblks; + struct disklabel *lp; + u_int64_t secno; + u_int64_t nsecs; - blkno = bp->b_blkno + - DL_GETPOFFSET(&wd->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)]); - blkno /= (SECTOR_SIZE / DEV_BSIZE); - nblks = bp->b_bcount / SECTOR_SIZE; + lp = wd->sc_dk.dk_label; + secno = DL_BLKTOSEC(lp, bp->b_blkno) + + DL_GETPOFFSET(lp->d_partitions[DISKPART(bp->b_dev)]); + nblks = howmany(bp->b_bcount, lp->d_secsize); wd->sc_bp = bp; @@ -381,9 +382,9 @@ _octcfstart(struct octcf_softc *wd, struct buf *bp) disk_busy(&wd->sc_dk); if (bp->b_flags & B_READ) - bp->b_error = octcf_read_sectors(wd, nblks, blkno, bp->b_data); + bp->b_error = octcf_read_sectors(wd, nsecs, secno, bp->b_data); else - bp->b_error = octcf_write_sectors(wd, nblks, blkno, bp->b_data); + bp->b_error = octcf_write_sectors(wd, nsecs, secno, bp->b_data); octcfdone(wd); }