diff options
author | Nick Piggin <npiggin@kernel.dk> | 2011-01-07 09:49:44 +0300 |
---|---|---|
committer | Nick Piggin <npiggin@kernel.dk> | 2011-01-07 09:50:24 +0300 |
commit | a734eb458ab2bd11479a27dd54f48e1b26a55845 (patch) | |
tree | 425f6173d63a58ec719147764300bb324e1d53e3 | |
parent | dc0474be3e27463d4d4a2793f82366eed906f223 (diff) | |
download | linux-a734eb458ab2bd11479a27dd54f48e1b26a55845.tar.xz |
fs: dcache reduce d_parent locking
Use RCU to simplify locking in dget_parent.
Signed-off-by: Nick Piggin <npiggin@kernel.dk>
-rw-r--r-- | fs/dcache.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index b4d2e28eef5b..a8f89765d602 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -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); |