aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Piggin <npiggin@kernel.dk>2011-01-05 04:01:21 -0500
committerNick Piggin <npiggin@kernel.dk>2011-01-05 04:01:21 -0500
commitd3a23e1678a5827c38ed8a465ad91d65e59fa911 (patch)
tree44363edff14c1796a634825f07decc2324d7e6e0
parent3c0eee3fe6a3a1c745379547c7e7c904aa64f6d5 (diff)
Revert "fs: use RCU read side protection in d_validate"
This reverts commit 3825bdb7ed920845961f32f364454bee5f469abb. You cannot dget() a dentry without having a reference, or holding a lock that guarantees it remains valid. Signed-off-by: Nick Piggin <npiggin@kernel.dk>
-rw-r--r--fs/dcache.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 23702a9d4e6d..cc2b93802179 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1491,26 +1491,33 @@ out:
1491 * This is used by ncpfs in its readdir implementation. 1491 * This is used by ncpfs in its readdir implementation.
1492 * Zero is returned in the dentry is invalid. 1492 * Zero is returned in the dentry is invalid.
1493 */ 1493 */
1494int d_validate(struct dentry *dentry, struct dentry *parent) 1494
1495int d_validate(struct dentry *dentry, struct dentry *dparent)
1495{ 1496{
1496 struct hlist_head *head = d_hash(parent, dentry->d_name.hash); 1497 struct hlist_head *base;
1497 struct hlist_node *node; 1498 struct hlist_node *lhp;
1498 struct dentry *d;
1499 1499
1500 /* Check whether the ptr might be valid at all.. */ 1500 /* Check whether the ptr might be valid at all.. */
1501 if (!kmem_ptr_validate(dentry_cache, dentry)) 1501 if (!kmem_ptr_validate(dentry_cache, dentry))
1502 return 0; 1502 goto out;
1503 if (dentry->d_parent != parent)
1504 return 0;
1505 1503
1506 rcu_read_lock(); 1504 if (dentry->d_parent != dparent)
1507 hlist_for_each_entry_rcu(d, node, head, d_hash) { 1505 goto out;
1508 if (d == dentry) { 1506
1509 dget(dentry); 1507 spin_lock(&dcache_lock);
1508 base = d_hash(dparent, dentry->d_name.hash);
1509 hlist_for_each(lhp,base) {
1510 /* hlist_for_each_entry_rcu() not required for d_hash list
1511 * as it is parsed under dcache_lock
1512 */
1513 if (dentry == hlist_entry(lhp, struct dentry, d_hash)) {
1514 __dget_locked(dentry);
1515 spin_unlock(&dcache_lock);
1510 return 1; 1516 return 1;
1511 } 1517 }
1512 } 1518 }
1513 rcu_read_unlock(); 1519 spin_unlock(&dcache_lock);
1520out:
1514 return 0; 1521 return 0;
1515} 1522}
1516EXPORT_SYMBOL(d_validate); 1523EXPORT_SYMBOL(d_validate);