Use bioq_flush() to drain a bio queue with a specific error code.

Retain the mistake of not updating the devstat API for now.

Spell bioq_disksort() consistently with the remaining bioq_*().

#include <geom/geom_disk.h> where this is more appropriate.
This commit is contained in:
Poul-Henning Kamp 2003-04-01 15:06:26 +00:00
parent 29f3f095a6
commit 891619a66d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112946
41 changed files with 61 additions and 109 deletions

View File

@ -394,7 +394,6 @@ cdoninvalidate(struct cam_periph *periph)
{
int s;
struct cd_softc *softc;
struct bio *q_bp;
struct ccb_setasync csa;
softc = (struct cd_softc *)periph->softc;
@ -424,11 +423,7 @@ cdoninvalidate(struct cam_periph *periph)
* XXX Handle any transactions queued to the card
* with XPT_ABORT_CCB.
*/
while ((q_bp = bioq_first(&softc->bio_queue)) != NULL){
bioq_remove(&softc->bio_queue, q_bp);
q_bp->bio_resid = q_bp->bio_bcount;
biofinish(q_bp, NULL, ENXIO);
}
bioq_flush(&softc->bio_queue, NULL, ENXIO);
splx(s);
/*
@ -1464,7 +1459,7 @@ cdstrategy(struct bio *bp)
/*
* Place it in the queue of disk activities for this disk
*/
bioqdisksort(&softc->bio_queue, bp);
bioq_disksort(&softc->bio_queue, bp);
splx(s);
@ -1630,16 +1625,11 @@ cddone(struct cam_periph *periph, union ccb *done_ccb)
if (error != 0) {
int s;
struct bio *q_bp;
xpt_print_path(periph->path);
printf("cddone: got error %#x back\n", error);
s = splbio();
while ((q_bp = bioq_first(&softc->bio_queue)) != NULL) {
bioq_remove(&softc->bio_queue, q_bp);
q_bp->bio_resid = q_bp->bio_bcount;
biofinish(q_bp, NULL, EIO);
}
bioq_flush(&softc->bio_queue, NULL, EIO);
splx(s);
bp->bio_resid = bp->bio_bcount;
bp->bio_error = error;

View File

@ -43,7 +43,6 @@
#include <sys/devicestat.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <sys/eventhandler.h>
#include <sys/malloc.h>
#include <sys/cons.h>
@ -53,6 +52,8 @@
#include <vm/vm.h>
#include <vm/pmap.h>
#include <geom/geom_disk.h>
#ifndef _KERNEL
#include <stdio.h>
#include <string.h>
@ -750,7 +751,7 @@ dastrategy(struct bio *bp)
/*
* Place it in the queue of disk activities for this disk
*/
bioqdisksort(&softc->bio_queue, bp);
bioq_disksort(&softc->bio_queue, bp);
splx(s);
@ -935,7 +936,6 @@ daoninvalidate(struct cam_periph *periph)
{
int s;
struct da_softc *softc;
struct bio *q_bp;
struct ccb_setasync csa;
softc = (struct da_softc *)periph->softc;
@ -965,11 +965,7 @@ daoninvalidate(struct cam_periph *periph)
* XXX Handle any transactions queued to the card
* with XPT_ABORT_CCB.
*/
while ((q_bp = bioq_first(&softc->bio_queue)) != NULL){
bioq_remove(&softc->bio_queue, q_bp);
q_bp->bio_resid = q_bp->bio_bcount;
biofinish(q_bp, NULL, ENXIO);
}
bioq_flush(&softc->bio_queue, NULL, ENXIO);
splx(s);
SLIST_REMOVE(&softc_list, softc, da_softc, links);
@ -1438,7 +1434,6 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
return;
}
if (error != 0) {
struct bio *q_bp;
s = splbio();
@ -1460,12 +1455,7 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
* the client can retry these I/Os in the
* proper order should it attempt to recover.
*/
while ((q_bp = bioq_first(&softc->bio_queue))
!= NULL) {
bioq_remove(&softc->bio_queue, q_bp);
q_bp->bio_resid = q_bp->bio_bcount;
biofinish(q_bp, NULL, EIO);
}
bioq_flush(&softc->bio_queue, NULL, EIO);
splx(s);
bp->bio_error = error;
bp->bio_resid = bp->bio_bcount;

View File

@ -353,7 +353,6 @@ ptoninvalidate(struct cam_periph *periph)
{
int s;
struct pt_softc *softc;
struct bio *q_bp;
struct ccb_setasync csa;
softc = (struct pt_softc *)periph->softc;
@ -383,11 +382,7 @@ ptoninvalidate(struct cam_periph *periph)
* XXX Handle any transactions queued to the card
* with XPT_ABORT_CCB.
*/
while ((q_bp = bioq_first(&softc->bio_queue)) != NULL){
bioq_remove(&softc->bio_queue, q_bp);
q_bp->bio_resid = q_bp->bio_bcount;
biofinish(q_bp, NULL, ENXIO);
}
bioq_flush(&softc->bio_queue, NULL, ENXIO);
splx(s);
@ -574,8 +569,6 @@ ptdone(struct cam_periph *periph, union ccb *done_ccb)
return;
}
if (error != 0) {
struct bio *q_bp;
s = splbio();
if (error == ENXIO) {
@ -593,12 +586,7 @@ ptdone(struct cam_periph *periph, union ccb *done_ccb)
* the client can retry these I/Os in the
* proper order should it attempt to recover.
*/
while ((q_bp = bioq_first(&softc->bio_queue))
!= NULL) {
bioq_remove(&softc->bio_queue, q_bp);
q_bp->bio_resid = q_bp->bio_bcount;
biofinish(q_bp, NULL, EIO);
}
bioq_flush(&softc->bio_queue, NULL, EIO);
splx(s);
bp->bio_error = error;
bp->bio_resid = bp->bio_bcount;

View File

@ -1281,7 +1281,6 @@ static void
saoninvalidate(struct cam_periph *periph)
{
struct sa_softc *softc;
struct bio *q_bp;
struct ccb_setasync csa;
int s;
@ -1312,11 +1311,7 @@ saoninvalidate(struct cam_periph *periph)
* XXX Handle any transactions queued to the card
* with XPT_ABORT_CCB.
*/
while ((q_bp = bioq_first(&softc->bio_queue)) != NULL){
bioq_remove(&softc->bio_queue, q_bp);
q_bp->bio_resid = q_bp->bio_bcount;
biofinish(q_bp, NULL, ENXIO);
}
bioq_flush(&softc->bio_queue, NULL, ENXIO);
softc->queue_count = 0;
splx(s);
@ -1698,7 +1693,6 @@ sadone(struct cam_periph *periph, union ccb *done_ccb)
if (error == EIO) {
int s;
struct bio *q_bp;
/*
* Catastrophic error. Mark the tape as frozen
@ -1713,11 +1707,7 @@ sadone(struct cam_periph *periph, union ccb *done_ccb)
s = splbio();
softc->flags |= SA_FLAG_TAPE_FROZEN;
while ((q_bp = bioq_first(&softc->bio_queue)) != NULL) {
bioq_remove(&softc->bio_queue, q_bp);
q_bp->bio_resid = q_bp->bio_bcount;
biofinish(q_bp, NULL, EIO);
}
bioq_flush(&softc->bio_queue, NULL, EIO);
splx(s);
}
if (error != 0) {

View File

@ -17,9 +17,9 @@
#include <sys/bio.h>
#include <sys/malloc.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <sys/module.h>
#include <machine/resource.h>
#include <geom/geom_disk.h>
#include <vm/vm.h>
#include <vm/pmap.h>
@ -133,7 +133,7 @@ flastrategy(struct bio *bp)
sc = bp->bio_disk->d_drv1;
bioqdisksort(&sc->bio_queue, bp);
bioq_disksort(&sc->bio_queue, bp);
if (sc->busy) {
return;

View File

@ -43,10 +43,10 @@
#include <sys/kthread.h>
#include <sys/sysctl.h>
#include <sys/poll.h>
#include <sys/ioccom.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <sys/signalvar.h>
#include <sys/time.h>
#include <sys/eventhandler.h>

View File

@ -39,13 +39,12 @@
#include <sys/kernel.h>
#include <sys/conf.h>
#include <dev/aac/aac_compat.h>
#include <sys/bus.h>
#include <sys/disk.h>
#include <machine/resource.h>
#include <machine/bus.h>
#include <dev/aac/aac_compat.h>
#include <dev/aac/aacreg.h>
#include <dev/aac/aac_ioctl.h>
#include <dev/aac/aacvar.h>

View File

@ -34,6 +34,8 @@
#include <sys/mutex.h>
#include <sys/taskqueue.h>
#include <sys/selinfo.h>
#include <geom/geom_disk.h>
/*
* Driver Parameter Definitions

View File

@ -68,7 +68,6 @@
#include <dev/amr/amr_compat.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <sys/stat.h>
#include <machine/bus_memio.h>

View File

@ -64,7 +64,6 @@
#include <dev/amr/amr_compat.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <sys/stat.h>
#include <cam/cam.h>

View File

@ -68,7 +68,6 @@
#include <dev/amr/amr_compat.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <machine/bus.h>
#include <sys/rman.h>

View File

@ -63,7 +63,6 @@
#include <dev/amr/amr_compat.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <machine/bus_memio.h>
#include <machine/bus_pio.h>

View File

@ -58,6 +58,7 @@
#if __FreeBSD_version >= 500005
# include <sys/taskqueue.h>
# include <geom/geom_disk.h>
#endif
#ifdef AMR_DEBUG

View File

@ -34,7 +34,6 @@
#include <sys/ata.h>
#include <sys/kernel.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/bio.h>
@ -47,6 +46,7 @@
#ifdef __alpha__
#include <machine/md_var.h>
#endif
#include <geom/geom_disk.h>
#include <dev/ata/ata-all.h>
#include <dev/ata/ata-disk.h>
#include <dev/ata/ata-raid.h>

View File

@ -45,6 +45,7 @@
#include <machine/md_var.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <geom/geom_disk.h>
#include <dev/ata/ata-all.h>
#include <dev/ata/ata-pci.h>
#include <dev/ata/ata-disk.h>
@ -217,7 +218,6 @@ ad_detach(struct ata_device *atadev, int flush) /* get rid of flush XXX SOS */
{
struct ad_softc *adp = atadev->driver;
struct ad_request *request;
struct bio *bp;
atadev->flags |= ATA_D_DETACHING;
ata_prtdev(atadev, "removed from configuration\n");
@ -229,10 +229,7 @@ ad_detach(struct ata_device *atadev, int flush) /* get rid of flush XXX SOS */
biofinish(request->bp, NULL, ENXIO);
ad_free(request);
}
while ((bp = bioq_first(&adp->queue))) {
bioq_remove(&adp->queue, bp);
biofinish(bp, NULL, ENXIO);
}
bioq_flush(&adp->queue, NULL, ENXIO);
disk_destroy(&adp->disk);
if (adp->flags & AD_F_RAID_SUBDISK)
@ -288,7 +285,7 @@ adstrategy(struct bio *bp)
return;
}
s = splbio();
bioqdisksort(&adp->queue, bp);
bioq_disksort(&adp->queue, bp);
splx(s);
ata_start(adp->device->channel);
}

View File

@ -44,6 +44,7 @@
#include <sys/kthread.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <geom/geom_disk.h>
#include <dev/ata/ata-all.h>
#include <dev/ata/ata-pci.h>
#include <dev/ata/ata-disk.h>

View File

@ -193,17 +193,13 @@ acddetach(struct ata_device *atadev)
{
struct acd_softc *cdp = atadev->driver;
struct acd_devlist *entry;
struct bio *bp;
int subdev;
if (cdp->changer_info) {
for (subdev = 0; subdev < cdp->changer_info->slots; subdev++) {
if (cdp->driver[subdev] == cdp)
continue;
while ((bp = bioq_first(&cdp->driver[subdev]->queue))) {
bioq_remove(&cdp->driver[subdev]->queue, bp);
biofinish(bp, NULL, ENXIO);
}
bioq_flush(&cdp->driver[subdev]->queue, NULL, ENXIO);
destroy_dev(cdp->driver[subdev]->dev);
while ((entry = TAILQ_FIRST(&cdp->driver[subdev]->dev_list))) {
destroy_dev(entry->dev);
@ -217,8 +213,7 @@ acddetach(struct ata_device *atadev)
free(cdp->driver, M_ACD);
free(cdp->changer_info, M_ACD);
}
while ((bp = bioq_first(&cdp->queue)))
biofinish(bp, NULL, ENXIO);
bioq_flush(&cdp->queue, NULL, ENXIO);
while ((entry = TAILQ_FIRST(&cdp->dev_list))) {
destroy_dev(entry->dev);
TAILQ_REMOVE(&cdp->dev_list, entry, chain);
@ -1100,7 +1095,7 @@ acdstrategy(struct bio *bp)
bp->bio_resid = bp->bio_bcount;
s = splbio();
bioqdisksort(&cdp->queue, bp);
bioq_disksort(&cdp->queue, bp);
splx(s);
ata_start(cdp->device->channel);
}

View File

@ -36,9 +36,9 @@
#include <sys/bio.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <sys/cdio.h>
#include <machine/bus.h>
#include <geom/geom_disk.h>
#include <dev/ata/ata-all.h>
#include <dev/ata/atapi-all.h>
#include <dev/ata/atapi-fd.h>
@ -103,12 +103,8 @@ void
afddetach(struct ata_device *atadev)
{
struct afd_softc *fdp = atadev->driver;
struct bio *bp;
while ((bp = bioq_first(&fdp->queue))) {
bioq_remove(&fdp->queue, bp);
biofinish(bp, NULL, ENXIO);
}
bioq_flush(&fdp->queue, NULL, ENXIO);
disk_destroy(&fdp->disk);
ata_free_name(atadev);
ata_free_lun(&afd_lun_map, fdp->lun);
@ -283,7 +279,7 @@ afdstrategy(struct bio *bp)
}
s = splbio();
bioqdisksort(&fdp->queue, bp);
bioq_disksort(&fdp->queue, bp);
splx(s);
ata_start(fdp->device->channel);
}

View File

@ -145,12 +145,8 @@ void
astdetach(struct ata_device *atadev)
{
struct ast_softc *stp = atadev->driver;
struct bio *bp;
while ((bp = bioq_first(&stp->queue))) {
bioq_remove(&stp->queue, bp);
biofinish(bp, NULL, ENXIO);
}
bioq_flush(&stp->queue, NULL, ENXIO);
destroy_dev(stp->dev1);
destroy_dev(stp->dev2);
devstat_remove_entry(stp->stats);

View File

@ -67,6 +67,7 @@
#include <sys/disk.h>
#include <sys/fcntl.h>
#include <sys/vnode.h>
#include <geom/geom_disk.h>
#include <sys/ccdvar.h>

View File

@ -1722,7 +1722,7 @@ fdstrategy(struct bio *bp)
}
bp->bio_pblkno = blknum;
s = splbio();
bioqdisksort(&fdc->head, bp);
bioq_disksort(&fdc->head, bp);
untimeout(fd_turnoff, fd, fd->toffhandle); /* a good idea */
devstat_start_transaction_bio(fd->device_stats, bp);
device_busy(fd->dev);

View File

@ -46,13 +46,14 @@
#include <sys/bio.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <machine/bus_memio.h>
#include <machine/bus_pio.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <geom/geom_disk.h>
#include <dev/ida/idareg.h>
#include <dev/ida/idavar.h>

View File

@ -38,7 +38,6 @@
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/cons.h>
#include <sys/disk.h>
#include <machine/bus_memio.h>
#include <machine/bus_pio.h>
@ -49,6 +48,8 @@
#include <vm/pmap.h>
#include <machine/md_var.h>
#include <geom/geom_disk.h>
#include <dev/ida/idareg.h>
#include <dev/ida/idavar.h>

View File

@ -34,13 +34,14 @@
#include <sys/bio.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <machine/bus_pio.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
#include <geom/geom_disk.h>
#include <dev/ida/idavar.h>
#include <dev/ida/idareg.h>

View File

@ -33,7 +33,6 @@
#include <sys/bio.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <machine/bus_memio.h>
#include <machine/bus_pio.h>
@ -44,6 +43,8 @@
#include <pci/pcireg.h>
#include <pci/pcivar.h>
#include <geom/geom_disk.h>
#include <dev/ida/idavar.h>
#include <dev/ida/idareg.h>

View File

@ -334,7 +334,7 @@ mcdstrategy(struct bio *bp)
/* queue it */
s = splbio();
bioqdisksort(&sc->data.head, bp);
bioq_disksort(&sc->data.head, bp);
splx(s);
/* now check whether we can perform processing */

View File

@ -376,7 +376,7 @@ g_md_start(struct bio *bp)
bp->bio_pblkno = bp->bio_offset / sc->secsize;
bp->bio_bcount = bp->bio_length;
mtx_lock(&sc->queue_mtx);
bioqdisksort(&sc->bio_queue, bp);
bioq_disksort(&sc->bio_queue, bp);
mtx_unlock(&sc->queue_mtx);
wakeup(sc);

View File

@ -37,7 +37,6 @@
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <sys/stat.h>
#include <machine/resource.h>
@ -47,6 +46,8 @@
#include <machine/clock.h>
#include <sys/rman.h>
#include <geom/geom_disk.h>
#include <dev/mlx/mlx_compat.h>
#include <dev/mlx/mlxio.h>
#include <dev/mlx/mlxvar.h>

View File

@ -37,11 +37,12 @@
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <geom/geom_disk.h>
#include <dev/mlx/mlx_compat.h>
#include <dev/mlx/mlxio.h>
#include <dev/mlx/mlxvar.h>

View File

@ -32,7 +32,6 @@
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <machine/bus_memio.h>
#include <machine/bus_pio.h>
@ -40,6 +39,8 @@
#include <machine/resource.h>
#include <sys/rman.h>
#include <geom/geom_disk.h>
#include <pci/pcireg.h>
#include <pci/pcivar.h>

View File

@ -35,7 +35,6 @@
#include <sys/bus.h>
#include <sys/bio.h>
#include <sys/conf.h>
#include <sys/disk.h>
#include <sys/eventhandler.h>
#include <sys/malloc.h>
#include <sys/lock.h>
@ -48,6 +47,7 @@
#include <sys/rman.h>
#include <pci/pcivar.h>
#include <pci/pcireg.h>
#include <geom/geom_disk.h>
#include "dev/pst/pst-iop.h"
@ -200,7 +200,7 @@ pststrategy(struct bio *bp)
struct pst_softc *psc = bp->bio_disk->d_drv1;
mtx_lock(&psc->mtx);
bioqdisksort(&psc->queue, bp);
bioq_disksort(&psc->queue, bp);
pst_start(psc);
mtx_unlock(&psc->mtx);
}

View File

@ -162,6 +162,7 @@
#include <sys/reboot.h>
#include <sys/module.h>
#include <vm/uma.h>
#include <geom/geom_disk.h>
#include "opt_raid.h"
#include <dev/raidframe/rf_raid.h>

View File

@ -291,7 +291,7 @@ scdstrategy(struct bio *bp)
/* queue it */
s = splbio();
bioqdisksort(&sc->data.head, bp);
bioq_disksort(&sc->data.head, bp);
splx(s);
/* now check whether we can perform processing */

View File

@ -39,6 +39,7 @@
#include <vm/vm.h>
#include <vm/pmap.h>
#include <dev/twe/twe_compat.h>
#include <geom/geom_disk.h>
#include <dev/twe/twereg.h>
#include <dev/twe/tweio.h>
#include <dev/twe/twevar.h>

View File

@ -67,6 +67,7 @@
#include <sys/disk.h>
#include <sys/fcntl.h>
#include <sys/vnode.h>
#include <geom/geom_disk.h>
#include <sys/ccdvar.h>

View File

@ -105,7 +105,7 @@ sscstrategy(struct bio *bp)
s = splbio();
bioqdisksort(&sc->bio_queue, bp);
bioq_disksort(&sc->bio_queue, bp);
if (sc->busy) {
splx(s);

View File

@ -1722,7 +1722,7 @@ fdstrategy(struct bio *bp)
}
bp->bio_pblkno = blknum;
s = splbio();
bioqdisksort(&fdc->head, bp);
bioq_disksort(&fdc->head, bp);
untimeout(fd_turnoff, fd, fd->toffhandle); /* a good idea */
devstat_start_transaction_bio(fd->device_stats, bp);
device_busy(fd->dev);

View File

@ -2151,7 +2151,7 @@ fdstrategy(struct bio *bp)
}
bp->bio_pblkno = blknum;
s = splbio();
bioqdisksort(&fdc->head, bp);
bioq_disksort(&fdc->head, bp);
untimeout(fd_turnoff, fd, fd->toffhandle); /* a good idea */
devstat_start_transaction_bio(fd->device_stats, bp);
device_busy(fd->dev);

View File

@ -2151,7 +2151,7 @@ fdstrategy(struct bio *bp)
}
bp->bio_pblkno = blknum;
s = splbio();
bioqdisksort(&fdc->head, bp);
bioq_disksort(&fdc->head, bp);
untimeout(fd_turnoff, fd, fd->toffhandle); /* a good idea */
devstat_start_transaction_bio(fd->device_stats, bp);
device_busy(fd->dev);

View File

@ -640,7 +640,7 @@ wdstrategy(struct bio *bp)
du->dk_state = WANTOPEN;
}
bioqdisksort(&drive_queue[lunit], bp);
bioq_disksort(&drive_queue[lunit], bp);
if (wdutab[lunit].b_active == 0)
wdustart(du); /* start drive */

View File

@ -441,7 +441,7 @@ acdstrategy(struct bio *bp)
bp->bio_resid = bp->bio_bcount;
x = splbio();
bioqdisksort(&cdp->bio_queue, bp);
bioq_disksort(&cdp->bio_queue, bp);
acd_start(cdp);
splx(x);
}