vfs: reimplement vref on top of vget
No change in generated assembly.
This commit is contained in:
+3
-25
@@ -2920,36 +2920,14 @@ vget_finish_ref(struct vnode *vp, enum vgetstate vs)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Increase the reference (use) and hold count of a vnode.
|
||||
* This will also remove the vnode from the free list if it is presently free.
|
||||
*/
|
||||
void
|
||||
vref(struct vnode *vp)
|
||||
{
|
||||
int old;
|
||||
enum vgetstate vs;
|
||||
|
||||
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
|
||||
if (refcount_acquire_if_not_zero(&vp->v_usecount)) {
|
||||
VNODE_REFCOUNT_FENCE_ACQ();
|
||||
VNASSERT(vp->v_holdcnt > 0, vp,
|
||||
("%s: active vnode not held", __func__));
|
||||
return;
|
||||
}
|
||||
vhold(vp);
|
||||
/*
|
||||
* See the comment in vget_finish.
|
||||
*/
|
||||
old = atomic_fetchadd_int(&vp->v_usecount, 1);
|
||||
VNASSERT(old >= 0, vp, ("%s: wrong use count %d", __func__, old));
|
||||
if (old != 0) {
|
||||
#ifdef INVARIANTS
|
||||
old = atomic_fetchadd_int(&vp->v_holdcnt, -1);
|
||||
VNASSERT(old > 1, vp, ("%s: wrong hold count %d", __func__, old));
|
||||
#else
|
||||
refcount_release(&vp->v_holdcnt);
|
||||
#endif
|
||||
}
|
||||
vs = vget_prep(vp);
|
||||
vget_finish_ref(vp, vs);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user