Date: Sat, 17 May 2014 22:57:59 +0200 From: =?iso-8859-2?Q?Edward_Tomasz_Napiera=B3a?= <trasz@FreeBSD.org> To: Konstantin Belousov <kostikbel@gmail.com> Cc: freebsd-fs@freebsd.org, Benjamin Kaduk <bjk@freebsd.org> Subject: Re: Add an assert that v_holdcnt >= v_usecount? Message-ID: <071EBBB0-CDC5-47B6-A98C-5D4AD6A21855@FreeBSD.org> In-Reply-To: <20140517192229.GA74331@kib.kiev.ua> References: <alpine.GSO.1.10.1405171326480.25244@multics.mit.edu> <20140517192229.GA74331@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
Wiadomość napisana przez Konstantin Belousov w dniu 17 maj 2014, o godz. 21:22:
> 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.
In a filesystem that's already in the tree, or being developed by someone
who knows how VFS works - sure. But assertions like this are great time
saver for someone who is new to VFS.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?071EBBB0-CDC5-47B6-A98C-5D4AD6A21855>
