diff options
author | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2009-06-03 22:09:31 +0000 |
---|---|---|
committer | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2009-06-03 22:09:31 +0000 |
commit | b25274aac4d1fef726702d299f285d361d17febc (patch) | |
tree | bf0a0eecf0269cbaf678c70381c20b040e57ed02 /sys/dev/vnd.c | |
parent | b96794b04ab20a0aba439e48813238555739661d (diff) |
add a flexible buffer queue (bufq) api, based on the never used
one by tedu@. It doesn't do anything smart yet, it just uses
plain old disksort. we also keep the old method of queueing bufs
since some miods have crazy MD drivers that need some love.
ok beck@, art@
tested by many on many archs.
Diffstat (limited to 'sys/dev/vnd.c')
-rw-r--r-- | sys/dev/vnd.c | 28 |
1 files changed, 14 insertions, 14 deletions
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); |