this one is for hd(4) on hp300s. again, i cant compile and therefore cant test.

anyone able to compile this for me? does anyone have such hardware?

On Sun, Nov 03, 2013 at 09:30:56AM +1000, David Gwynne wrote:
> once upon a time pretty much all block storage was on spinning disks, so all 
> the drivers for disks tried to order queued io to better suit moving a head 
> across a platter by calling disksort. between then and now a lot of the 
> assumptions that disksort relied on are no longer true (eg, SSDs are a thing 
> now) so it's usually more harmful than helpful. with beck@s addition of the 
> nscan backend in bufqs it makes sense to try and unify all disk drivers 
> behind bufqs and deprecate disksort.
> 
> so, ive been working through the tree replacing the last direct users of the 
> disksort() over to bufqs, but ive run out of code that i can compile for. 
> there are now 4 drivers in 3 architectures that need conversion, so im asking 
> if anyone is interested in taking some (or all) of them on.
> 
> the code in question is:
> 
> sys/arch/hp300/dev/hd.c
> sys/arch/sparc/dev/fd.c
> sys/arch/sparc/dev/xy.c
> sys/arch/vax/vsa/hdc9224.c
> 
> if anyone has those archs and a some spare time, please feel free to have a 
> go and cut them over. even if you dont have the hardware to test your change, 
> making a compilable diff and sending it to tech@ for testing is better than i 
> can do right now.
> 
> cheers,
> dlg

Index: hd.c
===================================================================
RCS file: /cvs/src/sys/arch/hp300/dev/hd.c,v
retrieving revision 1.73
diff -u -p -r1.73 hd.c
--- hd.c        1 Nov 2013 17:36:19 -0000       1.73
+++ hd.c        19 Nov 2013 05:22:44 -0000
@@ -294,6 +294,7 @@ hdattach(parent, self, aux)
         */
        sc->sc_dkdev.dk_name = sc->sc_dev.dv_xname;
        disk_attach(&sc->sc_dev, &sc->sc_dkdev);
+       bufq_init(&sc->sc_bufq, BUFQ_DEFAULT);
 
        sc->sc_slave = ha->ha_slave;
        sc->sc_punit = ha->ha_punit;
@@ -630,9 +631,9 @@ hdclose(dev, flag, mode, p)
        if (dk->dk_openmask == 0) {
                rs->sc_flags |= HDF_CLOSING;
                s = splbio();
-               while (rs->sc_tab.b_active) {
+               while (rs->sc_bp == NULL) {
                        rs->sc_flags |= HDF_WANTED;
-                       tsleep((caddr_t)&rs->sc_tab, PRIBIO, "hdclose", 0);
+                       tsleep((caddr_t)&rs->sc_bp, PRIBIO, "hdclose", 0);
                }
                splx(s);
                rs->sc_flags &= ~(HDF_CLOSING);
@@ -669,11 +670,11 @@ hdstrategy(bp)
        if (bounds_check_with_label(bp, rs->sc_dkdev.dk_label) == -1)
                goto done;
 
+       bufq_queue(&rs->sc_bufq, bp);
+
        s = splbio();
-       dp = &rs->sc_tab;
-       disksort(dp, bp);
-       if (dp->b_active == 0) {
-               dp->b_active = 1;
+       if (rs->b_bp == NULL) {
+               rs->sc_bp = bufq_dequeue(rs->sc_bufq);
                hdustart(rs);
        }
        splx(s);
@@ -710,7 +711,7 @@ hdustart(rs)
 {
        struct buf *bp;
 
-       bp = rs->sc_tab.b_actf;
+       bp = rs->sc_bp;
        rs->sc_addr = bp->b_data;
        rs->sc_resid = bp->b_bcount;
        if (hpibreq(rs->sc_dev.dv_parent, &rs->sc_hq))
@@ -722,24 +723,23 @@ hdfinish(rs, bp)
        struct hd_softc *rs;
        struct buf *bp;
 {
-       struct buf *dp = &rs->sc_tab;
        int s;
 
        rs->sc_errcnt = 0;
-       dp->b_actf = bp->b_actf;
        bp->b_resid = 0;
        s = splbio();
        biodone(bp);
        splx(s);
+
        hpibfree(rs->sc_dev.dv_parent, &rs->sc_hq);
-       if (dp->b_actf)
-               return (dp->b_actf);
-       dp->b_active = 0;
-       if (rs->sc_flags & HDF_WANTED) {
+       rs->sc_bp = bufq_dequeue(&rs->sc_bufq);
+
+       if (rs->sc_bp == NULL && rs->sc_flags & HDF_WANTED) {
                rs->sc_flags &= ~HDF_WANTED;
-               wakeup((caddr_t)dp);
+               wakeup((caddr_t)&rs->sc_bp);
        }
-       return (NULL);
+
+       return (rs->sc_bp);
 }
 
 void
@@ -748,7 +748,7 @@ hdstart(arg)
 {
        struct hd_softc *rs = arg;
        struct disklabel *lp;
-       struct buf *bp = rs->sc_tab.b_actf;
+       struct buf *bp = rs->sc_bp;
        int ctlr, slave;
        daddr_t bn;
 
@@ -831,7 +831,7 @@ hdgo(arg)
        void *arg;
 {
        struct hd_softc *rs = arg;
-       struct buf *bp = rs->sc_tab.b_actf;
+       struct buf *bp = rs->sc_bp;
        int rw, ctlr, slave;
 
        ctlr = rs->sc_dev.dv_parent->dv_unit;
@@ -855,7 +855,7 @@ hdinterrupt(arg)
 {
        struct hd_softc *rs = arg;
        int unit = rs->sc_dev.dv_unit;
-       struct buf *bp = rs->sc_tab.b_actf;
+       struct buf *bp = rs->sc_bp;
        u_char stat = 13;       /* in case hpibrecv fails */
        int rv, restart, ctlr, slave;
 
@@ -1025,7 +1025,7 @@ hderror(unit)
         * Note that not all errors report a block number, in that case
         * we just use b_blkno.
         */
-       bp = rs->sc_tab.b_actf;
+       bp = rs->sc_bp;
        pbn = 
DL_GETPOFFSET(&rs->sc_dkdev.dk_label->d_partitions[DISKPART(bp->b_dev)]);
        if ((sp->c_fef & FEF_CU) || (sp->c_fef & FEF_DR) ||
            (sp->c_ief & IEF_RRMASK)) {
Index: hdvar.h
===================================================================
RCS file: /cvs/src/sys/arch/hp300/dev/hdvar.h,v
retrieving revision 1.11
diff -u -p -r1.11 hdvar.h
--- hdvar.h     5 Jun 2011 18:40:33 -0000       1.11
+++ hdvar.h     19 Nov 2013 05:22:44 -0000
@@ -70,7 +70,8 @@ struct        hd_softc {
        struct  hd_iocmd sc_ioc;
        struct  hd_rscmd sc_rsc;
        struct  hd_stat sc_stat;
-       struct  buf sc_tab;             /* buffer queue */
+       struct  bufq sc_bufq;           /* buffer queue */
+       struct  buf *sc_bp;
 #ifdef DEBUG
        struct  hdstats sc_stats;
 #endif

Reply via email to