Add an assert that v_holdcnt >= v_usecount?
Konstantin Belousov
kostikbel at gmail.com
Sat May 17 19:22:39 UTC 2014
On Sat, May 17, 2014 at 01:48:11PM -0400, Benjamin Kaduk wrote:
> 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?
This is reasonable.
As a note, I never seen such corruption of the otherwise valid vnode state
ever. There were a lot of leaks, but never mismatched vget/vdrop.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20140517/3aedac77/attachment.sig>
More information about the freebsd-fs
mailing list