From 867fd730c6c54863c8c23fab93f5ab13f06342ce Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sun, 5 Jan 2020 00:59:16 +0000 Subject: [PATCH] vfs: patch up vnode count assertions to report found value --- sys/kern/vfs_subr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index b1f745e1e14..5ff6e5b9b16 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -2846,8 +2846,8 @@ vget_finish(struct vnode *vp, int flags, enum vgetstate vs) */ if (refcount_acquire_if_not_zero(&vp->v_usecount)) { #ifdef INVARIANTS - int old = atomic_fetchadd_int(&vp->v_holdcnt, -1) - 1; - VNASSERT(old > 0, vp, ("%s: wrong hold count", __func__)); + int 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 @@ -2872,8 +2872,8 @@ vget_finish(struct vnode *vp, int flags, enum vgetstate vs) */ if (refcount_acquire_if_not_zero(&vp->v_usecount)) { #ifdef INVARIANTS - int old = atomic_fetchadd_int(&vp->v_holdcnt, -1) - 1; - VNASSERT(old > 0, vp, ("%s: wrong hold count", __func__)); + int 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 @@ -2953,7 +2953,7 @@ vrefact(struct vnode *vp) CTR2(KTR_VFS, "%s: vp %p", __func__, vp); #ifdef INVARIANTS int old = atomic_fetchadd_int(&vp->v_usecount, 1); - VNASSERT(old > 0, vp, ("%s: wrong use count", __func__)); + VNASSERT(old > 0, vp, ("%s: wrong use count %d", __func__, old)); #else refcount_acquire(&vp->v_usecount); #endif @@ -3189,7 +3189,7 @@ 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__)); + VNASSERT(old > 0, vp, ("%s: wrong hold count %d", __func__, old)); #else atomic_add_int(&vp->v_holdcnt, 1); #endif