diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/dcache.c | 31 |
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 | 1494 | int d_validate(struct dentry *dentry, struct dentry *parent) | |
1495 | int 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(); |
1520 | out: | ||
1521 | return 0; | 1514 | return 0; |
1522 | } | 1515 | } |
1523 | EXPORT_SYMBOL(d_validate); | 1516 | EXPORT_SYMBOL(d_validate); |