Skip to content

Commit

Permalink
Linux 4.7 compat: Fix deadlock during lookup on case-insensitive
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes openzfs#5124
Closes openzfs#5141
Closes openzfs#5147
Closes openzfs#5148
  • Loading branch information
tuxoko authored and behlendorf committed Jan 20, 2017
1 parent d9dc458 commit 2ec998d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions module/zfs/zpl_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,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);
}
kmem_free(pn.pn_buf, ZFS_MAXNAMELEN);
return (new_dentry);
} else {
Expand Down

0 comments on commit 2ec998d

Please sign in to comment.