summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_subr.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-02-21 21:57:26 +0000
committerphk <phk@FreeBSD.org>2004-02-21 21:57:26 +0000
commit5551e292d8b6185cfd720b86e124a883103cfc15 (patch)
treed076858b5e5f94786b0a38e000ef6c98a01e7a00 /sys/kern/vfs_subr.c
parent39fb4aef3d058a6d6726a689f365d2c8a3333178 (diff)
downloadFreeBSD-src-5551e292d8b6185cfd720b86e124a883103cfc15.zip
FreeBSD-src-5551e292d8b6185cfd720b86e124a883103cfc15.tar.gz
Device megapatch 6/6:
This is what we came here for: Hang dev_t's from their cdevsw, refcount cdevsw and dev_t and generally keep track of things a lot better than we used to: Hold a cdevsw reference around all entrances into the device driver, this will be necessary to safely determine when we can unload driver code. Hold a dev_t reference while the device is open. KASSERT that we do not enter the driver on a non-referenced dev_t. Remove old D_NAG code, anonymous dev_t's are not a problem now. When destroy_dev() is called on a referenced dev_t, move it to dead_cdevsw's list. When the refcount drops, free it. Check that cdevsw->d_version is correct. If not, set all methods to the dead_*() methods to prevent entrance into driver. Print warning on console to this effect. The device driver may still explode if it is also incompatible with newbus, but in that case we probably didn't get this far in the first place.
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r--sys/kern/vfs_subr.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index bcf7af8..e43c78a 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1853,6 +1853,7 @@ addalias(nvp, dev)
{
KASSERT(nvp->v_type == VCHR, ("addalias on non-special vnode"));
+ dev_ref(dev);
nvp->v_rdev = dev;
VI_LOCK(nvp);
mtx_lock(&spechash_mtx);
@@ -2469,7 +2470,7 @@ vop_revoke(ap)
mtx_lock(&spechash_mtx);
vq = SLIST_FIRST(&dev->si_hlist);
mtx_unlock(&spechash_mtx);
- if (!vq)
+ if (vq == NULL)
break;
vgone(vq);
}
@@ -2587,11 +2588,12 @@ vgonel(vp, td)
* if it is on one.
*/
VI_LOCK(vp);
- if (vp->v_type == VCHR && vp->v_rdev != NULL && vp->v_rdev != NODEV) {
+ if (vp->v_type == VCHR && vp->v_rdev != NODEV) {
mtx_lock(&spechash_mtx);
SLIST_REMOVE(&vp->v_rdev->si_hlist, vp, vnode, v_specnext);
vp->v_rdev->si_usecount -= vp->v_usecount;
mtx_unlock(&spechash_mtx);
+ dev_rel(vp->v_rdev);
vp->v_rdev = NULL;
}
OpenPOWER on IntegriCloud