Whamcloud - gitweb
LU-13211 ldiskfs: rework data-in-dirent for linux 5.4.7+
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / linux-5.4 / ext4-lookup-dotdot.patch
1 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
2 index cd01c4a..0aefa8e 100644
3 --- a/fs/ext4/namei.c
4 +++ b/fs/ext4/namei.c
5 @@ -1663,6 +1663,32 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
6                         return ERR_PTR(-EPERM);
7                 }
8         }
9 +       /* ".." shouldn't go into dcache to preserve dcache hierarchy
10 +        * otherwise we'll get parent being a child of actual child.
11 +        * see bug 10458 for details -bzzz */
12 +       if (inode && (dentry->d_name.name[0] == '.' &&
13 +                     (dentry->d_name.len == 1 || (dentry->d_name.len == 2 &&
14 +                                            dentry->d_name.name[1] == '.')))) {
15 +               struct dentry *goal = NULL;
16 +
17 +               /* first, look for an existing dentry - any one is good */
18 +               goal = d_find_any_alias(inode);
19 +               if (goal == NULL) {
20 +                       spin_lock(&dentry->d_lock);
21 +                       /* there is no alias, we need to make current dentry:
22 +                        *  a) inaccessible for __d_lookup()
23 +                        *  b) inaccessible for iopen */
24 +                       J_ASSERT(hlist_unhashed(&dentry->d_u.d_alias));
25 +                       dentry->d_flags |= DCACHE_NFSFS_RENAMED;
26 +                       /* this is d_instantiate() ... */
27 +                       hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
28 +                       dentry->d_inode = inode;
29 +                       spin_unlock(&dentry->d_lock);
30 +               }
31 +               if (goal)
32 +                       iput(inode);
33 +               return goal;
34 +       }
35  
36  #ifdef CONFIG_UNICODE
37         if (!inode && IS_CASEFOLDED(dir)) {