Eliminate DEV_STRATEGY() macro: call dev_strategy() directly.
Make dev_strategy() handle errors and departing devices properly.
This commit is contained in:
parent
ce655e042c
commit
1a52a73d68
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=135617
@ -476,7 +476,6 @@ static int
|
|||||||
spec_xstrategy(struct vnode *vp, struct buf *bp)
|
spec_xstrategy(struct vnode *vp, struct buf *bp)
|
||||||
{
|
{
|
||||||
struct mount *mp;
|
struct mount *mp;
|
||||||
struct cdevsw *dsw;
|
|
||||||
struct thread *td = curthread;
|
struct thread *td = curthread;
|
||||||
|
|
||||||
KASSERT(bp->b_iocmd == BIO_READ || bp->b_iocmd == BIO_WRITE,
|
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++;
|
mp->mnt_stat.f_syncreads++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dsw = devsw(bp->b_dev);
|
|
||||||
if (dsw == NULL) {
|
dev_strategy(bp);
|
||||||
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);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ physio(struct cdev *dev, struct uio *uio, int ioflag)
|
|||||||
goto doerror;
|
goto doerror;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEV_STRATEGY(bp);
|
dev_strategy(bp);
|
||||||
if (uio->uio_rw == UIO_READ)
|
if (uio->uio_rw == UIO_READ)
|
||||||
bwait(bp, PRIBIO, "physrd");
|
bwait(bp, PRIBIO, "physrd");
|
||||||
else
|
else
|
||||||
|
@ -1144,7 +1144,7 @@ aio_qphysio(struct proc *p, struct aiocblist *aiocbe)
|
|||||||
splx(s);
|
splx(s);
|
||||||
|
|
||||||
/* Perform transfer. */
|
/* Perform transfer. */
|
||||||
DEV_STRATEGY(bp);
|
dev_strategy(bp);
|
||||||
|
|
||||||
notify = 0;
|
notify = 0;
|
||||||
s = splbio();
|
s = splbio();
|
||||||
|
@ -3105,14 +3105,23 @@ dev_strategy(struct buf *bp)
|
|||||||
bp->b_io.bio_done = bufdonebio;
|
bp->b_io.bio_done = bufdonebio;
|
||||||
bp->b_io.bio_caller2 = bp;
|
bp->b_io.bio_caller2 = bp;
|
||||||
dev = bp->b_io.bio_dev;
|
dev = bp->b_io.bio_dev;
|
||||||
csw = devsw(dev);
|
|
||||||
KASSERT(dev->si_refcount > 0,
|
KASSERT(dev->si_refcount > 0,
|
||||||
("dev_strategy on un-referenced struct cdev *(%s)",
|
("dev_strategy on un-referenced struct cdev *(%s)",
|
||||||
devtoname(dev)));
|
devtoname(dev)));
|
||||||
dev_lock();
|
dev_lock();
|
||||||
dev->si_threadcount++;
|
csw = devsw(dev);
|
||||||
|
if (csw != NULL)
|
||||||
|
dev->si_threadcount++;
|
||||||
dev_unlock();
|
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_lock();
|
||||||
dev->si_threadcount--;
|
dev->si_threadcount--;
|
||||||
dev_unlock();
|
dev_unlock();
|
||||||
|
@ -160,8 +160,6 @@ typedef int dumper_t(
|
|||||||
off_t offset, /* Byte-offset to write at. */
|
off_t offset, /* Byte-offset to write at. */
|
||||||
size_t length); /* Number of bytes to dump. */
|
size_t length); /* Number of bytes to dump. */
|
||||||
|
|
||||||
#define DEV_STRATEGY(bp) dev_strategy(bp)
|
|
||||||
|
|
||||||
#endif /* _KERNEL */
|
#endif /* _KERNEL */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user