diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ata/wd.c | 18 | ||||
-rw-r--r-- | sys/dev/flash.c | 8 | ||||
-rw-r--r-- | sys/dev/flashvar.h | 3 | ||||
-rw-r--r-- | sys/dev/vnd.c | 28 |
4 files changed, 25 insertions, 32 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index 045f8188f3b..e6d9f45e2f6 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wd.c,v 1.73 2008/11/08 01:32:06 chl Exp $ */ +/* $OpenBSD: wd.c,v 1.74 2009/06/03 22:09:30 thib Exp $ */ /* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */ /* @@ -119,7 +119,7 @@ struct wd_softc { /* General disk infos */ struct device sc_dev; struct disk sc_dk; - struct buf sc_q; + /* IDE disk soft states */ struct ata_bio sc_wdc_bio; /* current transfer */ struct buf *sc_bp; /* buf being transferred */ @@ -396,13 +396,12 @@ int wddetach(struct device *self, int flags) { struct wd_softc *sc = (struct wd_softc *)self; - struct buf *dp, *bp; + struct buf *bp; int s, bmaj, cmaj, mn; /* Remove unprocessed buffers from queue */ s = splbio(); - for (dp = &sc->sc_q; (bp = dp->b_actf) != NULL; ) { - dp->b_actf = bp->b_actf; + while ((bp = BUFQ_GET(sc->sc_dk.dk_bufq)) != NULL) { bp->b_error = ENXIO; bp->b_flags |= B_ERROR; biodone(bp); @@ -475,7 +474,7 @@ wdstrategy(struct buf *bp) goto done; /* Queue transfer on drive, activate drive and controller if idle. */ s = splbio(); - disksort(&wd->sc_q, bp); + BUFQ_ADD(wd->sc_dk.dk_bufq, bp); wdstart(wd); splx(s); device_unref(&wd->sc_dev); @@ -499,18 +498,15 @@ void wdstart(void *arg) { struct wd_softc *wd = arg; - struct buf *dp, *bp = NULL; + struct buf *bp = NULL; WDCDEBUG_PRINT(("wdstart %s\n", wd->sc_dev.dv_xname), DEBUG_XFERS); while (wd->openings > 0) { /* Is there a buf for us ? */ - dp = &wd->sc_q; - if ((bp = dp->b_actf) == NULL) /* yes, an assign */ + if ((bp = BUFQ_GET(wd->sc_dk.dk_bufq)) == NULL) return; - dp->b_actf = bp->b_actf; - /* * Make the command. First lock the device */ diff --git a/sys/dev/flash.c b/sys/dev/flash.c index c6ea5ccb26b..e7918184463 100644 --- a/sys/dev/flash.c +++ b/sys/dev/flash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flash.c,v 1.9 2008/06/15 00:36:41 krw Exp $ */ +/* $OpenBSD: flash.c,v 1.10 2009/06/03 22:09:30 thib Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org> @@ -814,7 +814,7 @@ flashstrategy(struct buf *bp) /* Queue the transfer. */ s = splbio(); - disksort(&sc->sc_q, bp); + BUFQ_ADD(sc->sc_dk.dk_bufq, bp); flashstart(sc); splx(s); device_unref(&sc->sc_dev); @@ -881,11 +881,9 @@ flashstart(struct flash_softc *sc) while (1) { /* Remove the next buffer from the queue or stop. */ - dp = &sc->sc_q; - bp = dp->b_actf; + bp = BUFQ_GET(sc->sc_dk.dk_bufq); if (bp == NULL) return; - dp->b_actf = bp->b_actf; /* Transfer this buffer now. */ _flashstart(sc, bp); diff --git a/sys/dev/flashvar.h b/sys/dev/flashvar.h index 940b3bce320..0be3d979424 100644 --- a/sys/dev/flashvar.h +++ b/sys/dev/flashvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: flashvar.h,v 1.2 2007/06/20 18:15:46 deraadt Exp $ */ +/* $OpenBSD: flashvar.h,v 1.3 2009/06/03 22:09:30 thib Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org> @@ -77,7 +77,6 @@ struct flash_softc { struct device sc_dev; /* Disk device information */ struct disk sc_dk; - struct buf sc_q; struct buf *sc_bp; int sc_flags; /* Flash controller tag */ diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index d1540534f7b..1ac734d5233 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vnd.c,v 1.90 2008/09/03 23:24:25 krw Exp $ */ +/* $OpenBSD: vnd.c,v 1.91 2009/06/03 22:09:30 thib Exp $ */ /* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */ /* @@ -125,6 +125,7 @@ struct pool vndbufpl; struct vnd_softc { struct device sc_dev; struct disk sc_dk; + int sc_active; /* XXX */ char sc_file[VNDNLEN]; /* file we're covering */ int sc_flags; /* flags */ @@ -134,7 +135,6 @@ struct vnd_softc { size_t sc_ntracks; /* # of tracks per cylinder */ struct vnode *sc_vp; /* vnode */ struct ucred *sc_cred; /* credentials */ - struct buf sc_tab; /* transfer queue */ blf_ctx *sc_keyctx; /* key context */ struct rwlock sc_rwlock; }; @@ -499,8 +499,8 @@ vndstrategy(struct buf *bp) biodone(bp); splx(s); - /* If nothing more is queued, we are done. */ - if (!vnd->sc_tab.b_active) + /* If nothing more is queued, we are done. */ + if (!vnd->sc_active) return; /* @@ -508,9 +508,8 @@ vndstrategy(struct buf *bp) * routine might queue using same links. */ s = splbio(); - bp = vnd->sc_tab.b_actf; - vnd->sc_tab.b_actf = bp->b_actf; - vnd->sc_tab.b_active--; + bp = BUFQ_GET(vnd->sc_dk.dk_bufq); + vnd->sc_active--; splx(s); } } @@ -610,8 +609,8 @@ vndstrategy(struct buf *bp) */ nbp->vb_buf.b_cylinder = nbp->vb_buf.b_blkno; s = splbio(); - disksort(&vnd->sc_tab, &nbp->vb_buf); - vnd->sc_tab.b_active++; + BUFQ_ADD(vnd->sc_dk.dk_bufq, &nbp->vb_buf); + vnd->sc_active++; vndstart(vnd); splx(s); bn += sz; @@ -634,8 +633,9 @@ vndstart(struct vnd_softc *vnd) * Dequeue now since lower level strategy routine might * queue using same links */ - bp = vnd->sc_tab.b_actf; - vnd->sc_tab.b_actf = bp->b_actf; + bp = BUFQ_GET(vnd->sc_dk.dk_bufq); + if (bp == NULL) + return; DNPRINTF(VDB_IO, "vndstart(%d): bp %p vp %p blkno %x addr %p cnt %lx\n", @@ -675,11 +675,11 @@ vndiodone(struct buf *bp) } pbp->b_resid -= vbp->vb_buf.b_bcount; putvndbuf(vbp); - if (vnd->sc_tab.b_active) { + if (vnd->sc_active) { disk_unbusy(&vnd->sc_dk, (pbp->b_bcount - pbp->b_resid), (pbp->b_flags & B_READ)); - if (!vnd->sc_tab.b_actf) - vnd->sc_tab.b_active--; + if (BUFQ_PEEK(vnd->sc_dk.dk_bufq) != NULL) + vnd->sc_active--; } if (pbp->b_resid == 0) { DNPRINTF(VDB_IO, "vndiodone: pbp %p iodone\n", pbp); |