diff options
author | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2009-06-17 01:30:33 +0000 |
---|---|---|
committer | Thordur I. Bjornsson <thib@cvs.openbsd.org> | 2009-06-17 01:30:33 +0000 |
commit | 3ee68d23a3466d2029ffb173fb427cbe52bf1c22 (patch) | |
tree | 9836d4f2fe25decc84e3ffcba4a9c31e9b946d7c /sys | |
parent | c51365090d32d88879756762d7720c7761a80060 (diff) |
Revert bufq's. this is inline with the major midlayer reverts that
have been going on. this appears to bring us back to stable state.
lots of testing by oga and ariane and my self.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/conf/files | 3 | ||||
-rw-r--r-- | sys/ddb/db_command.c | 17 | ||||
-rw-r--r-- | sys/ddb/db_command.h | 3 | ||||
-rw-r--r-- | sys/ddb/db_interface.h | 6 | ||||
-rw-r--r-- | sys/dev/ata/wd.c | 18 | ||||
-rw-r--r-- | sys/dev/flash.c | 10 | ||||
-rw-r--r-- | sys/dev/flashvar.h | 3 | ||||
-rw-r--r-- | sys/dev/vnd.c | 28 | ||||
-rw-r--r-- | sys/kern/kern_bufq.c | 154 | ||||
-rw-r--r-- | sys/kern/subr_disk.c | 11 | ||||
-rw-r--r-- | sys/scsi/cd.c | 40 | ||||
-rw-r--r-- | sys/scsi/cd.h | 3 | ||||
-rw-r--r-- | sys/scsi/sd.c | 40 | ||||
-rw-r--r-- | sys/scsi/sdvar.h | 3 | ||||
-rw-r--r-- | sys/sys/buf.h | 24 | ||||
-rw-r--r-- | sys/sys/disk.h | 4 |
16 files changed, 111 insertions, 256 deletions
diff --git a/sys/conf/files b/sys/conf/files index 84d1f578eb8..28e45437fd7 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.466 2009/06/16 16:42:41 ariane Exp $ +# $OpenBSD: files,v 1.467 2009/06/17 01:30:30 thib Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -656,7 +656,6 @@ file kern/exec_subr.c file kern/init_main.c file kern/init_sysent.c file kern/kern_acct.c accounting -file kern/kern_bufq.c file kern/kern_clock.c file kern/kern_descrip.c file kern/kern_event.c diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index e814d5c39e9..de2eff827c3 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.c,v 1.52 2009/06/03 22:09:30 thib Exp $ */ +/* $OpenBSD: db_command.c,v 1.53 2009/06/17 01:30:30 thib Exp $ */ /* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */ /* @@ -39,7 +39,6 @@ #include <sys/msgbuf.h> #include <sys/malloc.h> #include <sys/mount.h> -#include <sys/buf.h> #include <uvm/uvm_extern.h> #include <machine/db_machdep.h> /* type definitions */ @@ -297,19 +296,6 @@ db_buf_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) /*ARGSUSED*/ void -db_bufq_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) -{ - boolean_t full = FALSE; - - if (modif[0] == 'f') - full = TRUE; - - db_bufq_print((struct bufq *) addr, full, db_printf); -} - - -/*ARGSUSED*/ -void db_map_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { boolean_t full = FALSE; @@ -472,7 +458,6 @@ struct db_command db_show_cmds[] = { { "all", NULL, 0, db_show_all_cmds }, { "breaks", db_listbreak_cmd, 0, NULL }, { "buf", db_buf_print_cmd, 0, NULL }, - { "bufq", db_bufq_print_cmd, 0, NULL }, { "extents", db_extent_print_cmd, 0, NULL }, { "malloc", db_malloc_print_cmd, 0, NULL }, { "map", db_map_print_cmd, 0, NULL }, diff --git a/sys/ddb/db_command.h b/sys/ddb/db_command.h index af92b6a6cbd..867a05d703c 100644 --- a/sys/ddb/db_command.h +++ b/sys/ddb/db_command.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.h,v 1.23 2009/06/03 22:09:30 thib Exp $ */ +/* $OpenBSD: db_command.h,v 1.24 2009/06/17 01:30:30 thib Exp $ */ /* $NetBSD: db_command.h,v 1.8 1996/02/05 01:56:55 christos Exp $ */ /* @@ -39,7 +39,6 @@ int db_cmd_search(char *, struct db_command *, struct db_command **); void db_cmd_list(struct db_command *); void db_command(struct db_command **, struct db_command *); void db_buf_print_cmd(db_expr_t, int, db_expr_t, char *); -void db_bufq_print_cmd(db_expr_t, int, db_expr_t, char *); void db_map_print_cmd(db_expr_t, int, db_expr_t, char *); void db_malloc_print_cmd(db_expr_t, int, db_expr_t, char *); void db_mount_print_cmd(db_expr_t, int, db_expr_t, char *); diff --git a/sys/ddb/db_interface.h b/sys/ddb/db_interface.h index 90b19086b8f..e15ef4bbcdd 100644 --- a/sys/ddb/db_interface.h +++ b/sys/ddb/db_interface.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.h,v 1.11 2009/06/03 22:09:30 thib Exp $ */ +/* $OpenBSD: db_interface.h,v 1.12 2009/06/17 01:30:30 thib Exp $ */ /* $NetBSD: db_interface.h,v 1.1 1996/02/05 01:57:03 christos Exp $ */ /* @@ -61,10 +61,6 @@ struct nfsreq; void db_show_all_nfsreqs(db_expr_t, int, db_expr_t, char *); void db_nfsreq_print(struct nfsreq *, int, int (*)(const char *, ...)); -/* kern/kern_bufq.c */ -struct bufq; -void db_bufq_print(struct bufq *, int, int (*)(const char *, ...)); - /* ufs/ffs/ffs_softdep.c */ struct worklist; void worklist_print(struct worklist *, int, int (*)(const char *, ...)); diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index e6d9f45e2f6..b70a68ba61e 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wd.c,v 1.74 2009/06/03 22:09:30 thib Exp $ */ +/* $OpenBSD: wd.c,v 1.75 2009/06/17 01:30: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,12 +396,13 @@ int wddetach(struct device *self, int flags) { struct wd_softc *sc = (struct wd_softc *)self; - struct buf *bp; + struct buf *dp, *bp; int s, bmaj, cmaj, mn; /* Remove unprocessed buffers from queue */ s = splbio(); - while ((bp = BUFQ_GET(sc->sc_dk.dk_bufq)) != NULL) { + for (dp = &sc->sc_q; (bp = dp->b_actf) != NULL; ) { + dp->b_actf = bp->b_actf; bp->b_error = ENXIO; bp->b_flags |= B_ERROR; biodone(bp); @@ -474,7 +475,7 @@ wdstrategy(struct buf *bp) goto done; /* Queue transfer on drive, activate drive and controller if idle. */ s = splbio(); - BUFQ_ADD(wd->sc_dk.dk_bufq, bp); + disksort(&wd->sc_q, bp); wdstart(wd); splx(s); device_unref(&wd->sc_dev); @@ -498,15 +499,18 @@ void wdstart(void *arg) { struct wd_softc *wd = arg; - struct buf *bp = NULL; + struct buf *dp, *bp = NULL; WDCDEBUG_PRINT(("wdstart %s\n", wd->sc_dev.dv_xname), DEBUG_XFERS); while (wd->openings > 0) { /* Is there a buf for us ? */ - if ((bp = BUFQ_GET(wd->sc_dk.dk_bufq)) == NULL) + dp = &wd->sc_q; + if ((bp = dp->b_actf) == NULL) /* yes, an assign */ 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 ea87e89ce61..3e04aa4a268 100644 --- a/sys/dev/flash.c +++ b/sys/dev/flash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flash.c,v 1.11 2009/06/04 23:13:21 deraadt Exp $ */ +/* $OpenBSD: flash.c,v 1.12 2009/06/17 01:30:30 thib Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org> @@ -814,7 +814,7 @@ flashstrategy(struct buf *bp) /* Queue the transfer. */ s = splbio(); - BUFQ_ADD(sc->sc_dk.dk_bufq, bp); + disksort(&sc->sc_q, bp); flashstart(sc); splx(s); device_unref(&sc->sc_dev); @@ -877,13 +877,15 @@ flashsize(dev_t dev) void flashstart(struct flash_softc *sc) { - struct buf *bp; + struct buf *dp, *bp; while (1) { /* Remove the next buffer from the queue or stop. */ - bp = BUFQ_GET(sc->sc_dk.dk_bufq); + dp = &sc->sc_q; + bp = dp->b_actf; 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 0be3d979424..d6b150b4393 100644 --- a/sys/dev/flashvar.h +++ b/sys/dev/flashvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: flashvar.h,v 1.3 2009/06/03 22:09:30 thib Exp $ */ +/* $OpenBSD: flashvar.h,v 1.4 2009/06/17 01:30:30 thib Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org> @@ -77,6 +77,7 @@ 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 8cbda77ef91..43c78122563 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vnd.c,v 1.92 2009/06/04 05:57:27 krw Exp $ */ +/* $OpenBSD: vnd.c,v 1.93 2009/06/17 01:30:30 thib Exp $ */ /* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */ /* @@ -125,7 +125,6 @@ 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 */ @@ -135,6 +134,7 @@ 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_active) + /* If nothing more is queued, we are done. */ + if (!vnd->sc_tab.b_active) return; /* @@ -508,8 +508,9 @@ vndstrategy(struct buf *bp) * routine might queue using same links. */ s = splbio(); - bp = BUFQ_GET(vnd->sc_dk.dk_bufq); - vnd->sc_active--; + bp = vnd->sc_tab.b_actf; + vnd->sc_tab.b_actf = bp->b_actf; + vnd->sc_tab.b_active--; splx(s); } } @@ -609,8 +610,8 @@ vndstrategy(struct buf *bp) */ nbp->vb_buf.b_cylinder = nbp->vb_buf.b_blkno; s = splbio(); - BUFQ_ADD(vnd->sc_dk.dk_bufq, &nbp->vb_buf); - vnd->sc_active++; + disksort(&vnd->sc_tab, &nbp->vb_buf); + vnd->sc_tab.b_active++; vndstart(vnd); splx(s); bn += sz; @@ -633,9 +634,8 @@ vndstart(struct vnd_softc *vnd) * Dequeue now since lower level strategy routine might * queue using same links */ - bp = BUFQ_GET(vnd->sc_dk.dk_bufq); - if (bp == NULL) - return; + bp = vnd->sc_tab.b_actf; + vnd->sc_tab.b_actf = bp->b_actf; 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_active) { + if (vnd->sc_tab.b_active) { disk_unbusy(&vnd->sc_dk, (pbp->b_bcount - pbp->b_resid), (pbp->b_flags & B_READ)); - if (BUFQ_PEEK(vnd->sc_dk.dk_bufq) != NULL) - vnd->sc_active--; + if (!vnd->sc_tab.b_actf) + vnd->sc_tab.b_active--; } if (pbp->b_resid == 0) { DNPRINTF(VDB_IO, "vndiodone: pbp %p iodone\n", pbp); diff --git a/sys/kern/kern_bufq.c b/sys/kern/kern_bufq.c deleted file mode 100644 index 8af3a312f0f..00000000000 --- a/sys/kern/kern_bufq.c +++ /dev/null @@ -1,154 +0,0 @@ -/* $OpenBSD: kern_bufq.c,v 1.2 2009/06/04 19:16:13 thib Exp $ */ - -/* - * Copyright (c) 2008, 2009 Thordur I. Bjornsson <thib@openbsd.org> - * Copyright (c) 2004 Ted Unangst <tedu@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/malloc.h> -#include <sys/pool.h> -#include <sys/proc.h> -#include <sys/buf.h> -#include <sys/errno.h> - -#include <sys/disklabel.h> - -/* plain old disksort. */ -struct buf *bufq_disksort_get(struct bufq *, int); -void bufq_disksort_add(struct bufq *, struct buf *); -int bufq_disksort_init(struct bufq *); - -struct bufq * -bufq_init(int type) -{ - struct bufq *bq; - int error; - - KASSERT(type = BUFQ_DISKSORT); - - bq = malloc(sizeof(*bq), M_DEVBUF, M_NOWAIT|M_ZERO); - if (bq == NULL) - return (NULL); - - /* For now, only plain old disksort. */ - bq->bufq_type = type; - bq->bufq_get = bufq_disksort_get; - bq->bufq_add = bufq_disksort_add; - - error = bufq_disksort_init(bq); - if (error) { - free(bq, M_DEVBUF); - return (NULL); - } - - return (bq); -} - -void -bufq_destroy(struct bufq *bq) -{ - bufq_drain(bq); - - if (bq->bufq_data != NULL) - free(bq->bufq_data, M_DEVBUF); - - free(bq, M_DEVBUF); -} - -void -bufq_drain(struct bufq *bq) -{ - struct buf *bp; - int s; - - s = splbio(); - while ((bp = BUFQ_GET(bq)) != NULL) { - bp->b_error = ENXIO; - bp->b_flags |= B_ERROR; - biodone(bp); - } - splx(s); - -} - -void -bufq_disksort_add(struct bufq *bq, struct buf *bp) -{ - struct buf *bufq; - - splassert(IPL_BIO); - - bufq = (struct buf *)bq->bufq_data; - - disksort(bufq, bp); -} - -struct buf * -bufq_disksort_get(struct bufq *bq, int peeking) -{ - struct buf *bufq, *bp; - - splassert(IPL_BIO); - - bufq = (struct buf *)bq->bufq_data; - bp = bufq->b_actf; - if (bp == NULL) - return (NULL); - if (!peeking) - bufq->b_actf = bp->b_actf; - return (bp); -} - -int -bufq_disksort_init(struct bufq *bq) -{ - int error = 0; - - bq->bufq_data = malloc(sizeof(struct buf), M_DEVBUF, - M_WAITOK|M_ZERO); - - if (bq->bufq_data == NULL) - error = ENOMEM; - - return (error); -} - -#ifdef DDB -#include <machine/db_machdep.h> -#include <ddb/db_interface.h> -#include <ddb/db_output.h> - -void -db_bufq_print(struct bufq *bq, int full, int (*pr)(const char *, ...)) -{ - struct buf *bp, *dp; - - - (*pr)(" type %i\n bufq_add %p bufq_get %p bufq_data %p", - bq->bufq_type, bq->bufq_add, bq->bufq_get, bq->bufq_data); - - if (full) { - printf("bufs on queue:\n"); - bp = (struct buf *)bq->bufq_data; - while ((dp = bp->b_actf) != NULL) { - printf("%p\n", bp); - bp = dp; - } - } -} - -#endif diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index d33a152d299..e1dbaa310b6 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.94 2009/06/14 00:09:40 deraadt Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.95 2009/06/17 01:30:30 thib Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -768,10 +768,6 @@ disk_construct(struct disk *diskp, char *lockname) rw_init(&diskp->dk_lock, "dklk"); mtx_init(&diskp->dk_mtx, IPL_BIO); - diskp->dk_bufq = bufq_init(BUFQ_DEFAULT); - if (diskp->dk_bufq == NULL) - return (1); - diskp->dk_flags |= DKF_CONSTRUCTED; return (0); @@ -785,8 +781,7 @@ disk_attach(struct disk *diskp) { if (!ISSET(diskp->dk_flags, DKF_CONSTRUCTED)) - if (disk_construct(diskp, diskp->dk_name)) - panic("disk_attach: can't construct disk"); + disk_construct(diskp, diskp->dk_name); /* * Allocate and initialize the disklabel structures. Note that @@ -829,8 +824,6 @@ disk_detach(struct disk *diskp) */ free(diskp->dk_label, M_DEVBUF); - bufq_destroy(diskp->dk_bufq); - /* * Remove from the disklist. */ diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c index 619b06aad28..64b8e7adc8a 100644 --- a/sys/scsi/cd.c +++ b/sys/scsi/cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd.c,v 1.147 2009/06/03 22:09:30 thib Exp $ */ +/* $OpenBSD: cd.c,v 1.148 2009/06/17 01:30:30 thib Exp $ */ /* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */ /* @@ -98,6 +98,7 @@ void cdrestart(void *); void cdminphys(struct buf *); void cdgetdisklabel(dev_t, struct cd_softc *, struct disklabel *, int); void cddone(struct scsi_xfer *); +void cd_kill_buffers(struct cd_softc *); int cd_setchan(struct cd_softc *, int, int, int, int, int); int cd_getvol(struct cd_softc *cd, struct ioc_vol *, int); int cd_setvol(struct cd_softc *, const struct ioc_vol *, int); @@ -247,7 +248,7 @@ cddetach(struct device *self, int flags) struct cd_softc *cd = (struct cd_softc *)self; int bmaj, cmaj, mn; - bufq_drain(cd->sc_dk.dk_bufq); + cd_kill_buffers(cd); /* Locate the lowest minor number to be detached. */ mn = DISKMINOR(self->dv_unit, 0); @@ -498,7 +499,7 @@ cdstrategy(struct buf *bp) /* * Place it in the queue of disk activities for this disk */ - BUFQ_ADD(cd->sc_dk.dk_bufq, bp); + disksort(&cd->buf_queue, bp); /* * Tell the device to get going on the transfer if it's @@ -545,7 +546,8 @@ cdstart(void *v) { struct cd_softc *cd = v; struct scsi_link *sc_link = cd->sc_link; - struct buf *bp = NULL; + struct buf *bp = 0; + struct buf *dp; struct scsi_rw_big cmd_big; struct scsi_rw cmd_small; struct scsi_generic *cmdp; @@ -570,9 +572,13 @@ cdstart(void *v) return; } - /* See if there is a buf with work for us to do..*/ - if ((bp = BUFQ_GET(cd->sc_dk.dk_bufq)) == NULL) + /* + * See if there is a buf with work for us to do.. + */ + dp = &cd->buf_queue; + if ((bp = dp->b_actf) == NULL) /* yes, an assign */ return; + dp->b_actf = bp->b_actf; /* * If the device has become invalid, abort all the @@ -649,7 +655,7 @@ cdstart(void *v) /* * The device can't start another i/o. Try again later. */ - BUFQ_ADD(cd->sc_dk.dk_bufq, bp); + dp->b_actf = bp; disk_unbusy(&cd->sc_dk, 0, 0); timeout_add(&cd->sc_timeout, 1); return; @@ -1947,6 +1953,26 @@ cd_interpret_sense(struct scsi_xfer *xs) return (EJUSTRETURN); /* use generic handler in scsi_base */ } +/* + * Remove unprocessed buffers from queue. + */ +void +cd_kill_buffers(struct cd_softc *cd) +{ + struct buf *dp, *bp; + int s; + + s = splbio(); + for (dp = &cd->buf_queue; (bp = dp->b_actf) != NULL; ) { + dp->b_actf = bp->b_actf; + + bp->b_error = ENXIO; + bp->b_flags |= B_ERROR; + biodone(bp); + } + splx(s); +} + #if defined(__macppc__) int cd_eject(void) diff --git a/sys/scsi/cd.h b/sys/scsi/cd.h index e5ef94bcea5..e65f750f7c7 100644 --- a/sys/scsi/cd.h +++ b/sys/scsi/cd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cd.h,v 1.20 2009/06/03 22:09:30 thib Exp $ */ +/* $OpenBSD: cd.h,v 1.21 2009/06/17 01:30:30 thib Exp $ */ /* $NetBSD: scsi_cd.h,v 1.6 1996/03/19 03:06:39 mycroft Exp $ */ /* @@ -293,6 +293,7 @@ struct cd_softc { #ifdef CDDA struct cd_parms orig_params; /* filled in when CD-DA mode starts */ #endif + struct buf buf_queue; struct timeout sc_timeout; void *sc_cdpwrhook; /* our power hook */ }; diff --git a/sys/scsi/sd.c b/sys/scsi/sd.c index 27e9ee7e65e..8f9d44c4e6d 100644 --- a/sys/scsi/sd.c +++ b/sys/scsi/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.155 2009/06/03 22:09:30 thib Exp $ */ +/* $OpenBSD: sd.c,v 1.156 2009/06/17 01:30:30 thib Exp $ */ /* $NetBSD: sd.c,v 1.111 1997/04/02 02:29:41 mycroft Exp $ */ /*- @@ -90,6 +90,7 @@ int sd_reassign_blocks(struct sd_softc *, u_long); int sd_interpret_sense(struct scsi_xfer *); int sd_get_parms(struct sd_softc *, struct disk_parms *, int); void sd_flush(struct sd_softc *, int); +void sd_kill_buffers(struct sd_softc *); void viscpy(u_char *, u_char *, int); @@ -267,7 +268,7 @@ sdactivate(struct device *self, enum devact act) case DVACT_DEACTIVATE: sd->flags |= SDF_DYING; - bufq_drain(sd->sc_dk.dk_bufq); + sd_kill_buffers(sd); break; } @@ -281,7 +282,7 @@ sddetach(struct device *self, int flags) struct sd_softc *sd = (struct sd_softc *)self; int bmaj, cmaj, mn; - bufq_drain(sd->sc_dk.dk_bufq); + sd_kill_buffers(sd); /* Locate the lowest minor number to be detached. */ mn = DISKMINOR(self->dv_unit, 0); @@ -549,8 +550,10 @@ sdstrategy(struct buf *bp) s = splbio(); - /* Place it in the queue of disk activities for this disk */ - BUFQ_ADD(sd->sc_dk.dk_bufq, bp); + /* + * Place it in the queue of disk activities for this disk + */ + disksort(&sd->buf_queue, bp); /* * Tell the device to get going on the transfer if it's @@ -599,6 +602,7 @@ sdstart(void *v) struct sd_softc *sd = (struct sd_softc *)v; struct scsi_link *sc_link = sd->sc_link; struct buf *bp = 0; + struct buf *dp; struct scsi_rw_big cmd_big; struct scsi_rw_12 cmd_12; struct scsi_rw_16 cmd_16; @@ -633,8 +637,10 @@ sdstart(void *v) /* * See if there is a buf with work for us to do.. */ - if ((bp = BUFQ_GET(sd->sc_dk.dk_bufq)) == NULL) + dp = &sd->buf_queue; + if ((bp = dp->b_actf) == NULL) /* yes, an assign */ return; + dp->b_actf = bp->b_actf; /* * If the device has become invalid, abort all the @@ -741,7 +747,7 @@ sdstart(void *v) /* * The device can't start another i/o. Try again later. */ - BUFQ_ADD(sd->sc_dk.dk_bufq, bp); + dp->b_actf = bp; disk_unbusy(&sd->sc_dk, 0, 0); timeout_add(&sd->sc_timeout, 1); return; @@ -1489,3 +1495,23 @@ sd_flush(struct sd_softc *sd, int flags) } else sd->flags &= ~SDF_DIRTY; } + +/* + * Remove unprocessed buffers from queue. + */ +void +sd_kill_buffers(struct sd_softc *sd) +{ + struct buf *dp, *bp; + int s; + + s = splbio(); + for (dp = &sd->buf_queue; (bp = dp->b_actf) != NULL; ) { + dp->b_actf = bp->b_actf; + + bp->b_error = ENXIO; + bp->b_flags |= B_ERROR; + biodone(bp); + } + splx(s); +} diff --git a/sys/scsi/sdvar.h b/sys/scsi/sdvar.h index 2498b15edac..a6cd1541c02 100644 --- a/sys/scsi/sdvar.h +++ b/sys/scsi/sdvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sdvar.h,v 1.17 2009/06/03 22:09:30 thib Exp $ */ +/* $OpenBSD: sdvar.h,v 1.18 2009/06/17 01:30:32 thib Exp $ */ /* $NetBSD: sdvar.h,v 1.7 1998/08/17 00:49:03 mycroft Exp $ */ /*- @@ -69,6 +69,7 @@ struct sd_softc { u_long rot_rate; /* rotational rate, in RPM */ daddr64_t disksize; /* total number sectors */ } params; + struct buf buf_queue; void *sc_sdhook; /* our shutdown hook */ struct timeout sc_timeout; }; diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 522a320711f..ded9e03f319 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.h,v 1.65 2009/06/15 17:01:26 beck Exp $ */ +/* $OpenBSD: buf.h,v 1.66 2009/06/17 01:30:32 thib Exp $ */ /* $NetBSD: buf.h,v 1.25 1997/04/09 21:12:17 mycroft Exp $ */ /* @@ -106,28 +106,6 @@ struct buf { struct workhead b_dep; /* List of filesystem dependencies. */ }; -/* BUFQ: flexible buffer queue routines. */ -#define BUFQ_DISKSORT 1 -#define BUFQ_DEFAULT BUFQ_DISKSORT - -struct bufq { - struct buf *(*bufq_get)(struct bufq *, int); - void (*bufq_add)(struct bufq *, struct buf *); - void *bufq_data; - int bufq_type; -}; - -TAILQ_HEAD(bufq_tailq, buf); - -#define BUFQ_ADD(_bufq, _bp) (_bufq)->bufq_add(_bufq, _bp) -#define BUFQ_GET(_bufq) (_bufq)->bufq_get(_bufq, 0) -#define BUFQ_PEEK(_bufq) (_bufq)->bufq_get(_bufq, 1) - -struct bufq *bufq_init(int); -void bufq_destroy(struct bufq *); -void bufq_drain(struct bufq *); - - /* * For portability with historic industry practice, the cylinder number has * to be maintained in the `b_resid' field. diff --git a/sys/sys/disk.h b/sys/sys/disk.h index d044367c5af..9005ace6f7f 100644 --- a/sys/sys/disk.h +++ b/sys/sys/disk.h @@ -1,4 +1,4 @@ -/* $OpenBSD: disk.h,v 1.19 2009/06/03 22:09:30 thib Exp $ */ +/* $OpenBSD: disk.h,v 1.20 2009/06/17 01:30:32 thib Exp $ */ /* $NetBSD: disk.h,v 1.11 1996/04/28 20:22:50 thorpej Exp $ */ /* @@ -54,7 +54,6 @@ #include <sys/mutex.h> struct buf; -struct bufq; struct disklabel; #define DS_DISKNAMELEN 16 @@ -102,7 +101,6 @@ struct disk { int dk_byteshift; /* shift to convert bytes to blks */ struct dkdriver *dk_driver; /* pointer to driver */ - struct bufq *dk_bufq; /* * Disk label information. Storage for the in-core disk label |