Skip to content

Instantly share code, notes, and snippets.

@tuxoko
Created September 22, 2016 22:18
Show Gist options
  • Save tuxoko/aca3da99949a603a393818f8945a5010 to your computer and use it in GitHub Desktop.
Save tuxoko/aca3da99949a603a393818f8945a5010 to your computer and use it in GitHub Desktop.
commit ca788d058d342dafdcf93a4bd67da61bdd020f61
Author: Chunwei Chen <david.chen@osnexus.com>
Date: Tue Sep 20 11:26:32 2016 -0700
Linux 4.7: 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.
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
index cbdab7d..478f237 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 {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment