Whamcloud - gitweb
LU-162 Export ext4_discard_preallocations for ldiskfs
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext3-lookup-dotdot-2.6.9.patch
1 Index: linux-2.6.9-full/fs/ext3/namei.c
2 ===================================================================
3 --- linux-2.6.9-full.orig/fs/ext3/namei.c       2006-05-06 01:21:10.000000000 +0400
4 +++ linux-2.6.9-full/fs/ext3/namei.c    2006-05-06 01:29:30.000000000 +0400
5 @@ -1003,6 +1003,38 @@ static struct dentry *ext3_lookup(struct
6  
7                         return ERR_PTR(-EACCES);
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] == '.' && (dentry->d_name.len == 1 ||
13 +               (dentry->d_name.len == 2 && dentry->d_name.name[1] == '.')))) {
14 +               struct dentry *tmp, *goal = NULL;
15 +               struct list_head *lp;
16 +
17 +               /* first, look for an existing dentry - any one is good */
18 +               spin_lock(&dcache_lock);
19 +               list_for_each(lp, &inode->i_dentry) {
20 +                       tmp = list_entry(lp, struct dentry, d_alias);
21 +                       goal = tmp;
22 +                       dget_locked(goal);
23 +                       break;
24 +               }
25 +               if (goal == NULL) {
26 +                       /* there is no alias, we need to make current dentry:
27 +                        *  a) inaccessible for __d_lookup()
28 +                        *  b) inaccessible for iopen */
29 +                       J_ASSERT(list_empty(&dentry->d_alias));
30 +                       dentry->d_flags |= DCACHE_NFSFS_RENAMED;
31 +                       /* this is d_instantiate() ... */
32 +                       list_add(&dentry->d_alias, &inode->i_dentry);
33 +                       dentry->d_inode = inode;
34 +               }
35 +               spin_unlock(&dcache_lock);
36 +               if (goal)
37 +                       iput(inode);
38 +               return goal;
39 +       }
40 +
41         return d_splice_alias(inode, dentry);
42  }
43