Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 May 2014 13:48:11 -0400 (EDT)
From:      Benjamin Kaduk <bjk@freebsd.org>
To:        freebsd-fs@freebsd.org
Subject:   Add an assert that v_holdcnt >= v_usecount?
Message-ID:  <alpine.GSO.1.10.1405171326480.25244@multics.mit.edu>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.GSO.1.10.1405171326480.25244>