summaryrefslogtreecommitdiff
path: root/sys/dev/ata/wd.c
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2010-05-26 16:16:24 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2010-05-26 16:16:24 +0000
commit1d9656180642de37498a80ae37bf919e0be788a5 (patch)
treee86b42e6c53ea72d2b1ec755aa574618b5d57c35 /sys/dev/ata/wd.c
parentd821b774f6c04139b001bdd61bbbe71e0bda2052 (diff)
Reintroduce bufqs. A few changes since it was backed out after some good
comments from dlg@. No need for a separate bufq.h, keep all of in buf.h; As requested by kittens and deraadt. Only sd(4) and wd(4) for now. The rest of the drivers will be converted soon, also other goodies like heuristics for sd(4) for selecting the bufq type and the death of disksort() are forthcoming. Tested on: i386, amd64, sparc64, macppc, loongson and alpha by myself and phessler. OK art@, beck@, kettenis@, oga@
Diffstat (limited to 'sys/dev/ata/wd.c')
-rw-r--r--sys/dev/ata/wd.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c
index 545236089f1..6b172b1a0e3 100644
--- a/sys/dev/ata/wd.c
+++ b/sys/dev/ata/wd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wd.c,v 1.82 2010/05/24 11:18:50 kettenis Exp $ */
+/* $OpenBSD: wd.c,v 1.83 2010/05/26 16:16:23 thib Exp $ */
/* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */
/*
@@ -70,6 +70,7 @@
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
+#include <sys/mutex.h>
#include <sys/buf.h>
#include <sys/uio.h>
#include <sys/malloc.h>
@@ -120,7 +121,8 @@ struct wd_softc {
/* General disk infos */
struct device sc_dev;
struct disk sc_dk;
- struct buf sc_q;
+ struct bufq *sc_bufq;
+
/* IDE disk soft states */
struct ata_bio sc_wdc_bio; /* current transfer */
struct buf *sc_bp; /* buf being transferred */
@@ -367,6 +369,7 @@ wdattach(struct device *parent, struct device *self, void *aux)
*/
wd->sc_dk.dk_driver = &wddkdriver;
wd->sc_dk.dk_name = wd->sc_dev.dv_xname;
+ wd->sc_bufq = bufq_init(BUFQ_DEFAULT);
disk_attach(&wd->sc_dk);
wd->sc_wdc_bio.lp = wd->sc_dk.dk_label;
wd->sc_sdhook = shutdownhook_establish(wd_shutdown, wd);
@@ -403,13 +406,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_DEQUEUE(sc->sc_bufq)) != NULL) {
bp->b_error = ENXIO;
bp->b_flags |= B_ERROR;
biodone(bp);
@@ -431,6 +433,7 @@ wddetach(struct device *self, int flags)
shutdownhook_disestablish(sc->sc_sdhook);
/* Detach disk. */
+ bufq_destroy(sc->sc_bufq);
disk_detach(&sc->sc_dk);
return (0);
@@ -481,8 +484,8 @@ wdstrategy(struct buf *bp)
(wd->sc_flags & (WDF_WLABEL|WDF_LABELLING)) != 0) <= 0)
goto done;
/* Queue transfer on drive, activate drive and controller if idle. */
+ BUFQ_QUEUE(wd->sc_bufq, bp);
s = splbio();
- disksort(&wd->sc_q, bp);
wdstart(wd);
splx(s);
device_unref(&wd->sc_dev);
@@ -506,18 +509,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_DEQUEUE(wd->sc_bufq)) == NULL)
return;
- dp->b_actf = bp->b_actf;
-
/*
* Make the command. First lock the device
*/