Add an assert that v_holdcnt >= v_usecount?
Benjamin Kaduk
bjk at freebsd.org
Sat May 17 17:53:24 UTC 2014
jhb was helping me debug a crashy openafs build in one of my VMs, and the
symptoms seemed to indicate that a vnode had been partially destroyed
before vgone() was called from vflush(), as if some buggy filesystem code
had called vdrop() instead of vrele() or something similar. In a quick
check, it didn't look like we had any assertions that would catch such
bugs, so I tried adding something like this:
Index: sys/kern/vfs_subr.c
===================================================================
--- sys/kern/vfs_subr.c (revision 266330)
+++ sys/kern/vfs_subr.c (working copy)
@@ -2343,6 +2343,8 @@
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;
Does that seem like something that would be generally useful?
-Ben
More information about the freebsd-fs
mailing list