summaryrefslogtreecommitdiffstats
path: root/sys/dev/ata/atapi-tape.c
diff options
context:
space:
mode:
authorsos <sos@FreeBSD.org>2001-03-14 12:05:44 +0000
committersos <sos@FreeBSD.org>2001-03-14 12:05:44 +0000
commit4659caa469c2dedd9d5063417c8da7cc4e37d7aa (patch)
tree871c965e909b58c956ea34692b952d392b3c58c1 /sys/dev/ata/atapi-tape.c
parent045a83cd9229e8ab1171e7adf872e072644f8945 (diff)
downloadFreeBSD-src-4659caa469c2dedd9d5063417c8da7cc4e37d7aa.zip
FreeBSD-src-4659caa469c2dedd9d5063417c8da7cc4e37d7aa.tar.gz
Refine the detach/attach code.
Proberly fail outstanding bio requests on devices that are detached. This makes it possible to change between disk/cdrom/dvd/whathaveyou in a notebook, just by suspending it, changing the device in the bay (or what you model calls it), unsuspend and the ATA driver will figure out what disappeared and properly fail those, and attach any new devices found.
Diffstat (limited to 'sys/dev/ata/atapi-tape.c')
-rw-r--r--sys/dev/ata/atapi-tape.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c
index af3e7af..7fa8fc5 100644
--- a/sys/dev/ata/atapi-tape.c
+++ b/sys/dev/ata/atapi-tape.c
@@ -101,7 +101,7 @@ astattach(struct atapi_softc *atp)
printf("ast: out of memory\n");
return -1;
}
- bioq_init(&stp->bio_queue);
+ bioq_init(&stp->queue);
stp->atp = atp;
stp->lun = ata_get_lun(&ast_lun_map);
if (ast_sense(stp)) {
@@ -151,7 +151,13 @@ void
astdetach(struct atapi_softc *atp)
{
struct ast_softc *stp = atp->driver;
+ struct bio *bp;
+ while ((bp = bioq_first(&stp->queue))) {
+ bp->bio_error = ENXIO;
+ bp->bio_flags |= BIO_ERROR;
+ biodone(bp);
+ }
destroy_dev(stp->dev1);
destroy_dev(stp->dev2);
devstat_remove_entry(&stp->stats);
@@ -414,6 +420,13 @@ aststrategy(struct bio *bp)
struct ast_softc *stp = bp->bio_dev->si_drv1;
int s;
+ if (stp->atp->flags & ATAPI_F_DETACHING) {
+ bp->bio_error = ENXIO;
+ bp->bio_flags |= BIO_ERROR;
+ biodone(bp);
+ return;
+ }
+
/* if it's a null transfer, return immediatly. */
if (bp->bio_bcount == 0) {
bp->bio_resid = 0;
@@ -447,7 +460,7 @@ aststrategy(struct bio *bp)
}
s = splbio();
- bioq_insert_tail(&stp->bio_queue, bp);
+ bioq_insert_tail(&stp->queue, bp);
ata_start(stp->atp->controller);
splx(s);
}
@@ -456,7 +469,7 @@ void
ast_start(struct atapi_softc *atp)
{
struct ast_softc *stp = atp->driver;
- struct bio *bp = bioq_first(&stp->bio_queue);
+ struct bio *bp = bioq_first(&stp->queue);
u_int32_t blkcount;
int8_t ccb[16];
@@ -470,7 +483,7 @@ ast_start(struct atapi_softc *atp)
else
ccb[0] = ATAPI_WRITE;
- bioq_remove(&stp->bio_queue, bp);
+ bioq_remove(&stp->queue, bp);
blkcount = bp->bio_bcount / stp->blksize;
ccb[1] = 1;
OpenPOWER on IntegriCloud