summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-03-10 20:56:28 +0000
committerphk <phk@FreeBSD.org>2004-03-10 20:56:28 +0000
commit263999b14d714a98d600885cba9f4a7c43a567ec (patch)
treef360b628b2e93cde720868f754d8bed43705f3ba
parent5b6d5b3f4b105ca4a7229e76895304e038457dcb (diff)
downloadFreeBSD-src-263999b14d714a98d600885cba9f4a7c43a567ec.zip
FreeBSD-src-263999b14d714a98d600885cba9f4a7c43a567ec.tar.gz
Don't call devsw() more than we need to, and in particular do not expose
ourselves to device removal by not checking for it the second time. Use count_dev(dev) rather than vcount(vp)
-rw-r--r--sys/fs/specfs/spec_vnops.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c
index 4fc0553..97c3804 100644
--- a/sys/fs/specfs/spec_vnops.c
+++ b/sys/fs/specfs/spec_vnops.c
@@ -517,13 +517,13 @@ spec_xstrategy(struct vnode *vp, struct buf *bp)
mp->mnt_stat.f_syncreads++;
}
}
- if (devsw(bp->b_dev) == NULL) {
+ dsw = devsw(bp->b_dev);
+ if (dsw == NULL) {
bp->b_io.bio_error = ENXIO;
bp->b_io.bio_flags |= BIO_ERROR;
biodone(&bp->b_io);
return (0);
}
- dsw = devsw(bp->b_dev);
KASSERT(dsw->d_strategy != NULL,
("No strategy on dev %s responsible for buffer %p\n",
devtoname(bp->b_dev), bp));
@@ -621,7 +621,7 @@ spec_close(ap)
if (td && vp == td->td_proc->p_session->s_ttyvp) {
SESS_LOCK(td->td_proc->p_session);
VI_LOCK(vp);
- if (vcount(vp) == 2 && (vp->v_iflag & VI_XLOCK) == 0) {
+ if (count_dev(dev) == 2 && (vp->v_iflag & VI_XLOCK) == 0) {
td->td_proc->p_session->s_ttyvp = NULL;
oldvp = vp;
}
@@ -645,7 +645,7 @@ spec_close(ap)
/* Forced close. */
} else if (dsw->d_flags & D_TRACKCLOSE) {
/* Keep device updated on status. */
- } else if (vcount(vp) > 1) {
+ } else if (count_dev(dev) > 1) {
VI_UNLOCK(vp);
return (0);
}
OpenPOWER on IntegriCloud