From 2391618e08f43e2d64013ac9a32e3cc7fa45e92c Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 7 Jan 2011 17:49:45 +1100 Subject: [PATCH] --- yaml --- r: 226717 b: refs/heads/master c: 89e6054836a7b1e7500cd70a14b5579e752c9250 h: refs/heads/master i: 226715: f10692791b6459ee3a3d88a78e09617e254aad1e v: v3 --- [refs] | 2 +- trunk/fs/dcache.c | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/[refs] b/[refs] index 1a8da51dd54d..93c6a7461a73 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a734eb458ab2bd11479a27dd54f48e1b26a55845 +refs/heads/master: 89e6054836a7b1e7500cd70a14b5579e752c9250 diff --git a/trunk/fs/dcache.c b/trunk/fs/dcache.c index a8f89765d602..195706374697 100644 --- a/trunk/fs/dcache.c +++ b/trunk/fs/dcache.c @@ -582,26 +582,29 @@ static void prune_one_dentry(struct dentry *dentry, struct dentry *parent) * Prune ancestors. */ while (dentry) { - spin_lock(&dcache_inode_lock); -again: +relock: spin_lock(&dentry->d_lock); + if (dentry->d_count > 1) { + dentry->d_count--; + spin_unlock(&dentry->d_lock); + return; + } + if (!spin_trylock(&dcache_inode_lock)) { +relock2: + spin_unlock(&dentry->d_lock); + cpu_relax(); + goto relock; + } + if (IS_ROOT(dentry)) parent = NULL; else parent = dentry->d_parent; if (parent && !spin_trylock(&parent->d_lock)) { - spin_unlock(&dentry->d_lock); - goto again; - } - dentry->d_count--; - if (dentry->d_count) { - if (parent) - spin_unlock(&parent->d_lock); - spin_unlock(&dentry->d_lock); spin_unlock(&dcache_inode_lock); - return; + goto relock2; } - + dentry->d_count--; dentry_lru_del(dentry); __d_drop(dentry); dentry = d_kill(dentry, parent);