Check for mismatched vref()/vdrop()

Assert that the hold count has not fallen below the use count, a situation
that would only happen when a vref() (or similar) is erroneously paired
with a vdrop().  This situation has not been observed in the wild, but
could be helpful for someone implementing a new filesystem.

Reviewed by:	kib
Approved by:	hrs (mentor)
This commit is contained in:
Benjamin Kaduk 2014-05-21 03:11:27 +00:00
parent 96d67b46df
commit bf09eca2cb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=266482

View File

@ -2343,6 +2343,8 @@ vdropl(struct vnode *vp)
if (vp->v_holdcnt <= 0)
panic("vdrop: holdcnt %d", vp->v_holdcnt);
vp->v_holdcnt--;
VNASSERT(vp->v_holdcnt >= vp->v_usecount, vp,
("hold count less than use count"));
if (vp->v_holdcnt > 0) {
VI_UNLOCK(vp);
return;