]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Linux 4.7 compat: Fix deadlock during lookup on case-insensitive
authortuxoko <tuxoko@gmail.com>
Fri, 23 Sep 2016 02:09:16 +0000 (19:09 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 23 Sep 2016 02:09:16 +0000 (19:09 -0700)
We must not use d_add_ci if the dentry already has the real name. Otherwise,
d_add_ci()->d_alloc_parallel() will find itself on the lookup hash and wait
on itself causing deadlock.

Tested-by: satmandu
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes #5124
Closes #5141
Closes #5147
Closes #5148

module/zfs/zpl_inode.c

index 010f0fd4e21ff5c3ebbe8b409f07941d5203e23c..b7ac4649c1a16a6f405794cc877a014acf9f216f 100644 (file)
@@ -101,9 +101,13 @@ zpl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
                struct dentry *new_dentry;
                struct qstr ci_name;
 
-               ci_name.name = pn.pn_buf;
-               ci_name.len = strlen(pn.pn_buf);
-               new_dentry = d_add_ci(dentry, ip, &ci_name);
+               if (strcmp(dname(dentry), pn.pn_buf) == 0) {
+                       new_dentry = d_splice_alias(ip,  dentry);
+               } else {
+                       ci_name.name = pn.pn_buf;
+                       ci_name.len = strlen(pn.pn_buf);
+                       new_dentry = d_add_ci(dentry, ip, &ci_name);
+               }
                pn_free(ppn);
                return (new_dentry);
        } else {