From c0716f13efc4a9ab2123683870bfe3178747b8aa Mon Sep 17 00:00:00 2001 From: tuxoko Date: Thu, 22 Sep 2016 19:09:16 -0700 Subject: [PATCH] Linux 4.7 compat: Fix deadlock during lookup on case-insensitive 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 Signed-off-by: Chunwei Chen Closes #5124 Closes #5141 Closes #5147 Closes #5148 --- module/zfs/zpl_inode.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c index ed12bb19d78e..d5d37345d117 100644 --- a/module/zfs/zpl_inode.c +++ b/module/zfs/zpl_inode.c @@ -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 {