switch d_add_ci() to d_splice_alias() in "found negative" case as well
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 17 Jul 2011 14:52:14 +0000 (10:52 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 21 Jul 2011 00:48:02 +0000 (20:48 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/dcache.c

index 2762804a140db03cb432648a1b38d910f24f640d..d1d6b3349ec7a045e027b0a6c141352862bd80b1 100644 (file)
@@ -1652,26 +1652,12 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
         * Negative dentry: instantiate it unless the inode is a directory and
         * already has a dentry.
         */
-       spin_lock(&inode->i_lock);
-       if (!S_ISDIR(inode->i_mode) || list_empty(&inode->i_dentry)) {
-               __d_instantiate(found, inode);
-               spin_unlock(&inode->i_lock);
-               security_d_instantiate(found, inode);
-               return found;
+       new = d_splice_alias(inode, found);
+       if (new) {
+               dput(found);
+               found = new;
        }
-
-       /*
-        * In case a directory already has a (disconnected) entry grab a
-        * reference to it, move it in place and use it.
-        */
-       new = list_entry(inode->i_dentry.next, struct dentry, d_alias);
-       __dget(new);
-       spin_unlock(&inode->i_lock);
-       security_d_instantiate(found, inode);
-       d_move(new, found);
-       iput(inode);
-       dput(found);
-       return new;
+       return found;
 
 err_out:
        iput(inode);