Commit 06171a48 authored by Andrew Morton's avatar Andrew Morton Committed by Greg Kroah-Hartman

[PATCH] dentry->d_count fixes: hpfs

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

- hpfs_unlink() can race with lockless d_lookup(), as we can have situations
  where d_lookup() has successfully looked-up a dentry and at the sametime
  hpfs_unlink()--->d_drop() has dropped it. Taking the per dentry lock
  before checking the d_count in hpfs_unlink() solves this race condition.
parent e59317b4
...@@ -372,12 +372,15 @@ int hpfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -372,12 +372,15 @@ int hpfs_unlink(struct inode *dir, struct dentry *dentry)
if (rep) if (rep)
goto ret; goto ret;
d_drop(dentry); d_drop(dentry);
spin_lock(&dentry->d_lock);
if (atomic_read(&dentry->d_count) > 1 || if (atomic_read(&dentry->d_count) > 1 ||
permission(inode, MAY_WRITE) || permission(inode, MAY_WRITE) ||
get_write_access(inode)) { get_write_access(inode)) {
spin_unlock(&dentry->d_lock);
d_rehash(dentry); d_rehash(dentry);
goto ret; goto ret;
} }
spin_unlock(&dentry->d_lock);
/*printk("HPFS: truncating file before delete.\n");*/ /*printk("HPFS: truncating file before delete.\n");*/
newattrs.ia_size = 0; newattrs.ia_size = 0;
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
......
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