Whamcloud - gitweb
land b1_5 onto HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs_nointent-2.6-rhel4.patch
1 Index: linux-2.6.9-5.0.3.EL/fs/namei.c
2 ===================================================================
3 --- linux-2.6.9-5.0.3.EL.orig/fs/namei.c        2005-02-26 13:29:11.948782168 +0200
4 +++ linux-2.6.9-5.0.3.EL/fs/namei.c     2005-02-26 13:29:13.355568304 +0200
5 @@ -1380,7 +1380,7 @@
6                 if (!error) {
7                         DQUOT_INIT(inode);
8                         
9 -                       error = do_truncate(dentry, 0);
10 +                       error = do_truncate(dentry, 0, 1);
11                 }
12                 put_write_access(inode);
13                 if (error)
14 @@ -1638,6 +1638,7 @@
15         char * tmp;
16         struct dentry * dentry;
17         struct nameidata nd;
18 +       intent_init(&nd.intent, IT_LOOKUP);
19  
20         if (S_ISDIR(mode))
21                 return -EPERM;
22 @@ -1648,6 +1649,15 @@
23         error = path_lookup(tmp, LOOKUP_PARENT, &nd);
24         if (error)
25                 goto out;
26 +
27 +       if (nd.dentry->d_inode->i_op->mknod_raw) {
28 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
29 +               error = op->mknod_raw(&nd, mode, dev);
30 +               /* the file system wants to use normal vfs path now */
31 +               if (error != -EOPNOTSUPP)
32 +                       goto out2;
33 +       }
34 +
35         dentry = lookup_create(&nd, 0);
36         error = PTR_ERR(dentry);
37  
38 @@ -1674,6 +1684,7 @@
39                 dput(dentry);
40         }
41         up(&nd.dentry->d_inode->i_sem);
42 +out2:
43         path_release(&nd);
44  out:
45         putname(tmp);
46 @@ -1715,10 +1726,18 @@
47         if (!IS_ERR(tmp)) {
48                 struct dentry *dentry;
49                 struct nameidata nd;
50 +               intent_init(&nd.intent, IT_LOOKUP);
51  
52                 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
53                 if (error)
54                         goto out;
55 +               if (nd.dentry->d_inode->i_op->mkdir_raw) {
56 +                       struct inode_operations *op = nd.dentry->d_inode->i_op;
57 +                       error = op->mkdir_raw(&nd, mode);
58 +                       /* the file system wants to use normal vfs path now */
59 +                       if (error != -EOPNOTSUPP)
60 +                               goto out2;
61 +               }
62                 dentry = lookup_create(&nd, 1);
63                 error = PTR_ERR(dentry);
64                 if (!IS_ERR(dentry)) {
65 @@ -1728,6 +1747,7 @@
66                         dput(dentry);
67                 }
68                 up(&nd.dentry->d_inode->i_sem);
69 +out2:
70                 path_release(&nd);
71  out:
72                 putname(tmp);
73 @@ -1808,6 +1828,7 @@
74         char * name;
75         struct dentry *dentry;
76         struct nameidata nd;
77 +       intent_init(&nd.intent, IT_LOOKUP);
78  
79         name = getname(pathname);
80         if(IS_ERR(name))
81 @@ -1828,6 +1849,16 @@
82                         error = -EBUSY;
83                         goto exit1;
84         }
85 +
86 +       if (nd.dentry->d_inode->i_op->rmdir_raw) {
87 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
88 +
89 +               error = op->rmdir_raw(&nd);
90 +               /* the file system wants to use normal vfs path now */
91 +               if (error != -EOPNOTSUPP)
92 +                       goto exit1;
93 +       }
94 +
95         down(&nd.dentry->d_inode->i_sem);
96         dentry = lookup_hash(&nd.last, nd.dentry);
97         error = PTR_ERR(dentry);
98 @@ -1886,6 +1917,7 @@
99         struct dentry *dentry;
100         struct nameidata nd;
101         struct inode *inode = NULL;
102 +       intent_init(&nd.intent, IT_LOOKUP);
103  
104         name = getname(pathname);
105         if(IS_ERR(name))
106 @@ -1897,6 +1929,13 @@
107         error = -EISDIR;
108         if (nd.last_type != LAST_NORM)
109                 goto exit1;
110 +       if (nd.dentry->d_inode->i_op->unlink_raw) {
111 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
112 +               error = op->unlink_raw(&nd);
113 +               /* the file system wants to use normal vfs path now */
114 +               if (error != -EOPNOTSUPP)
115 +                       goto exit1;
116 +       }
117         down(&nd.dentry->d_inode->i_sem);
118         dentry = lookup_hash(&nd.last, nd.dentry);
119         error = PTR_ERR(dentry);
120 @@ -1963,10 +2002,18 @@
121         if (!IS_ERR(to)) {
122                 struct dentry *dentry;
123                 struct nameidata nd;
124 +               intent_init(&nd.intent, IT_LOOKUP);
125  
126                 error = path_lookup(to, LOOKUP_PARENT, &nd);
127                 if (error)
128                         goto out;
129 +               if (nd.dentry->d_inode->i_op->symlink_raw) {
130 +                       struct inode_operations *op = nd.dentry->d_inode->i_op;
131 +                       error = op->symlink_raw(&nd, from);
132 +                       /* the file system wants to use normal vfs path now */
133 +                       if (error != -EOPNOTSUPP)
134 +                               goto out2;
135 +               }
136                 dentry = lookup_create(&nd, 0);
137                 error = PTR_ERR(dentry);
138                 if (!IS_ERR(dentry)) {
139 @@ -1974,6 +2021,7 @@
140                         dput(dentry);
141                 }
142                 up(&nd.dentry->d_inode->i_sem);
143 +out2:
144                 path_release(&nd);
145  out:
146                 putname(to);
147 @@ -2037,6 +2085,8 @@
148         struct nameidata nd, old_nd;
149         int error;
150         char * to;
151 +       intent_init(&nd.intent, IT_LOOKUP);
152 +       intent_init(&old_nd.intent, IT_LOOKUP);
153  
154         to = getname(newname);
155         if (IS_ERR(to))
156 @@ -2051,6 +2101,13 @@
157         error = -EXDEV;
158         if (old_nd.mnt != nd.mnt)
159                 goto out_release;
160 +       if (nd.dentry->d_inode->i_op->link_raw) {
161 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
162 +               error = op->link_raw(&old_nd, &nd);
163 +               /* the file system wants to use normal vfs path now */
164 +               if (error != -EOPNOTSUPP)
165 +                       goto out_release;
166 +       }
167         new_dentry = lookup_create(&nd, 0);
168         error = PTR_ERR(new_dentry);
169         if (!IS_ERR(new_dentry)) {
170 @@ -2223,6 +2280,8 @@
171         struct dentry * old_dentry, *new_dentry;
172         struct dentry * trap;
173         struct nameidata oldnd, newnd;
174 +       intent_init(&oldnd.intent, IT_LOOKUP);
175 +       intent_init(&newnd.intent, IT_LOOKUP);
176  
177         error = path_lookup(oldname, LOOKUP_PARENT, &oldnd);
178         if (error)
179 @@ -2245,6 +2304,13 @@
180         if (newnd.last_type != LAST_NORM)
181                 goto exit2;
182  
183 +       if (old_dir->d_inode->i_op->rename_raw) {
184 +               error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
185 +               /* the file system wants to use normal vfs path now */
186 +               if (error != -EOPNOTSUPP)
187 +                       goto exit2;
188 +       }
189 +
190         trap = lock_rename(new_dir, old_dir);
191  
192         old_dentry = lookup_hash(&oldnd.last, old_dir);
193 @@ -2276,8 +2342,7 @@
194         if (new_dentry == trap)
195                 goto exit5;
196  
197 -       error = vfs_rename(old_dir->d_inode, old_dentry,
198 -                                  new_dir->d_inode, new_dentry);
199 +       error = vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry);
200  exit5:
201         dput(new_dentry);
202  exit4:
203 Index: linux-2.6.9-5.0.3.EL/fs/open.c
204 ===================================================================
205 --- linux-2.6.9-5.0.3.EL.orig/fs/open.c 2005-02-26 13:29:11.962780040 +0200
206 +++ linux-2.6.9-5.0.3.EL/fs/open.c      2005-02-26 13:29:13.359567696 +0200
207 @@ -191,9 +191,10 @@
208         return error;
209  }
210  
211 -int do_truncate(struct dentry *dentry, loff_t length)
212 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
213  {
214         int err;
215 +       struct inode_operations *op = dentry->d_inode->i_op;
216         struct iattr newattrs;
217  
218         /* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
219 @@ -204,7 +205,14 @@
220         newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
221         down(&dentry->d_inode->i_sem);
222         down_write(&dentry->d_inode->i_alloc_sem);
223 -       err = notify_change(dentry, &newattrs);
224 +       if (called_from_open)
225 +               newattrs.ia_valid |= ATTR_FROM_OPEN;
226 +       if (op->setattr_raw) {
227 +               newattrs.ia_valid |= ATTR_RAW;
228 +               newattrs.ia_ctime = CURRENT_TIME;
229 +               err = op->setattr_raw(dentry->d_inode, &newattrs);
230 +       } else
231 +               err = notify_change(dentry, &newattrs);
232         up_write(&dentry->d_inode->i_alloc_sem);
233         up(&dentry->d_inode->i_sem);
234         return err;
235 @@ -260,7 +268,7 @@
236         error = locks_verify_truncate(inode, NULL, length);
237         if (!error) {
238                 DQUOT_INIT(inode);
239 -               error = do_truncate(nd.dentry, length);
240 +               error = do_truncate(nd.dentry, length, 0);
241         }
242         put_write_access(inode);
243  
244 @@ -312,7 +320,7 @@
245  
246         error = locks_verify_truncate(inode, file, length);
247         if (!error)
248 -               error = do_truncate(dentry, length);
249 +               error = do_truncate(dentry, length, 0);
250  out_putf:
251         fput(file);
252  out:
253 @@ -391,9 +399,19 @@
254                     (error = permission(inode,MAY_WRITE,&nd)) != 0)
255                         goto dput_and_out;
256         }
257 -       down(&inode->i_sem);
258 -       error = notify_change(nd.dentry, &newattrs);
259 -       up(&inode->i_sem);
260 +       if (inode->i_op->setattr_raw) {
261 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
262 +
263 +               newattrs.ia_valid |= ATTR_RAW;
264 +               error = op->setattr_raw(inode, &newattrs);
265 +               /* the file system wants to use normal vfs path now */
266 +               if (error != -EOPNOTSUPP)
267 +                       goto dput_and_out;
268 +       } else {
269 +               down(&inode->i_sem);
270 +               error = notify_change(nd.dentry, &newattrs);
271 +               up(&inode->i_sem);
272 +       }
273  dput_and_out:
274         path_release(&nd);
275  out:
276 @@ -444,9 +462,19 @@
277                     (error = permission(inode,MAY_WRITE,&nd)) != 0)
278                         goto dput_and_out;
279         }
280 -       down(&inode->i_sem);
281 -       error = notify_change(nd.dentry, &newattrs);
282 -       up(&inode->i_sem);
283 +       if (inode->i_op->setattr_raw) {
284 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
285 +
286 +               newattrs.ia_valid |= ATTR_RAW;
287 +               error = op->setattr_raw(inode, &newattrs);
288 +               /* the file system wants to use normal vfs path now */
289 +               if (error != -EOPNOTSUPP)
290 +                       goto dput_and_out;
291 +       } else {
292 +               down(&inode->i_sem);
293 +               error = notify_change(nd.dentry, &newattrs);
294 +               up(&inode->i_sem);
295 +       }
296  dput_and_out:
297         path_release(&nd);
298  out:
299 @@ -600,36 +628,52 @@
300  
301  EXPORT_SYMBOL_GPL(sys_chroot);
302  
303 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
304 +int chmod_common(struct dentry *dentry, mode_t mode)
305  {
306 -       struct inode * inode;
307 -       struct dentry * dentry;
308 -       struct file * file;
309 -       int err = -EBADF;
310 +       struct inode * inode = dentry->d_inode;
311         struct iattr newattrs;
312 +       int error = -EROFS;
313  
314 -       file = fget(fd);
315 -       if (!file)
316 +       if (IS_RDONLY(inode))
317                 goto out;
318 +       
319 +       if (inode->i_op->setattr_raw) {
320 +               struct inode_operations *op = dentry->d_inode->i_op;
321  
322 -       dentry = file->f_dentry;
323 -       inode = dentry->d_inode;
324 +               newattrs.ia_mode = mode;
325 +               newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
326 +               newattrs.ia_valid |= ATTR_RAW;
327 +               error = op->setattr_raw(inode, &newattrs);
328 +               /* the file system wants to use the normal vfs path now */
329 +               if (error != -EOPNOTSUPP)
330 +                       goto out;
331 +       }
332  
333 -       err = -EROFS;
334 -       if (IS_RDONLY(inode))
335 -               goto out_putf;
336 -       err = -EPERM;
337 +       error = -EPERM;
338         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
339 -               goto out_putf;
340 +               goto out;
341 +
342         down(&inode->i_sem);
343         if (mode == (mode_t) -1)
344                 mode = inode->i_mode;
345         newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
346         newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
347 -       err = notify_change(dentry, &newattrs);
348 +       error = notify_change(dentry, &newattrs);
349         up(&inode->i_sem);
350 +out:
351 +       return error;
352 +}
353  
354 -out_putf:
355 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
356 +{
357 +       struct file * file;
358 +       int err = -EBADF;
359 +
360 +       file = fget(fd);
361 +       if (!file)
362 +               goto out;
363 +
364 +       err = chmod_common(file->f_dentry, mode);
365         fput(file);
366  out:
367         return err;
368 @@ -638,32 +682,13 @@
369  asmlinkage long sys_chmod(const char __user * filename, mode_t mode)
370  {
371         struct nameidata nd;
372 -       struct inode * inode;
373         int error;
374 -       struct iattr newattrs;
375  
376         error = user_path_walk(filename, &nd);
377         if (error)
378                 goto out;
379 -       inode = nd.dentry->d_inode;
380 -
381 -       error = -EROFS;
382 -       if (IS_RDONLY(inode))
383 -               goto dput_and_out;
384 -
385 -       error = -EPERM;
386 -       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
387 -               goto dput_and_out;
388 -
389 -       down(&inode->i_sem);
390 -       if (mode == (mode_t) -1)
391 -               mode = inode->i_mode;
392 -       newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
393 -       newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
394 -       error = notify_change(nd.dentry, &newattrs);
395 -       up(&inode->i_sem);
396  
397 -dput_and_out:
398 +       error = chmod_common(nd.dentry, mode);
399         path_release(&nd);
400  out:
401         return error;
402 @@ -684,6 +709,18 @@
403         if (IS_RDONLY(inode))
404                 goto out;
405         error = -EPERM;
406 +       if (inode->i_op->setattr_raw) {
407 +               struct inode_operations *op = dentry->d_inode->i_op;
408 +
409 +               newattrs.ia_uid = user;
410 +               newattrs.ia_gid = group;
411 +               newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
412 +               newattrs.ia_valid |= ATTR_RAW;
413 +               error = op->setattr_raw(inode, &newattrs);
414 +               /* the file system wants to use normal vfs path now */
415 +               if (error != -EOPNOTSUPP)
416 +                       return error;
417 +       }
418         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
419                 goto out;
420         newattrs.ia_valid =  ATTR_CTIME;
421 @@ -697,6 +734,7 @@
422         }
423         if (!S_ISDIR(inode->i_mode))
424                 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
425 +
426         down(&inode->i_sem);
427         error = notify_change(dentry, &newattrs);
428         up(&inode->i_sem);
429 Index: linux-2.6.9-5.0.3.EL/fs/exec.c
430 ===================================================================
431 --- linux-2.6.9-5.0.3.EL.orig/fs/exec.c 2005-02-26 13:29:11.936783992 +0200
432 +++ linux-2.6.9-5.0.3.EL/fs/exec.c      2005-02-26 13:29:13.362567240 +0200
433 @@ -1451,7 +1451,7 @@
434                 goto close_fail;
435         if (!file->f_op->write)
436                 goto close_fail;
437 -       if (do_truncate(file->f_dentry, 0) != 0)
438 +       if (do_truncate(file->f_dentry, 0, 0) != 0)
439                 goto close_fail;
440  
441         retval = binfmt->core_dump(signr, regs, file);
442 Index: linux-2.6.9-5.0.3.EL/include/linux/fs.h
443 ===================================================================
444 --- linux-2.6.9-5.0.3.EL.orig/include/linux/fs.h        2005-02-26 13:29:11.987776240 +0200
445 +++ linux-2.6.9-5.0.3.EL/include/linux/fs.h     2005-02-26 13:29:13.365566784 +0200
446 @@ -926,13 +926,20 @@
447         int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
448         struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
449         int (*link) (struct dentry *,struct inode *,struct dentry *);
450 +       int (*link_raw) (struct nameidata *,struct nameidata *);
451         int (*unlink) (struct inode *,struct dentry *);
452 +       int (*unlink_raw) (struct nameidata *);
453         int (*symlink) (struct inode *,struct dentry *,const char *);
454 +       int (*symlink_raw) (struct nameidata *,const char *);
455         int (*mkdir) (struct inode *,struct dentry *,int);
456 +       int (*mkdir_raw) (struct nameidata *,int);
457         int (*rmdir) (struct inode *,struct dentry *);
458 +       int (*rmdir_raw) (struct nameidata *);
459         int (*mknod) (struct inode *,struct dentry *,int,dev_t);
460 +       int (*mknod_raw) (struct nameidata *,int,dev_t);
461         int (*rename) (struct inode *, struct dentry *,
462                         struct inode *, struct dentry *);
463 +       int (*rename_raw) (struct nameidata *, struct nameidata *);
464         int (*readlink) (struct dentry *, char __user *,int);
465         int (*follow_link) (struct dentry *, struct nameidata *);
466         void (*put_link) (struct dentry *, struct nameidata *);
467 @@ -1234,7 +1241,7 @@
468  
469  /* fs/open.c */
470  
471 -extern int do_truncate(struct dentry *, loff_t start);
472 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
473  extern struct file *filp_open(const char *, int, int);
474  extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
475  extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
476 Index: linux-2.6.9-5.0.3.EL/net/unix/af_unix.c
477 ===================================================================
478 --- linux-2.6.9-5.0.3.EL.orig/net/unix/af_unix.c        2005-02-25 10:25:31.000000000 +0200
479 +++ linux-2.6.9-5.0.3.EL/net/unix/af_unix.c     2005-02-26 13:29:13.387563440 +0200
480 @@ -676,6 +676,7 @@
481         int err = 0;
482         
483         if (sunname->sun_path[0]) {
484 +               intent_init(&nd.intent, IT_LOOKUP);
485                 err = path_lookup(sunname->sun_path, LOOKUP_FOLLOW, &nd);
486                 if (err)
487                         goto fail;