diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2010-09-01 01:38:13 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2010-09-01 01:38:13 +0000 |
commit | aa0e77253a76c57fda0220581374a0ced2f4b16e (patch) | |
tree | 87ed4a22e8fd3fbd25acb0fa7d17ddd5ef1bb967 /sys/scsi | |
parent | d51d4c9766720cb9333704e3b7f2ecb8a8a03aa1 (diff) |
make struct bufq a member of the softc for devices that use it,
rather than it being a pointer to something that needs to be allocated
at attach. since all these devices need a bufq to operate, it makes
sense to have it allocated as part of the softc and get bufq_init
to just initialise all its fields. it also gets rid of the possibility
that you wont be able to allocate the bufq struct during attach,
which is something you dont want to happen.
secondly, it consistently implements a split between wrapper functions
and the per discipline implementation of the bufq handlers. it
consistently does the locking in the wrappers rather than doing
half in the wrappers and the other half in the implementations.
it also consistently handles the outstanding bufq bq pointer in the
wrappers.
this hides most of the implementation inside kern_bufq.c. the only
stuff left in buf.h is for the bits each implementation needs to
put inside struct buf.
tested by thib@ krw@ and me
ok thib@ matthew@
no objection from krw@
Diffstat (limited to 'sys/scsi')
-rw-r--r-- | sys/scsi/cd.c | 22 | ||||
-rw-r--r-- | sys/scsi/sd.c | 18 | ||||
-rw-r--r-- | sys/scsi/sdvar.h | 4 | ||||
-rw-r--r-- | sys/scsi/st.c | 22 |
4 files changed, 33 insertions, 33 deletions
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c index adbc211842e..e5fa0b3b650 100644 --- a/sys/scsi/cd.c +++ b/sys/scsi/cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd.c,v 1.184 2010/08/31 16:41:24 deraadt Exp $ */ +/* $OpenBSD: cd.c,v 1.185 2010/09/01 01:38:12 dlg Exp $ */ /* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */ /* @@ -111,7 +111,7 @@ struct cd_softc { u_int32_t blksize; daddr64_t disksize; /* total number sectors */ } sc_params; - struct bufq *sc_bufq; + struct bufq sc_bufq; struct scsi_xshandler sc_xsh; struct timeout sc_timeout; void *sc_cdpwrhook; /* our power hook */ @@ -219,7 +219,7 @@ cdattach(struct device *parent, struct device *self, void *aux) * Initialize disk structures. */ sc->sc_dk.dk_name = sc->sc_dev.dv_xname; - sc->sc_bufq = bufq_init(BUFQ_DEFAULT); + bufq_init(&sc->sc_bufq, BUFQ_DEFAULT); /* * Note if this device is ancient. This is used in cdminphys(). @@ -263,7 +263,7 @@ cdactivate(struct device *self, int act) break; case DVACT_DEACTIVATE: sc->sc_flags |= CDF_DYING; - bufq_drain(sc->sc_bufq); + bufq_drain(&sc->sc_bufq); break; } return (rv); @@ -294,7 +294,7 @@ cddetach(struct device *self, int flags) struct cd_softc *sc = (struct cd_softc *)self; int bmaj, cmaj, mn; - bufq_drain(sc->sc_bufq); + bufq_drain(&sc->sc_bufq); /* Locate the lowest minor number to be detached. */ mn = DISKMINOR(self->dv_unit, 0); @@ -311,7 +311,7 @@ cddetach(struct device *self, int flags) powerhook_disestablish(sc->sc_cdpwrhook); /* Detach disk. */ - bufq_destroy(sc->sc_bufq); + bufq_destroy(&sc->sc_bufq); disk_detach(&sc->sc_dk); return (0); @@ -556,7 +556,7 @@ cdstrategy(struct buf *bp) goto done; /* Place it in the queue of disk activities for this disk. */ - BUFQ_QUEUE(sc->sc_bufq, bp); + bufq_queue(&sc->sc_bufq, bp); /* * Tell the device to get going on the transfer if it's @@ -622,12 +622,12 @@ cdstart(struct scsi_xfer *xs) * re-opened */ if ((sc_link->flags & SDEV_MEDIA_LOADED) == 0) { - bufq_drain(sc->sc_bufq); + bufq_drain(&sc->sc_bufq); scsi_xs_put(xs); return; } - bp = BUFQ_DEQUEUE(sc->sc_bufq); + bp = bufq_dequeue(&sc->sc_bufq); if (bp == NULL) { scsi_xs_put(xs); return; @@ -691,7 +691,7 @@ cdstart(struct scsi_xfer *xs) if (ISSET(sc->sc_flags, CDF_WAITING)) CLR(sc->sc_flags, CDF_WAITING); - else if (BUFQ_PEEK(sc->sc_bufq)) + else if (bufq_peek(&sc->sc_bufq)) scsi_xsh_add(&sc->sc_xsh); } @@ -712,7 +712,7 @@ cd_buf_done(struct scsi_xfer *xs) /* The adapter is busy, requeue the buf and try it later. */ disk_unbusy(&sc->sc_dk, bp->b_bcount - xs->resid, bp->b_flags & B_READ); - BUFQ_REQUEUE(sc->sc_bufq, bp); + bufq_requeue(&sc->sc_bufq, bp); scsi_xs_put(xs); SET(sc->sc_flags, CDF_WAITING); timeout_add(&sc->sc_timeout, 1); diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 8ca02b80fd4..fe2815bebce 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.207 2010/08/31 16:34:38 deraadt Exp $ */ +/* $OpenBSD: sd.c,v 1.208 2010/09/01 01:38:12 dlg Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -172,7 +172,7 @@ sdattach(struct device *parent, struct device *self, void *aux) * Initialize disk structures. */ sc->sc_dk.dk_name = sc->sc_dev.dv_xname; - sc->sc_bufq = bufq_init(BUFQ_DEFAULT); + bufq_init(&sc->sc_bufq, BUFQ_DEFAULT); if ((sc_link->flags & SDEV_ATAPI) && (sc_link->flags & SDEV_REMOVABLE)) sc_link->quirks |= SDEV_NOSYNCCACHE; @@ -302,7 +302,7 @@ sddetach(struct device *self, int flags) struct sd_softc *sc = (struct sd_softc *)self; int bmaj, cmaj, mn; - bufq_drain(sc->sc_bufq); + bufq_drain(&sc->sc_bufq); /* Locate the lowest minor number to be detached. */ mn = DISKMINOR(self->dv_unit, 0); @@ -319,7 +319,7 @@ sddetach(struct device *self, int flags) shutdownhook_disestablish(sc->sc_sdhook); /* Detach disk. */ - bufq_destroy(sc->sc_bufq); + bufq_destroy(&sc->sc_bufq); disk_detach(&sc->sc_dk); return (0); @@ -574,7 +574,7 @@ sdstrategy(struct buf *bp) goto done; /* Place it in the queue of disk activities for this disk. */ - BUFQ_QUEUE(sc->sc_bufq, bp); + bufq_queue(&sc->sc_bufq, bp); /* * Tell the device to get going on the transfer if it's @@ -676,12 +676,12 @@ sdstart(struct scsi_xfer *xs) return; } if ((link->flags & SDEV_MEDIA_LOADED) == 0) { - bufq_drain(sc->sc_bufq); + bufq_drain(&sc->sc_bufq); scsi_xs_put(xs); return; } - bp = BUFQ_DEQUEUE(sc->sc_bufq); + bp = bufq_dequeue(&sc->sc_bufq); if (bp == NULL) { scsi_xs_put(xs); return; @@ -732,7 +732,7 @@ sdstart(struct scsi_xfer *xs) /* move onto the next io */ if (ISSET(sc->flags, SDF_WAITING)) CLR(sc->flags, SDF_WAITING); - else if (BUFQ_PEEK(sc->sc_bufq) != NULL) + else if (bufq_peek(&sc->sc_bufq) != NULL) scsi_xsh_add(&sc->sc_xsh); } @@ -753,7 +753,7 @@ sd_buf_done(struct scsi_xfer *xs) /* The adapter is busy, requeue the buf and try it later. */ disk_unbusy(&sc->sc_dk, bp->b_bcount - xs->resid, bp->b_flags & B_READ); - BUFQ_REQUEUE(sc->sc_bufq, bp); + bufq_requeue(&sc->sc_bufq, bp); scsi_xs_put(xs); SET(sc->flags, SDF_WAITING); timeout_add(&sc->sc_timeout, 1); diff --git a/sys/scsi/sdvar.h b/sys/scsi/sdvar.h index d5debe6a498..0a158b4c382 100644 --- a/sys/scsi/sdvar.h +++ b/sys/scsi/sdvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sdvar.h,v 1.31 2010/06/02 13:32:13 dlg Exp $ */ +/* $OpenBSD: sdvar.h,v 1.32 2010/09/01 01:38:12 dlg Exp $ */ /* $NetBSD: sdvar.h,v 1.7 1998/08/17 00:49:03 mycroft Exp $ */ /*- @@ -51,7 +51,7 @@ struct sd_softc { struct device sc_dev; struct disk sc_dk; - struct bufq *sc_bufq; + struct bufq sc_bufq; int flags; #define SDF_LOCKED 0x01 diff --git a/sys/scsi/st.c b/sys/scsi/st.c index 5ce3c057a0e..56556e69fb9 100644 --- a/sys/scsi/st.c +++ b/sys/scsi/st.c @@ -1,4 +1,4 @@ -/* $OpenBSD: st.c,v 1.107 2010/08/30 02:47:56 matthew Exp $ */ +/* $OpenBSD: st.c,v 1.108 2010/09/01 01:38:12 dlg Exp $ */ /* $NetBSD: st.c,v 1.71 1997/02/21 23:03:49 thorpej Exp $ */ /* @@ -215,7 +215,7 @@ struct st_softc { #define BLKSIZE_SET_BY_USER 0x04 #define BLKSIZE_SET_BY_QUIRK 0x08 - struct bufq *sc_bufq; + struct bufq sc_bufq; struct timeout sc_timeout; struct scsi_xshandler sc_xsh; }; @@ -331,7 +331,7 @@ stattach(struct device *parent, struct device *self, void *aux) &st->sc_xsh); /* Set up the buf queue for this device. */ - st->sc_bufq = bufq_init(BUFQ_FIFO); + bufq_init(&st->sc_bufq, BUFQ_FIFO); /* Start up with media position unknown. */ st->media_fileno = -1; @@ -357,7 +357,7 @@ stactivate(struct device *self, int act) case DVACT_DEACTIVATE: st->flags |= ST_DYING; - bufq_drain(st->sc_bufq); + bufq_drain(&st->sc_bufq); break; } @@ -370,7 +370,7 @@ stdetach(struct device *self, int flags) struct st_softc *st = (struct st_softc *)self; int bmaj, cmaj, mn; - bufq_drain(st->sc_bufq); + bufq_drain(&st->sc_bufq); /* Locate the lowest minor number to be detached. */ mn = STUNIT(self->dv_unit); @@ -390,7 +390,7 @@ stdetach(struct device *self, int flags) vdevgone(cmaj, mn, mn + 3, VCHR); } - bufq_destroy(st->sc_bufq); + bufq_destroy(&st->sc_bufq); return (0); } @@ -877,7 +877,7 @@ ststrategy(struct buf *bp) * at the end (a bit silly because we only have on user.. * (but it could fork())) */ - BUFQ_QUEUE(st->sc_bufq, bp); + bufq_queue(&st->sc_bufq, bp); /* * Tell the device to get going on the transfer if it's @@ -922,13 +922,13 @@ ststart(struct scsi_xfer *xs) !(sc_link->flags & SDEV_MEDIA_LOADED)) { /* make sure that one implies the other.. */ sc_link->flags &= ~SDEV_MEDIA_LOADED; - bufq_drain(st->sc_bufq); + bufq_drain(&st->sc_bufq); scsi_xs_put(xs); return; } for (;;) { - bp = BUFQ_DEQUEUE(st->sc_bufq); + bp = bufq_dequeue(&st->sc_bufq); if (bp == NULL) { scsi_xs_put(xs); return; @@ -1041,7 +1041,7 @@ ststart(struct scsi_xfer *xs) */ if (ISSET(st->flags, ST_WAITING)) CLR(st->flags, ST_WAITING); - else if (BUFQ_PEEK(st->sc_bufq)) + else if (bufq_peek(&st->sc_bufq)) scsi_xsh_add(&st->sc_xsh); } @@ -1060,7 +1060,7 @@ st_buf_done(struct scsi_xfer *xs) case XS_NO_CCB: /* The adapter is busy, requeue the buf and try it later. */ - BUFQ_REQUEUE(st->sc_bufq, bp); + bufq_requeue(&st->sc_bufq, bp); scsi_xs_put(xs); SET(st->flags, ST_WAITING); /* dont let ststart xsh_add */ timeout_add(&st->sc_timeout, 1); |