diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2007-06-20 20:13:42 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2007-06-20 20:13:42 +0000 |
commit | 4f93eac49ec225f6770beaef42c320c99a8b1619 (patch) | |
tree | 56dcbd8fb95fe16f77aeebbdc4ef15bb28721b31 /sys/arch | |
parent | 6766d4ec05d843d13b7654d87957286ec0d69aeb (diff) |
These drivers were abusing b_cylinder to store device-specific information
in strategy(), and were reusing it in start().
I first considered introducing a b_rawblkno field in struct buf, as has been
done in NetBSD, to stop this abuse.
However, it does not cost more to simply move the device-specific
``was-b_cylinder'' computation to the start() routine. Plus we get type fixes
(daddr64_t) for free, although this does not really matter for these
pedro-sized devices. Thus we do not need to grow struct buf for these
devices which really ought to live in your Attic (and my machineroom, of
course).
hp300 HP-IB tested, vax mfm not, but the logic is the same.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/hp300/dev/hd.c | 40 | ||||
-rw-r--r-- | sys/arch/vax/vsa/hdc9224.c | 33 |
2 files changed, 29 insertions, 44 deletions
diff --git a/sys/arch/hp300/dev/hd.c b/sys/arch/hp300/dev/hd.c index 63b8e1bdf0c..3a2b218bf01 100644 --- a/sys/arch/hp300/dev/hd.c +++ b/sys/arch/hp300/dev/hd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hd.c,v 1.51 2007/06/20 18:15:47 deraadt Exp $ */ +/* $OpenBSD: hd.c,v 1.52 2007/06/20 20:13:40 miod Exp $ */ /* $NetBSD: rd.c,v 1.33 1997/07/10 18:14:08 kleink Exp $ */ /* @@ -654,8 +654,8 @@ hdstrategy(bp) int unit = DISKUNIT(bp->b_dev); struct hd_softc *rs; struct buf *dp; + struct disklabel *lp; int s; - struct partition *pinfo; rs = hdlookup(unit); if (rs == NULL) { @@ -670,6 +670,8 @@ hdstrategy(bp) (bp->b_flags & B_READ) ? 'R' : 'W'); #endif + lp = rs->sc_dkdev.dk_label; + /* * If it's a null transfer, return immediately */ @@ -679,7 +681,7 @@ hdstrategy(bp) /* * The transfer must be a whole number of blocks. */ - if ((bp->b_bcount % rs->sc_dkdev.dk_label->d_secsize) != 0) { + if ((bp->b_bcount % lp->d_secsize) != 0) { bp->b_error = EINVAL; goto bad; } @@ -688,27 +690,12 @@ hdstrategy(bp) * Do bounds checking, adjust transfer. if error, process; * If end of partition, just return. */ - - dp = &rs->sc_tab; - - if (DISKPART(bp->b_dev) == RAW_PART) { - /* valid regardless of the disklabel */ - bp->b_cylinder = bp->b_blkno; - } else { - if (bounds_check_with_label(bp, rs->sc_dkdev.dk_label, - (rs->sc_flags & HDF_WLABEL) != 0) <= 0) + if (bounds_check_with_label(bp, lp, + (rs->sc_flags & HDF_WLABEL) != 0) <= 0) goto done; - /* - * XXX Note that since b_cylinder is stored over b_resid, this - * XXX destroys the disksort ordering hint - * XXX bounds_check_with_label() has put in there. - */ - pinfo = &rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)]; - bp->b_cylinder = bp->b_blkno + DL_GETPOFFSET(pinfo); - } - s = splbio(); + dp = &rs->sc_tab; disksort(dp, bp); if (dp->b_active == 0) { dp->b_active = 1; @@ -787,8 +774,10 @@ hdstart(arg) void *arg; { struct hd_softc *rs = arg; + struct disklabel *lp; struct buf *bp = rs->sc_tab.b_actf; - int part, ctlr, slave; + int ctlr, slave; + daddr64_t bn; ctlr = rs->sc_dev.dv_parent->dv_unit; slave = rs->sc_slave; @@ -799,13 +788,16 @@ again: printf("hdstart(%s): bp %p, %c\n", rs->sc_dev.dv_xname, bp, (bp->b_flags & B_READ) ? 'R' : 'W'); #endif - part = DISKPART(bp->b_dev); + lp = rs->sc_dkdev.dk_label; + bn = bp->b_blkno + + DL_GETPOFFSET(&lp->d_partitions[DISKPART(bp->b_dev)]); + rs->sc_flags |= HDF_SEEK; rs->sc_ioc.c_unit = C_SUNIT(rs->sc_punit); rs->sc_ioc.c_volume = C_SVOL(0); rs->sc_ioc.c_saddr = C_SADDR; rs->sc_ioc.c_hiaddr = 0; - rs->sc_ioc.c_addr = HDBTOS(bp->b_cylinder); + rs->sc_ioc.c_addr = HDBTOS(bn); rs->sc_ioc.c_nop2 = C_NOP; rs->sc_ioc.c_slen = C_SLEN; rs->sc_ioc.c_len = rs->sc_resid; diff --git a/sys/arch/vax/vsa/hdc9224.c b/sys/arch/vax/vsa/hdc9224.c index 5c4cdbb30b6..be10546fb14 100644 --- a/sys/arch/vax/vsa/hdc9224.c +++ b/sys/arch/vax/vsa/hdc9224.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hdc9224.c,v 1.20 2007/06/20 18:15:46 deraadt Exp $ */ +/* $OpenBSD: hdc9224.c,v 1.21 2007/06/20 20:13:41 miod Exp $ */ /* $NetBSD: hdc9224.c,v 1.16 2001/07/26 15:05:09 wiz Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. @@ -142,7 +142,7 @@ struct hdcsoftc { caddr_t sc_dmabase; /* */ int sc_dmasize; caddr_t sc_bufaddr; /* Current in-core address */ - int sc_diskblk; /* Current block on disk */ + daddr64_t sc_diskblk; /* Current block on disk */ int sc_bytecnt; /* How much left to transfer */ int sc_xfer; /* Current transfer size */ int sc_retries; @@ -438,7 +438,6 @@ hdstrategy(struct buf *bp) struct hdcsoftc *sc; struct disklabel *lp; int unit, s; - daddr64_t bn; unit = DISKUNIT(bp->b_dev); if (unit > hd_cd.cd_ndevs || (hd = hd_cd.cd_devs[unit]) == NULL) { @@ -455,17 +454,6 @@ hdstrategy(struct buf *bp) if (bp->b_bcount == 0) goto done; - /* - * XXX Since we need to know blkno in hdcstart() and do not have a - * b_rawblkno field in struct buf (yet), abuse b_cylinder to store - * the block number instead of the cylinder number. - * This will be suboptimal in disksort(), but not harmful. Of course, - * this also truncates the block number at 4G, but there shouldn't be - * any MFM disk that large. - */ - bn = bp->b_blkno + DL_GETPOFFSET(&lp->d_partitions[DISKPART(bp->b_dev)]); - bp->b_cylinder = bn; - s = splbio(); disksort(&sc->sc_buf_queue, bp); if (inq == 0) { @@ -504,22 +492,22 @@ hdcstart(struct hdcsoftc *sc, struct buf *ob) struct disklabel *lp; struct hdsoftc *hd; struct buf *dp, *bp; - int cn, sn, tn, bn, blks; + int cn, sn, tn, blks; volatile char ch; + daddr64_t bn; splassert(IPL_BIO); if (sc->sc_active) return; /* Already doing something */ - if (ob == 0) { + if (ob == NULL) { dp = &sc->sc_buf_queue; if ((bp = dp->b_actf) == NULL) return; /* Nothing to do */ + dp->b_actf = bp->b_actf; sc->sc_bufaddr = bp->b_data; - /* XXX see hdstrategy() comments regarding b_cylinder usage */ - sc->sc_diskblk = bp->b_cylinder; sc->sc_bytecnt = bp->b_bcount; sc->sc_retries = 0; bp->b_resid = 0; @@ -527,12 +515,17 @@ hdcstart(struct hdcsoftc *sc, struct buf *ob) bp = ob; hd = hd_cd.cd_devs[DISKUNIT(bp->b_dev)]; + lp = hd->sc_disk.dk_label; hdc_hdselect(sc, hd->sc_drive); sc->sc_active = bp; + if (ob == NULL) { + sc->sc_diskblk = bp->b_blkno + + DL_GETPOFFSET(&lp->d_partitions[DISKPART(bp->b_dev)]); + } bn = sc->sc_diskblk; - lp = hd->sc_disk.dk_label; - if (bn) { + + if (bn != 0) { cn = bn / lp->d_secpercyl; sn = bn % lp->d_secpercyl; tn = sn / lp->d_nsectors; |