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