aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-10-10 05:36:27 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2010-10-25 21:26:13 -0400
commit3825bdb7ed920845961f32f364454bee5f469abb (patch)
tree935f4d42ff568efd595700889a1839a604aa8cec /fs
parenta4633357ac610cd2f8740e28a31fc148a7960421 (diff)
fs: use RCU read side protection in d_validate
d_validate does a purely read lookup in the dentry hash, so use RCU read side locking instead of dcache_lock. Split out from a larget patch by Nick Piggin <npiggin@suse.de>. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/dcache.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index cc2b93802179..23702a9d4e6d 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1491,33 +1491,26 @@ 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 */
1494 1494int d_validate(struct dentry *dentry, struct dentry *parent)
1495int d_validate(struct dentry *dentry, struct dentry *dparent)
1496{ 1495{
1497 struct hlist_head *base; 1496 struct hlist_head *head = d_hash(parent, dentry->d_name.hash);
1498 struct hlist_node *lhp; 1497 struct hlist_node *node;
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 goto out; 1502 return 0;
1503 1503 if (dentry->d_parent != parent)
1504 if (dentry->d_parent != dparent) 1504 return 0;
1505 goto out;
1506 1505
1507 spin_lock(&dcache_lock); 1506 rcu_read_lock();
1508 base = d_hash(dparent, dentry->d_name.hash); 1507 hlist_for_each_entry_rcu(d, node, head, d_hash) {
1509 hlist_for_each(lhp,base) { 1508 if (d == dentry) {
1510 /* hlist_for_each_entry_rcu() not required for d_hash list 1509 dget(dentry);
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);
1516 return 1; 1510 return 1;
1517 } 1511 }
1518 } 1512 }
1519 spin_unlock(&dcache_lock); 1513 rcu_read_unlock();
1520out:
1521 return 0; 1514 return 0;
1522} 1515}
1523EXPORT_SYMBOL(d_validate); 1516EXPORT_SYMBOL(d_validate);