__d_add(): don't drop/regain ->d_lock
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 14 Apr 2016 23:40:56 +0000 (19:40 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 2 May 2016 23:47:26 +0000 (19:47 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/dcache.c

index 4962a7b4384ef51905d735fc07ef3443bf86e59b..20394fb6f967e07c76cb8a4121c2ed090f0b17cd 100644 (file)
@@ -2366,11 +2366,19 @@ EXPORT_SYMBOL(d_rehash);
 
 static inline void __d_add(struct dentry *dentry, struct inode *inode)
 {
+       spin_lock(&dentry->d_lock);
        if (inode) {
-               __d_instantiate(dentry, inode);
+               unsigned add_flags = d_flags_for_inode(inode);
+               hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
+               raw_write_seqcount_begin(&dentry->d_seq);
+               __d_set_inode_and_type(dentry, inode, add_flags);
+               raw_write_seqcount_end(&dentry->d_seq);
+               __fsnotify_d_instantiate(dentry);
+       }
+       _d_rehash(dentry);
+       spin_unlock(&dentry->d_lock);
+       if (inode)
                spin_unlock(&inode->i_lock);
-       }
-       d_rehash(dentry);
 }
 
 /**