Commit 67ae67d5 authored by Andrew Morton's avatar Andrew Morton Committed by Greg Kroah-Hartman

[PATCH] dentry->d_count fixes: d_invalidate

From: Maneesh Soni <maneesh@in.ibm.com>

- d_invalidate() can incorrectly return success instead of returning -EBUSY
  as we can have situations where lockless d_lookup has found a dentry
  successfully before d_invalidate drops it
parent 91bf7a38
...@@ -232,14 +232,17 @@ int d_invalidate(struct dentry * dentry) ...@@ -232,14 +232,17 @@ int d_invalidate(struct dentry * dentry)
* we might still populate it if it was a * we might still populate it if it was a
* working directory or similar). * working directory or similar).
*/ */
spin_lock(&dentry->d_lock);
if (atomic_read(&dentry->d_count) > 1) { if (atomic_read(&dentry->d_count) > 1) {
if (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode)) { if (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode)) {
spin_unlock(&dentry->d_lock);
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
return -EBUSY; return -EBUSY;
} }
} }
__d_drop(dentry); __d_drop(dentry);
spin_unlock(&dentry->d_lock);
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment