mirror of https://gitee.com/openkylin/linux.git
Revert "fs: use RCU read side protection in d_validate"
This reverts commit 3825bdb7ed
.
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>
This commit is contained in:
parent
3c0eee3fe6
commit
d3a23e1678
31
fs/dcache.c
31
fs/dcache.c
|
@ -1491,26 +1491,33 @@ struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name)
|
||||||
* This is used by ncpfs in its readdir implementation.
|
* This is used by ncpfs in its readdir implementation.
|
||||||
* Zero is returned in the dentry is invalid.
|
* 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_head *base;
|
||||||
struct hlist_node *node;
|
struct hlist_node *lhp;
|
||||||
struct dentry *d;
|
|
||||||
|
|
||||||
/* Check whether the ptr might be valid at all.. */
|
/* Check whether the ptr might be valid at all.. */
|
||||||
if (!kmem_ptr_validate(dentry_cache, dentry))
|
if (!kmem_ptr_validate(dentry_cache, dentry))
|
||||||
return 0;
|
goto out;
|
||||||
if (dentry->d_parent != parent)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
rcu_read_lock();
|
if (dentry->d_parent != dparent)
|
||||||
hlist_for_each_entry_rcu(d, node, head, d_hash) {
|
goto out;
|
||||||
if (d == dentry) {
|
|
||||||
dget(dentry);
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rcu_read_unlock();
|
spin_unlock(&dcache_lock);
|
||||||
|
out:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(d_validate);
|
EXPORT_SYMBOL(d_validate);
|
||||||
|
|
Loading…
Reference in New Issue