vfs: tidy up vdrop
Skip vfs_refcount_release_if_not_last if the interlock is held and just go straight to refcount_release. While here do cosmetic rearrangement of _vhold to better show it contains equivalent behaviour.
This commit is contained in:
parent
504d9b6029
commit
31c2c6e95e
@ -2840,14 +2840,14 @@ _vhold(struct vnode *vp, bool locked)
|
||||
else
|
||||
ASSERT_VI_UNLOCKED(vp, __func__);
|
||||
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
|
||||
if (!locked && vfs_refcount_acquire_if_not_zero(&vp->v_holdcnt)) {
|
||||
if (!locked) {
|
||||
if (vfs_refcount_acquire_if_not_zero(&vp->v_holdcnt)) {
|
||||
VNASSERT((vp->v_iflag & VI_FREE) == 0, vp,
|
||||
("_vhold: vnode with holdcnt is free"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!locked)
|
||||
VI_LOCK(vp);
|
||||
}
|
||||
if ((vp->v_iflag & VI_FREE) == 0) {
|
||||
refcount_acquire(&vp->v_holdcnt);
|
||||
if (!locked)
|
||||
@ -2911,14 +2911,11 @@ _vdrop(struct vnode *vp, bool locked)
|
||||
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
|
||||
if ((int)vp->v_holdcnt <= 0)
|
||||
panic("vdrop: holdcnt %d", vp->v_holdcnt);
|
||||
if (vfs_refcount_release_if_not_last(&vp->v_holdcnt)) {
|
||||
if (locked)
|
||||
VI_UNLOCK(vp);
|
||||
if (!locked) {
|
||||
if (vfs_refcount_release_if_not_last(&vp->v_holdcnt))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!locked)
|
||||
VI_LOCK(vp);
|
||||
}
|
||||
if (refcount_release(&vp->v_holdcnt) == 0) {
|
||||
VI_UNLOCK(vp);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user