summaryrefslogtreecommitdiff
path: root/sys/scsi
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2010-05-26 16:38:21 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2010-05-26 16:38:21 +0000
commit0f31cd36b18a4e846125940b5fbdb71a8d33b5aa (patch)
treee95c5d0e6ff6ae1795cbaffa819d82d37ba2821d /sys/scsi
parentbea6c9716c22aab90347c534b30293dfbe0f186c (diff)
Trying this again. Mixing anoncvs with cvs is _not_ a good idea.
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/scsi')
-rw-r--r--sys/scsi/sd.c27
-rw-r--r--sys/scsi/sdvar.h5
2 files changed, 14 insertions, 18 deletions
diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c
index d2f67671eb1..d2bc296b27e 100644
--- a/sys/scsi/sd.c
+++ b/sys/scsi/sd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sd.c,v 1.190 2010/05/20 00:04:38 krw Exp $ */
+/* $OpenBSD: sd.c,v 1.191 2010/05/26 16:38:20 thib Exp $ */
/* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */
/*-
@@ -55,6 +55,7 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/mtio.h>
+#include <sys/mutex.h>
#include <sys/buf.h>
#include <sys/uio.h>
#include <sys/malloc.h>
@@ -168,8 +169,6 @@ sdattach(struct device *parent, struct device *self, void *aux)
SC_DEBUG(sc_link, SDEV_DB2, ("sdattach:\n"));
- mtx_init(&sc->sc_buf_mtx, IPL_BIO);
-
/*
* Store information needed to contact our base driver
*/
@@ -182,6 +181,7 @@ sdattach(struct device *parent, struct device *self, void *aux)
*/
sc->sc_dk.dk_driver = &sddkdriver;
sc->sc_dk.dk_name = sc->sc_dev.dv_xname;
+ sc->sc_bufq = bufq_init(BUFQ_DEFAULT);
disk_attach(&sc->sc_dk);
if ((sc_link->flags & SDEV_ATAPI) && (sc_link->flags & SDEV_REMOVABLE))
@@ -277,7 +277,7 @@ sdactivate(struct device *self, int act)
case DVACT_DEACTIVATE:
sc->flags |= SDF_DYING;
- scsi_buf_killqueue(&sc->sc_buf_queue, &sc->sc_buf_mtx);
+ bufq_drain(sc->sc_bufq);
break;
}
@@ -291,7 +291,7 @@ sddetach(struct device *self, int flags)
struct sd_softc *sc = (struct sd_softc *)self;
int bmaj, cmaj, mn;
- scsi_buf_killqueue(&sc->sc_buf_queue, &sc->sc_buf_mtx);
+ bufq_drain(sc->sc_bufq);
/* Locate the lowest minor number to be detached. */
mn = DISKMINOR(self->dv_unit, 0);
@@ -308,6 +308,7 @@ sddetach(struct device *self, int flags)
shutdownhook_disestablish(sc->sc_sdhook);
/* Detach disk. */
+ bufq_destroy(sc->sc_bufq);
disk_detach(&sc->sc_dk);
return (0);
@@ -561,12 +562,8 @@ sdstrategy(struct buf *bp)
(sc->flags & (SDF_WLABEL|SDF_LABELLING)) != 0) <= 0)
goto done;
- /*
- * Place it in the queue of disk activities for this disk
- */
- mtx_enter(&sc->sc_buf_mtx);
- disksort(&sc->sc_buf_queue, bp);
- mtx_leave(&sc->sc_buf_mtx);
+ /* Place it in the queue of disk activities for this disk. */
+ BUFQ_QUEUE(sc->sc_bufq, bp);
/*
* Tell the device to get going on the transfer if it's
@@ -668,12 +665,12 @@ sdstart(struct scsi_xfer *xs)
return;
}
if ((link->flags & SDEV_MEDIA_LOADED) == 0) {
- scsi_buf_killqueue(&sc->sc_buf_queue, &sc->sc_buf_mtx);
+ bufq_drain(sc->sc_bufq);
scsi_xs_put(xs);
return;
}
- bp = scsi_buf_dequeue(&sc->sc_buf_queue, &sc->sc_buf_mtx);
+ bp = BUFQ_DEQUEUE(sc->sc_bufq);
if (bp == NULL) {
scsi_xs_put(xs);
return;
@@ -721,7 +718,7 @@ sdstart(struct scsi_xfer *xs)
scsi_xs_exec(xs);
/* move onto the next io */
- if (scsi_buf_canqueue(&sc->sc_buf_queue, &sc->sc_buf_mtx))
+ if (BUFQ_PEEK(sc->sc_bufq) != NULL)
scsi_xsh_add(&sc->sc_xsh);
}
@@ -742,7 +739,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);
- scsi_buf_requeue(&sc->sc_buf_queue, bp, &sc->sc_buf_mtx);
+ BUFQ_REQUEUE(sc->sc_bufq, bp);
scsi_xs_put(xs);
timeout_add(&sc->sc_timeout, 1);
return;
diff --git a/sys/scsi/sdvar.h b/sys/scsi/sdvar.h
index 4fdefa1d725..396b1cd1da9 100644
--- a/sys/scsi/sdvar.h
+++ b/sys/scsi/sdvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdvar.h,v 1.29 2010/05/19 05:50:50 dlg Exp $ */
+/* $OpenBSD: sdvar.h,v 1.30 2010/05/26 16:38:20 thib Exp $ */
/* $NetBSD: sdvar.h,v 1.7 1998/08/17 00:49:03 mycroft Exp $ */
/*-
@@ -51,6 +51,7 @@
struct sd_softc {
struct device sc_dev;
struct disk sc_dk;
+ struct bufq *sc_bufq;
int flags;
#define SDF_LOCKED 0x01
@@ -69,8 +70,6 @@ struct sd_softc {
u_long rot_rate; /* rotational rate, in RPM */
daddr64_t disksize; /* total number sectors */
} params;
- struct mutex sc_buf_mtx;
- struct buf sc_buf_queue;
void *sc_sdhook; /* our shutdown hook */
struct timeout sc_timeout;