lkml.org 
[lkml]   [2007]   [Sep]   [15]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateSat, 15 Sep 2007 01:39:13 -0700
FromAndrew Morton <>
SubjectRe: [PATCH] Add a refcount check in dput()
On Mon, 10 Sep 2007 15:13:19 -0700 (PDT) menage@google.com (Paul Menage) wrote:

> Add a BUG_ON() to check for passing an unreferenced dentry to dput().
> 
> This is analogous to the similar check in dget(), and will make
> reference-counting bugs in filesystems more immediately obvious. (I
> just spent a while debugging an oops that turned out to be due to
> broken fs reference counting.)
> 
> Signed-off-by: Paul Menage <menage@google.com>
> 
> ---
>  fs/dcache.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> Index: container-2.6.23-rc3-mm1/fs/dcache.c
> ===================================================================
> --- container-2.6.23-rc3-mm1.orig/fs/dcache.c
> +++ container-2.6.23-rc3-mm1/fs/dcache.c
> @@ -176,6 +176,7 @@ void dput(struct dentry *dentry)
>  	if (!dentry)
>  		return;
> 
> +	BUG_ON(!atomic_read(&dentry->d_count));
>  repeat:
>  	if (atomic_read(&dentry->d_count) == 1)
>  		might_sleep();

eek, much too aggressive.

I added this:

--- a/fs/dcache.c~add-a-refcount-check-in-dput
+++ a/fs/dcache.c
@@ -176,6 +176,7 @@ void dput(struct dentry *dentry)
 	if (!dentry)
 		return;
 
+	WARN_ON_ONCE(!atomic_read(&dentry->d_count));
 repeat:
 	if (atomic_read(&dentry->d_count) == 1)
 		might_sleep();
_
to the -mm-only-debugging-patches section of the -mm tree.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-09-15 10:41    [from the cache]
©2003-2008