From 0332d1bd067112143fcc7c997835268c0dd909c0 Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 7 Jan 2011 17:49:44 +1100 Subject: [PATCH] --- yaml --- r: 226716 b: refs/heads/master c: a734eb458ab2bd11479a27dd54f48e1b26a55845 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/dcache.c | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/[refs] b/[refs] index d8cc70e99f98..1a8da51dd54d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: dc0474be3e27463d4d4a2793f82366eed906f223 +refs/heads/master: a734eb458ab2bd11479a27dd54f48e1b26a55845 diff --git a/trunk/fs/dcache.c b/trunk/fs/dcache.c index b4d2e28eef5b..a8f89765d602 100644 --- a/trunk/fs/dcache.c +++ b/trunk/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);