mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-15 15:06:42 +00:00
Exploit recent improvements in the disk minilayer to simplify error
handling a bit. Dogmatic lingupurists can celebrate that a number of gotos got removed. Reviewed by: mjacob, ken
This commit is contained in:
parent
e0e0b6610e
commit
b63170f870
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=76362
@ -1366,8 +1366,8 @@ cdstrategy(struct bio *bp)
|
||||
part = dkpart(bp->bio_dev);
|
||||
periph = cam_extend_get(cdperiphs, unit);
|
||||
if (periph == NULL) {
|
||||
bp->bio_error = ENXIO;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, ENXIO);
|
||||
return;
|
||||
}
|
||||
|
||||
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering cdstrategy\n"));
|
||||
@ -1386,8 +1386,8 @@ cdstrategy(struct bio *bp)
|
||||
*/
|
||||
if ((softc->flags & CD_FLAG_INVALID)) {
|
||||
splx(s);
|
||||
bp->bio_error = ENXIO;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, ENXIO);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1407,14 +1407,6 @@ cdstrategy(struct bio *bp)
|
||||
cdschedule(periph, /* priority */ 1);
|
||||
|
||||
return;
|
||||
bad:
|
||||
bp->bio_flags |= BIO_ERROR;
|
||||
/*
|
||||
* Correctly set the buf to indicate a completed xfer
|
||||
*/
|
||||
bp->bio_resid = bp->bio_bcount;
|
||||
biodone(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -555,8 +555,8 @@ dastrategy(struct bio *bp)
|
||||
part = dkpart(bp->bio_dev);
|
||||
periph = cam_extend_get(daperiphs, unit);
|
||||
if (periph == NULL) {
|
||||
bp->bio_error = ENXIO;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, ENXIO);
|
||||
return;
|
||||
}
|
||||
softc = (struct da_softc *)periph->softc;
|
||||
#if 0
|
||||
@ -578,8 +578,8 @@ dastrategy(struct bio *bp)
|
||||
*/
|
||||
if ((softc->flags & DA_FLAG_PACK_INVALID)) {
|
||||
splx(s);
|
||||
bp->bio_error = ENXIO;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, ENXIO);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -594,15 +594,6 @@ dastrategy(struct bio *bp)
|
||||
*/
|
||||
xpt_schedule(periph, /* XXX priority */1);
|
||||
|
||||
return;
|
||||
bad:
|
||||
bp->bio_flags |= BIO_ERROR;
|
||||
|
||||
/*
|
||||
* Correctly set the buf to indicate a completed xfer
|
||||
*/
|
||||
bp->bio_resid = bp->bio_bcount;
|
||||
biodone(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -223,9 +223,10 @@ ptstrategy(struct bio *bp)
|
||||
|
||||
unit = minor(bp->bio_dev);
|
||||
periph = cam_extend_get(ptperiphs, unit);
|
||||
bp->bio_resid = bp->bio_bcount;
|
||||
if (periph == NULL) {
|
||||
bp->bio_error = ENXIO;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, ENXIO);
|
||||
return;
|
||||
}
|
||||
softc = (struct pt_softc *)periph->softc;
|
||||
|
||||
@ -241,8 +242,8 @@ ptstrategy(struct bio *bp)
|
||||
*/
|
||||
if ((softc->flags & PT_FLAG_DEVICE_INVALID)) {
|
||||
splx(s);
|
||||
bp->bio_error = ENXIO;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, ENXIO);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -258,14 +259,6 @@ ptstrategy(struct bio *bp)
|
||||
xpt_schedule(periph, /* XXX priority */1);
|
||||
|
||||
return;
|
||||
bad:
|
||||
bp->bio_flags |= BIO_ERROR;
|
||||
|
||||
/*
|
||||
* Correctly set the buf to indicate a completed xfer
|
||||
*/
|
||||
bp->bio_resid = bp->bio_bcount;
|
||||
biodone(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -652,15 +652,16 @@ sastrategy(struct bio *bp)
|
||||
u_int unit;
|
||||
int s;
|
||||
|
||||
bp->bio_resid = bp->bio_bcount;
|
||||
if (SA_IS_CTRL(bp->bio_dev)) {
|
||||
bp->bio_error = EINVAL;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, EINVAL);
|
||||
return;
|
||||
}
|
||||
unit = SAUNIT(bp->bio_dev);
|
||||
periph = cam_extend_get(saperiphs, unit);
|
||||
if (periph == NULL) {
|
||||
bp->bio_error = ENXIO;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, ENXIO);
|
||||
return;
|
||||
}
|
||||
softc = (struct sa_softc *)periph->softc;
|
||||
|
||||
@ -668,14 +669,14 @@ sastrategy(struct bio *bp)
|
||||
|
||||
if (softc->flags & SA_FLAG_INVALID) {
|
||||
splx(s);
|
||||
bp->bio_error = ENXIO;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, ENXIO);
|
||||
return;
|
||||
}
|
||||
|
||||
if (softc->flags & SA_FLAG_TAPE_FROZEN) {
|
||||
splx(s);
|
||||
bp->bio_error = EPERM;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, EPERM);
|
||||
return;
|
||||
}
|
||||
|
||||
splx(s);
|
||||
@ -683,8 +684,10 @@ sastrategy(struct bio *bp)
|
||||
/*
|
||||
* If it's a null transfer, return immediatly
|
||||
*/
|
||||
if (bp->bio_bcount == 0)
|
||||
goto done;
|
||||
if (bp->bio_bcount == 0) {
|
||||
biodone(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
/* valid request? */
|
||||
if (softc->flags & SA_FLAG_FIXED) {
|
||||
@ -700,8 +703,8 @@ sastrategy(struct bio *bp)
|
||||
printf("Invalid request. Fixed block device "
|
||||
"requests must be a multiple "
|
||||
"of %d bytes\n", softc->min_blk);
|
||||
bp->bio_error = EINVAL;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, EINVAL);
|
||||
return;
|
||||
}
|
||||
} else if ((bp->bio_bcount > softc->max_blk) ||
|
||||
(bp->bio_bcount < softc->min_blk) ||
|
||||
@ -715,8 +718,8 @@ sastrategy(struct bio *bp)
|
||||
}
|
||||
printf("between %d and %d bytes\n", softc->min_blk,
|
||||
softc->max_blk);
|
||||
bp->bio_error = EINVAL;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, EINVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -745,15 +748,6 @@ sastrategy(struct bio *bp)
|
||||
xpt_schedule(periph, 1);
|
||||
|
||||
return;
|
||||
bad:
|
||||
bp->bio_flags |= BIO_ERROR;
|
||||
done:
|
||||
|
||||
/*
|
||||
* Correctly set the buf to indicate a completed xfer
|
||||
*/
|
||||
bp->bio_resid = bp->bio_bcount;
|
||||
biodone(bp);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1155,17 +1155,18 @@ targstrategy(struct bio *bp)
|
||||
int s;
|
||||
|
||||
unit = minor(bp->bio_dev);
|
||||
bp->bio_resid = bp->bio_bcount;
|
||||
|
||||
/* ioctl is the only supported operation of the control device */
|
||||
if (TARG_IS_CONTROL_DEV(unit)) {
|
||||
bp->bio_error = EINVAL;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, EINVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
periph = cam_extend_get(targperiphs, unit);
|
||||
if (periph == NULL) {
|
||||
bp->bio_error = ENXIO;
|
||||
goto bad;
|
||||
biofinish(bp, NULL, ENXIO);
|
||||
return;
|
||||
}
|
||||
softc = (struct targ_softc *)periph->softc;
|
||||
|
||||
@ -1183,10 +1184,11 @@ targstrategy(struct bio *bp)
|
||||
splx(s);
|
||||
if (softc->state == TARG_STATE_EXCEPTION
|
||||
&& (softc->exceptions & TARG_EXCEPT_DEVICE_INVALID) == 0)
|
||||
bp->bio_error = EBUSY;
|
||||
s = EBUSY;
|
||||
else
|
||||
bp->bio_error = ENXIO;
|
||||
goto bad;
|
||||
s = ENXIO;
|
||||
biofinish(bp, NULL, s);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1214,14 +1216,6 @@ targstrategy(struct bio *bp)
|
||||
targrunqueue(periph, softc);
|
||||
|
||||
return;
|
||||
bad:
|
||||
bp->bio_flags |= BIO_ERROR;
|
||||
|
||||
/*
|
||||
* Correctly set the buf to indicate a completed xfer
|
||||
*/
|
||||
bp->bio_resid = bp->bio_bcount;
|
||||
biodone(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user