Whamcloud - gitweb
b=7049
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs-raw_ops-vanilla-2.6.patch
1 Index: linus-2.6.7/fs/namei.c
2 ===================================================================
3 --- linus-2.6.7.orig/fs/namei.c 2005-03-05 20:24:52.000000000 +0200
4 +++ linus-2.6.7/fs/namei.c      2005-03-23 13:37:48.563339840 +0200
5 @@ -758,14 +758,20 @@
6  lookup_parent:
7                 nd->last = this;
8                 nd->last_type = LAST_NORM;
9 -               if (this.name[0] != '.')
10 -                       goto return_base;
11 -               if (this.len == 1)
12 -                       nd->last_type = LAST_DOT;
13 -               else if (this.len == 2 && this.name[1] == '.')
14 -                       nd->last_type = LAST_DOTDOT;
15 -               else
16 -                       goto return_base;
17 +               if (this.name[0] == '.') {
18 +                       if (this.len == 1)
19 +                               nd->last_type = LAST_DOT;
20 +                       else if (this.len == 2 && this.name[1] == '.')
21 +                               nd->last_type = LAST_DOTDOT;
22 +               }
23 +
24 +               if ((nd->last_type == LAST_NORM) && inode->i_op &&
25 +                   inode->i_op->endparentlookup) {
26 +                       err = inode->i_op->endparentlookup(nd);
27 +                       if (err)
28 +                               break;
29 +               }
30 +               goto return_base;
31  return_reval:
32                 /*
33                  * We bypassed the ordinary revalidation routines.
34 @@ -1535,9 +1541,16 @@
35         if (IS_ERR(tmp))
36                 return PTR_ERR(tmp);
37  
38 -       error = path_lookup(tmp, LOOKUP_PARENT, &nd);
39 +       intent_init(&nd.intent.open, IT_MKNOD);
40 +       nd.intent.open.create_mode = mode;
41 +       nd.intent.open.create.dev = dev;
42 +
43 +       error = path_lookup_it(tmp, LOOKUP_PARENT, &nd);
44         if (error)
45                 goto out;
46 +       if (nd.intent.open.flags & IT_STATUS_RAW)
47 +               goto out2;
48 +
49         dentry = lookup_create(&nd, 0);
50         error = PTR_ERR(dentry);
51  
52 @@ -1564,6 +1577,7 @@
53                 dput(dentry);
54         }
55         up(&nd.dentry->d_inode->i_sem);
56 +out2:
57         path_release(&nd);
58  out:
59         putname(tmp);
60 @@ -1606,9 +1620,13 @@
61                 struct dentry *dentry;
62                 struct nameidata nd;
63  
64 -               error = path_lookup(tmp, LOOKUP_PARENT, &nd);
65 +               intent_init(&nd.intent.open, IT_MKDIR);
66 +               nd.intent.open.create_mode = mode;
67 +               error = path_lookup_it(tmp, LOOKUP_PARENT, &nd);
68                 if (error)
69                         goto out;
70 +               if (nd.intent.open.flags & IT_STATUS_RAW)
71 +                       goto out2;
72                 dentry = lookup_create(&nd, 1);
73                 error = PTR_ERR(dentry);
74                 if (!IS_ERR(dentry)) {
75 @@ -1618,6 +1636,7 @@
76                         dput(dentry);
77                 }
78                 up(&nd.dentry->d_inode->i_sem);
79 +out2:
80                 path_release(&nd);
81  out:
82                 putname(tmp);
83 @@ -1703,9 +1722,12 @@
84         if(IS_ERR(name))
85                 return PTR_ERR(name);
86  
87 -       error = path_lookup(name, LOOKUP_PARENT, &nd);
88 +       intent_init(&nd.intent.open, IT_RMDIR);
89 +       error = path_lookup_it(name, LOOKUP_PARENT, &nd);
90         if (error)
91                 goto exit;
92 +       if (nd.intent.open.flags & IT_STATUS_RAW)
93 +               goto exit1;
94  
95         switch(nd.last_type) {
96                 case LAST_DOTDOT:
97 @@ -1781,9 +1803,13 @@
98         if(IS_ERR(name))
99                 return PTR_ERR(name);
100  
101 -       error = path_lookup(name, LOOKUP_PARENT, &nd);
102 +       intent_init(&nd.intent.open, IT_UNLINK);
103 +       error = path_lookup_it(name, LOOKUP_PARENT, &nd);
104         if (error)
105                 goto exit;
106 +       if (nd.intent.open.flags & IT_STATUS_RAW)
107 +               goto exit1;
108 +
109         error = -EISDIR;
110         if (nd.last_type != LAST_NORM)
111                 goto exit1;
112 @@ -1855,9 +1881,13 @@
113                 struct dentry *dentry;
114                 struct nameidata nd;
115  
116 -               error = path_lookup(to, LOOKUP_PARENT, &nd);
117 +               intent_init(&nd.intent.open, IT_SYMLINK);
118 +               nd.intent.open.create.link = from;
119 +               error = path_lookup_it(to, LOOKUP_PARENT, &nd);
120                 if (error)
121                         goto out;
122 +               if (nd.intent.open.flags & IT_STATUS_RAW)
123 +                       goto out2;
124                 dentry = lookup_create(&nd, 0);
125                 error = PTR_ERR(dentry);
126                 if (!IS_ERR(dentry)) {
127 @@ -1865,6 +1895,7 @@
128                         dput(dentry);
129                 }
130                 up(&nd.dentry->d_inode->i_sem);
131 +out2:
132                 path_release(&nd);
133  out:
134                 putname(to);
135 @@ -1936,9 +1967,13 @@
136         error = __user_walk(oldname, 0, &old_nd);
137         if (error)
138                 goto exit;
139 -       error = path_lookup(to, LOOKUP_PARENT, &nd);
140 +       intent_init(&nd.intent.open, IT_LINK);
141 +       nd.intent.open.create.source_nd = &old_nd;
142 +       error = path_lookup_it(to, LOOKUP_PARENT, &nd);
143         if (error)
144                 goto out;
145 +       if (nd.intent.open.flags & IT_STATUS_RAW)
146 +               goto out_release;
147         error = -EXDEV;
148         if (old_nd.mnt != nd.mnt)
149                 goto out_release;
150 @@ -2119,9 +2154,18 @@
151         if (error)
152                 goto exit;
153  
154 -       error = path_lookup(newname, LOOKUP_PARENT, &newnd);
155 +       error = -EBUSY;
156 +       if (oldnd.last_type != LAST_NORM)
157 +               goto exit1;
158 +
159 +       intent_init(&newnd.intent.open, IT_RENAME);
160 +       newnd.intent.open.create.source_nd = &oldnd;
161 +       error = path_lookup_it(newname, LOOKUP_PARENT, &newnd);
162         if (error)
163                 goto exit1;
164 +       if (newnd.intent.open.flags & IT_STATUS_RAW) {
165 +               goto exit2;
166 +       }
167  
168         error = -EXDEV;
169         if (oldnd.mnt != newnd.mnt)
170 @@ -2129,8 +2173,6 @@
171  
172         old_dir = oldnd.dentry;
173         error = -EBUSY;
174 -       if (oldnd.last_type != LAST_NORM)
175 -               goto exit2;
176  
177         new_dir = newnd.dentry;
178         if (newnd.last_type != LAST_NORM)
179 @@ -2238,6 +2280,7 @@
180         intent_init(&nd->intent.open, it.op);
181         nd->intent.open.flags = it.flags;
182         nd->intent.open.create_mode = it.create_mode;
183 +       nd->intent.open.create = it.create;
184         res = link_path_walk(link, nd);
185  out:
186         if (current->link_count || res || nd->last_type!=LAST_NORM)
187 Index: linus-2.6.7/include/linux/namei.h
188 ===================================================================
189 --- linus-2.6.7.orig/include/linux/namei.h      2005-03-05 20:24:52.000000000 +0200
190 +++ linus-2.6.7/include/linux/namei.h   2005-03-23 13:34:56.632477304 +0200
191 @@ -15,9 +15,19 @@
192  #define IT_UNLINK      (1<<5)
193  #define IT_TRUNC       (1<<6)
194  #define IT_GETXATTR    (1<<7)
195 +#define IT_RMDIR       (1<<8)
196 +#define IT_LINK                (1<<9)
197 +#define IT_RENAME      (1<<10)
198 +#define IT_MKDIR       (1<<11)
199 +#define IT_MKNOD       (1<<12)
200 +#define IT_SYMLINK     (1<<13)
201 +#define IT_CHDIR       (1<<14)
202  
203  #define INTENT_MAGIC 0x19620323
204 -
205 +#define IT_STATUS_RAW (1<<10)  /* Setting this in it_flags on exit from lookup
206 +                                  means everything was done already and return
207 +                                  value from lookup is in fact status of
208 +                                  already performed operation */
209  struct open_intent {
210         int     magic;
211         int     op;
212 @@ -25,6 +35,11 @@
213         int     flags;
214         int     create_mode;
215         union {
216 +               unsigned        dev;    /* For mknod */
217 +               char    *link;  /* For symlink */
218 +               struct nameidata *source_nd; /* For link/rename */
219 +       } create;
220 +       union {
221                 void *fs_data; /* FS-specific intent data */
222         } d;
223  };
224 Index: linus-2.6.7/include/linux/fs.h
225 ===================================================================
226 --- linus-2.6.7.orig/include/linux/fs.h 2005-03-05 20:24:52.000000000 +0200
227 +++ linus-2.6.7/include/linux/fs.h      2005-03-23 13:35:08.796628072 +0200
228 @@ -909,6 +909,7 @@
229         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
230         ssize_t (*listxattr) (struct dentry *, char *, size_t);
231         int (*removexattr) (struct dentry *, const char *);
232 +       int (*endparentlookup) (struct nameidata *);
233  };
234  
235  struct seq_file;