[PATCH 01/46] Revert "fs: use RCU read side protection in d_validate"

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Nick Piggin
Date: Saturday, November 27, 2010 - 2:56 am

This reverts commit 3825bdb7ed920845961f32f364454bee5f469abb.

Patch is broken, you can't dget() without holding any locks!

Signed-off-by: Nick Piggin <npiggin@kernel.dk>
---
 fs/dcache.c |   31 +++++++++++++++++++------------
 1 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 23702a9..cc2b938 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1491,26 +1491,33 @@ out:
  * This is used by ncpfs in its readdir implementation.
  * Zero is returned in the dentry is invalid.
  */
-int d_validate(struct dentry *dentry, struct dentry *parent)
+ 
+int d_validate(struct dentry *dentry, struct dentry *dparent)
 {
-	struct hlist_head *head = d_hash(parent, dentry->d_name.hash);
-	struct hlist_node *node;
-	struct dentry *d;
+	struct hlist_head *base;
+	struct hlist_node *lhp;
 
 	/* Check whether the ptr might be valid at all.. */
 	if (!kmem_ptr_validate(dentry_cache, dentry))
-		return 0;
-	if (dentry->d_parent != parent)
-		return 0;
+		goto out;
 
-	rcu_read_lock();
-	hlist_for_each_entry_rcu(d, node, head, d_hash) {
-		if (d == dentry) {
-			dget(dentry);
+	if (dentry->d_parent != dparent)
+		goto out;
+
+	spin_lock(&dcache_lock);
+	base = d_hash(dparent, dentry->d_name.hash);
+	hlist_for_each(lhp,base) { 
+		/* hlist_for_each_entry_rcu() not required for d_hash list
+		 * as it is parsed under dcache_lock
+		 */
+		if (dentry == hlist_entry(lhp, struct dentry, d_hash)) {
+			__dget_locked(dentry);
+			spin_unlock(&dcache_lock);
 			return 1;
 		}
 	}
-	rcu_read_unlock();
+	spin_unlock(&dcache_lock);
+out:
 	return 0;
 }
 EXPORT_SYMBOL(d_validate);
-- 
1.7.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 02/46] fs: d_validate fixes, Nick Piggin, (Sat Nov 27, 2:44 am)
[PATCH 08/46] fs: change d_compare for rcu-walk, Nick Piggin, (Sat Nov 27, 2:44 am)
[PATCH 09/46] fs: change d_hash for rcu-walk, Nick Piggin, (Sat Nov 27, 2:44 am)
[PATCH 10/46] hostfs: simplify locking, Nick Piggin, (Sat Nov 27, 2:44 am)
[PATCH 11/46] fs: dcache scale hash, Nick Piggin, (Sat Nov 27, 2:44 am)
[PATCH 15/46] fs: dcache scale subdirs, Nick Piggin, (Sat Nov 27, 2:44 am)
[PATCH 16/46] fs: scale inode alias list, Nick Piggin, (Sat Nov 27, 2:44 am)
[PATCH 23/46] fs: dcache reduce dcache_inode_lock, Nick Piggin, (Sat Nov 27, 2:44 am)
[PATCH 30/46] fs: icache RCU free inodes, Nick Piggin, (Sat Nov 27, 2:45 am)
[PATCH 35/46] fs: dcache remove d_mounted, Nick Piggin, (Sat Nov 27, 2:45 am)
[PATCH 45/46] fs: dcache per-inode inode alias locking, Nick Piggin, (Sat Nov 27, 2:45 am)
[PATCH 01/46] Revert "fs: use RCU read side protection in ..., Nick Piggin, (Sat Nov 27, 2:56 am)
[PATCH 00/46] rcu-walk and dcache scaling, Nick Piggin, (Sat Nov 27, 3:15 am)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Anca Emanuel, (Sat Nov 27, 8:04 am)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Nick Piggin, (Sat Nov 27, 8:28 pm)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Sedat Dilek, (Sat Nov 27, 11:24 pm)
Re: [PATCH 00/46] rcu-walk and dcache scaling, David Miller, (Wed Dec 1, 11:03 am)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Nick Piggin, (Fri Dec 3, 9:55 am)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Nick Piggin, (Tue Dec 7, 8:24 am)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Peter Zijlstra, (Tue Dec 7, 8:49 am)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Nick Piggin, (Tue Dec 7, 8:59 am)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Peter Zijlstra, (Tue Dec 7, 9:23 am)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Dave Chinner, (Tue Dec 7, 2:56 pm)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Nick Piggin, (Tue Dec 7, 6:47 pm)
Re: [PATCH 02/46] fs: d_validate fixes, Dave Chinner, (Tue Dec 7, 6:53 pm)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Nick Piggin, (Tue Dec 7, 8:28 pm)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Dave Chinner, (Tue Dec 7, 8:32 pm)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Dave Chinner, (Tue Dec 7, 9:28 pm)
Re: [PATCH 02/46] fs: d_validate fixes, Nick Piggin, (Tue Dec 7, 11:59 pm)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Nick Piggin, (Wed Dec 8, 12:09 am)
Re: [PATCH 02/46] fs: d_validate fixes, Dave Chinner, (Wed Dec 8, 5:50 pm)
Re: [PATCH 02/46] fs: d_validate fixes, Nick Piggin, (Wed Dec 8, 9:50 pm)
Re: [PATCH 11/46] fs: dcache scale hash, Dave Chinner, (Wed Dec 8, 11:09 pm)
Re: [PATCH 11/46] fs: dcache scale hash, Nick Piggin, (Wed Dec 8, 11:28 pm)
Re: [PATCH 11/46] fs: dcache scale hash, Dave Chinner, (Thu Dec 9, 1:17 am)
Re: [PATCH 11/46] fs: dcache scale hash, Nick Piggin, (Thu Dec 9, 5:53 am)
Re: [PATCH 11/46] fs: dcache scale hash, Dave Chinner, (Thu Dec 9, 4:42 pm)
Re: [PATCH 11/46] fs: dcache scale hash, Nick Piggin, (Thu Dec 9, 7:35 pm)
Re: [PATCH 11/46] fs: dcache scale hash, Dave Chinner, (Fri Dec 10, 2:01 am)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Paul E. McKenney, (Fri Dec 10, 1:32 pm)
Re: [PATCH 00/46] rcu-walk and dcache scaling, Paul E. McKenney, (Sun Dec 12, 7:54 am)
Re: [PATCH 11/46] fs: dcache scale hash, Nick Piggin, (Sun Dec 12, 9:48 pm)
Re: [PATCH 11/46] fs: dcache scale hash, Nick Piggin, (Sun Dec 12, 10:05 pm)