From: menage@google.com (Paul Menage) Add a WARN_ON_ONCE() 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 Signed-off-by: Andrew Morton --- fs/dcache.c | 1 + 1 file changed, 1 insertion(+) diff -puN fs/dcache.c~add-a-refcount-check-in-dput fs/dcache.c --- a/fs/dcache.c~add-a-refcount-check-in-dput +++ a/fs/dcache.c @@ -213,6 +213,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(); _