Eliminate DEV_STRATEGY() macro: call dev_strategy() directly.

Make dev_strategy() handle errors and departing devices properly.
This commit is contained in:
Poul-Henning Kamp 2004-09-23 14:45:04 +00:00
parent ce655e042c
commit 1a52a73d68
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=135617
5 changed files with 16 additions and 25 deletions

View File

@ -476,7 +476,6 @@ static int
spec_xstrategy(struct vnode *vp, struct buf *bp)
{
struct mount *mp;
struct cdevsw *dsw;
struct thread *td = curthread;
KASSERT(bp->b_iocmd == BIO_READ || bp->b_iocmd == BIO_WRITE,
@ -508,23 +507,8 @@ spec_xstrategy(struct vnode *vp, struct buf *bp)
mp->mnt_stat.f_syncreads++;
}
}
dsw = devsw(bp->b_dev);
if (dsw == NULL) {
bp->b_error = ENXIO;
bp->b_ioflags |= BIO_ERROR;
bufdone(bp);
return (0);
}
KASSERT(dsw->d_strategy != NULL,
("No strategy on dev %s responsible for buffer %p\n",
devtoname(bp->b_dev), bp));
if (!(dsw->d_flags & D_NEEDGIANT)) {
/* XXX: notyet DROP_GIANT(); */
DEV_STRATEGY(bp);
/* XXX: notyet PICKUP_GIANT(); */
} else
DEV_STRATEGY(bp);
dev_strategy(bp);
return (0);
}

View File

@ -95,7 +95,7 @@ physio(struct cdev *dev, struct uio *uio, int ioflag)
goto doerror;
}
DEV_STRATEGY(bp);
dev_strategy(bp);
if (uio->uio_rw == UIO_READ)
bwait(bp, PRIBIO, "physrd");
else

View File

@ -1144,7 +1144,7 @@ aio_qphysio(struct proc *p, struct aiocblist *aiocbe)
splx(s);
/* Perform transfer. */
DEV_STRATEGY(bp);
dev_strategy(bp);
notify = 0;
s = splbio();

View File

@ -3105,14 +3105,23 @@ dev_strategy(struct buf *bp)
bp->b_io.bio_done = bufdonebio;
bp->b_io.bio_caller2 = bp;
dev = bp->b_io.bio_dev;
csw = devsw(dev);
KASSERT(dev->si_refcount > 0,
("dev_strategy on un-referenced struct cdev *(%s)",
devtoname(dev)));
dev_lock();
dev->si_threadcount++;
csw = devsw(dev);
if (csw != NULL)
dev->si_threadcount++;
dev_unlock();
(*devsw(bp->b_io.bio_dev)->d_strategy)(&bp->b_io);
if (csw == NULL) {
bp->b_error = ENXIO;
bp->b_ioflags = BIO_ERROR;
mtx_lock(&Giant); /* XXX: too defensive ? */
bufdone(bp);
mtx_unlock(&Giant); /* XXX: too defensive ? */
return;
}
(*csw->d_strategy)(&bp->b_io);
dev_lock();
dev->si_threadcount--;
dev_unlock();

View File

@ -160,8 +160,6 @@ typedef int dumper_t(
off_t offset, /* Byte-offset to write at. */
size_t length); /* Number of bytes to dump. */
#define DEV_STRATEGY(bp) dev_strategy(bp)
#endif /* _KERNEL */
/*