Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 226716
b: refs/heads/master
c: a734eb4
h: refs/heads/master
v: v3
  • Loading branch information
Nick Piggin committed Jan 7, 2011
1 parent f106927 commit 0332d1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dc0474be3e27463d4d4a2793f82366eed906f223
refs/heads/master: a734eb458ab2bd11479a27dd54f48e1b26a55845
21 changes: 12 additions & 9 deletions trunk/fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,24 +446,27 @@ struct dentry *dget_parent(struct dentry *dentry)
struct dentry *ret;

repeat:
spin_lock(&dentry->d_lock);
/*
* Don't need rcu_dereference because we re-check it was correct under
* the lock.
*/
rcu_read_lock();
ret = dentry->d_parent;
if (!ret)
goto out;
if (dentry == ret) {
ret->d_count++;
if (!ret) {
rcu_read_unlock();
goto out;
}
if (!spin_trylock(&ret->d_lock)) {
spin_unlock(&dentry->d_lock);
cpu_relax();
spin_lock(&ret->d_lock);
if (unlikely(ret != dentry->d_parent)) {
spin_unlock(&ret->d_lock);
rcu_read_unlock();
goto repeat;
}
rcu_read_unlock();
BUG_ON(!ret->d_count);
ret->d_count++;
spin_unlock(&ret->d_lock);
out:
spin_unlock(&dentry->d_lock);
return ret;
}
EXPORT_SYMBOL(dget_parent);
Expand Down

0 comments on commit 0332d1b

Please sign in to comment.