From: Andrew Morton <akpm@linux-foundation.org>
To: menage@google.com (Paul Menage)
Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Add a refcount check in dput()
Date: Sat, 15 Sep 2007 01:39:13 -0700 [thread overview]
Message-ID: <20070915013913.880b4c70.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070910221319.302473D66CF@localhost>
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.
next prev parent reply other threads:[~2007-09-15 8:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-10 22:13 [PATCH] Add a refcount check in dput() Paul Menage
2007-09-15 8:39 ` Andrew Morton [this message]
2007-09-17 18:21 ` Paul Menage
2007-09-17 20:48 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070915013913.880b4c70.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox