vfs: add vholdnz (for already held vnodes)

Reviewed by:	kib (previous version)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21358
This commit is contained in:
mjg 2019-08-25 05:11:43 +00:00
parent 71ab388e98
commit 2ccfe33336
2 changed files with 14 additions and 0 deletions

View File

@ -3018,6 +3018,19 @@ _vhold(struct vnode *vp, bool locked)
VI_UNLOCK(vp);
}
void
vholdnz(struct vnode *vp)
{
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
#ifdef INVARIANTS
int old = atomic_fetchadd_int(&vp->v_holdcnt, 1);
VNASSERT(old > 0, vp, ("%s: wrong hold count", __func__));
#else
atomic_add_int(&vp->v_holdcnt, 1);
#endif
}
/*
* Drop the hold count of the vnode. If this is the last reference to
* the vnode we place it on the free list unless it has been vgone'd

View File

@ -657,6 +657,7 @@ void vgone(struct vnode *vp);
#define vhold(vp) _vhold((vp), 0)
#define vholdl(vp) _vhold((vp), 1)
void _vhold(struct vnode *, bool);
void vholdnz(struct vnode *);
void vinactive(struct vnode *, struct thread *);
int vinvalbuf(struct vnode *vp, int save, int slpflag, int slptimeo);
int vtruncbuf(struct vnode *vp, off_t length, int blksize);