vfs: move si_usecount manipulation to dedicated functions

Reviewed by:	kib
This commit is contained in:
Mateusz Guzik 2015-07-11 16:28:12 +00:00
parent 8a08cec166
commit 2d1ca3cdff
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285392

View File

@ -105,6 +105,8 @@ static void v_incr_usecount(struct vnode *);
static void v_decr_usecount(struct vnode *);
static void v_decr_useonly(struct vnode *);
static void v_upgrade_usecount(struct vnode *);
static void v_incr_devcount(struct vnode *);
static void v_decr_devcount(struct vnode *);
static void vnlru_free(int);
static void vgonel(struct vnode *);
static void vfs_knllock(void *arg);
@ -2082,11 +2084,7 @@ v_incr_usecount(struct vnode *vp)
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
vholdl(vp);
vp->v_usecount++;
if (vp->v_type == VCHR && vp->v_rdev != NULL) {
dev_lock();
vp->v_rdev->si_usecount++;
dev_unlock();
}
v_incr_devcount(vp);
}
/*
@ -2099,11 +2097,7 @@ v_upgrade_usecount(struct vnode *vp)
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
vp->v_usecount++;
if (vp->v_type == VCHR && vp->v_rdev != NULL) {
dev_lock();
vp->v_rdev->si_usecount++;
dev_unlock();
}
v_incr_devcount(vp);
}
/*
@ -2120,11 +2114,7 @@ v_decr_usecount(struct vnode *vp)
("v_decr_usecount: negative usecount"));
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
vp->v_usecount--;
if (vp->v_type == VCHR && vp->v_rdev != NULL) {
dev_lock();
vp->v_rdev->si_usecount--;
dev_unlock();
}
v_decr_devcount(vp);
vdropl(vp);
}
@ -2143,6 +2133,36 @@ v_decr_useonly(struct vnode *vp)
("v_decr_useonly: negative usecount"));
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
vp->v_usecount--;
v_decr_devcount(vp);
}
/*
* Increment si_usecount of the associated device, if any.
*/
static void
v_incr_devcount(struct vnode *vp)
{
#ifdef INVARIANTS
/* getnewvnode() calls v_incr_usecount() without holding interlock. */
if (vp->v_type != VNON || vp->v_data != NULL)
ASSERT_VI_LOCKED(vp, __FUNCTION__);
#endif
if (vp->v_type == VCHR && vp->v_rdev != NULL) {
dev_lock();
vp->v_rdev->si_usecount++;
dev_unlock();
}
}
/*
* Decrement si_usecount of the associated device, if any.
*/
static void
v_decr_devcount(struct vnode *vp)
{
ASSERT_VI_LOCKED(vp, __FUNCTION__);
if (vp->v_type == VCHR && vp->v_rdev != NULL) {
dev_lock();
vp->v_rdev->si_usecount--;