[PATCH] Add a refcount check in dput()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Paul Menage
Date: Monday, September 10, 2007 - 3:13 pm

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();
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Add a refcount check in dput(), Paul Menage, (Mon Sep 10, 3:13 pm)
Re: [PATCH] Add a refcount check in dput(), Andrew Morton, (Sat Sep 15, 1:39 am)
Re: [PATCH] Add a refcount check in dput(), Paul Menage, (Mon Sep 17, 11:21 am)
Re: [PATCH] Add a refcount check in dput(), Andrew Morton, (Mon Sep 17, 1:48 pm)