diff --git a/fs/dcache.c b/fs/dcache.c index a8f89765d6027c3c6c882c947582882c53238d07..1957063746977c7bc1e72446223589e772890a40 100644 --- a/fs/dcache.c +++ b/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);