Whamcloud - gitweb
- landing of b_fid after merge with b_hd_cleanup_merge.
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs_nointent-2.6-suse.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.5-12.1/fs/namei.c
6 ===================================================================
7 --- linux-2.6.5-12.1.orig/fs/namei.c    2004-05-11 15:41:54.000000000 -0400
8 +++ linux-2.6.5-12.1/fs/namei.c 2004-05-11 15:42:00.000000000 -0400
9 @@ -1292,7 +1292,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 @@ -1542,6 +1542,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 @@ -1554,6 +1555,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 @@ -1580,6 +1590,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 @@ -1626,10 +1637,18 @@
51  
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 @@ -1639,6 +1658,7 @@
70                         dput(dentry);
71                 }
72                 up(&nd.dentry->d_inode->i_sem);
73 +out2:
74                 path_release(&nd);
75  out:
76  
77 @@ -1722,6 +1742,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 @@ -1744,6 +1765,14 @@
86                         error = -EBUSY;
87                         goto exit1;
88         }
89 +       if (nd.dentry->d_inode->i_op->rmdir_raw) {
90 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
91 +
92 +               error = op->rmdir_raw(&nd);
93 +               /* the file system wants to use normal vfs path now */
94 +               if (error != -EOPNOTSUPP)
95 +                       goto exit1;
96 +       }
97         down(&nd.dentry->d_inode->i_sem);
98         dentry = lookup_hash(&nd.last, nd.dentry);
99         error = PTR_ERR(dentry);
100 @@ -1805,6 +1834,7 @@
101         struct dentry *dentry;
102         struct nameidata nd;
103         struct inode *inode = NULL;
104 +        intent_init(&nd.intent, IT_LOOKUP);
105  
106         name = getname(pathname);
107         if(IS_ERR(name))
108 @@ -1818,6 +1848,13 @@
109         error = -EISDIR;
110         if (nd.last_type != LAST_NORM)
111                 goto exit1;
112 +       if (nd.dentry->d_inode->i_op->unlink_raw) {
113 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
114 +               error = op->unlink_raw(&nd);
115 +               /* the file system wants to use normal vfs path now */
116 +               if (error != -EOPNOTSUPP)
117 +                       goto exit1;
118 +       }
119         down(&nd.dentry->d_inode->i_sem);
120         dentry = lookup_hash(&nd.last, nd.dentry);
121         error = PTR_ERR(dentry);
122 @@ -1891,10 +1928,18 @@
123  
124                 struct dentry *dentry;
125                 struct nameidata nd;
126 +                intent_init(&nd.intent, IT_LOOKUP);
127  
128                 error = path_lookup(to, LOOKUP_PARENT, &nd);
129                 if (error)
130                         goto out;
131 +               if (nd.dentry->d_inode->i_op->symlink_raw) {
132 +                       struct inode_operations *op = nd.dentry->d_inode->i_op;
133 +                       error = op->symlink_raw(&nd, from);
134 +                       /* the file system wants to use normal vfs path now */
135 +                       if (error != -EOPNOTSUPP)
136 +                               goto out2;
137 +               }
138                 dentry = lookup_create(&nd, 0);
139                 error = PTR_ERR(dentry);
140                 if (!IS_ERR(dentry)) {
141 @@ -1902,6 +1947,7 @@
142                         dput(dentry);
143                 }
144                 up(&nd.dentry->d_inode->i_sem);
145 +out2:
146                 path_release(&nd);
147  out:
148  
149 @@ -1968,6 +2014,8 @@
150         struct nameidata nd, old_nd;
151         int error;
152         char * to;
153 +        intent_init(&nd.intent, IT_LOOKUP);
154 +        intent_init(&old_nd.intent, IT_LOOKUP);
155  
156         to = getname(newname);
157         if (IS_ERR(to))
158 @@ -1986,6 +2034,13 @@
159         error = -EXDEV;
160         if (old_nd.mnt != nd.mnt)
161                 goto out_release;
162 +        if (nd.dentry->d_inode->i_op->link_raw) {
163 +                struct inode_operations *op = nd.dentry->d_inode->i_op;
164 +                error = op->link_raw(&old_nd, &nd);
165 +                /* the file system wants to use normal vfs path now */
166 +                if (error != -EOPNOTSUPP)
167 +                        goto out_release;
168 +        }
169         new_dentry = lookup_create(&nd, 0);
170         error = PTR_ERR(new_dentry);
171         if (!IS_ERR(new_dentry)) {
172 @@ -2038,7 +2093,7 @@
173   *        locking].
174   */
175  int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
176 -              struct inode *new_dir, struct dentry *new_dentry)
177 +                   struct inode *new_dir, struct dentry *new_dentry)
178  {
179         int error = 0;
180         struct inode *target;
181 @@ -2083,7 +2138,7 @@
182  }
183  
184  int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
185 -              struct inode *new_dir, struct dentry *new_dentry)
186 +                     struct inode *new_dir, struct dentry *new_dentry)
187  {
188         struct inode *target;
189         int error;
190 @@ -2160,6 +2215,8 @@
191         struct dentry * old_dentry, *new_dentry;
192         struct dentry * trap;
193         struct nameidata oldnd, newnd;
194 +        intent_init(&oldnd.intent, IT_LOOKUP);
195 +        intent_init(&newnd.intent, IT_LOOKUP);
196  
197         error = path_lookup(oldname, LOOKUP_PARENT, &oldnd);
198         if (error)
199 @@ -2182,6 +2239,13 @@
200         if (newnd.last_type != LAST_NORM)
201                 goto exit2;
202  
203 +       if (old_dir->d_inode->i_op->rename_raw) {
204 +               error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
205 +               /* the file system wants to use normal vfs path now */
206 +               if (error != -EOPNOTSUPP)
207 +                       goto exit2;
208 +       }
209 +
210         trap = lock_rename(new_dir, old_dir);
211  
212         old_dentry = lookup_hash(&oldnd.last, old_dir);
213 @@ -2213,8 +2277,7 @@
214         if (new_dentry == trap)
215                 goto exit5;
216  
217 -       error = vfs_rename(old_dir->d_inode, old_dentry,
218 -                                  new_dir->d_inode, new_dentry);
219 +       error = vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry);
220  exit5:
221         dput(new_dentry);
222  exit4:
223 Index: linux-2.6.5-12.1/fs/open.c
224 ===================================================================
225 --- linux-2.6.5-12.1.orig/fs/open.c     2004-05-11 15:41:54.000000000 -0400
226 +++ linux-2.6.5-12.1/fs/open.c  2004-05-11 16:07:02.000000000 -0400
227 @@ -203,9 +203,10 @@
228         return error;
229  }
230  
231 -int do_truncate(struct dentry *dentry, loff_t length)
232 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
233  {
234         int err;
235 +       struct inode_operations *op = dentry->d_inode->i_op;
236         struct iattr newattrs;
237  
238         /* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
239 @@ -216,7 +217,14 @@
240         newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
241         down(&dentry->d_inode->i_sem);
242         down_write(&dentry->d_inode->i_alloc_sem);
243 -       err = notify_change(dentry, &newattrs);
244 +       if (called_from_open)
245 +               newattrs.ia_valid |= ATTR_FROM_OPEN;
246 +       if (op->setattr_raw) {
247 +               newattrs.ia_valid |= ATTR_RAW;
248 +               newattrs.ia_ctime = CURRENT_TIME;
249 +               err = op->setattr_raw(dentry->d_inode, &newattrs);
250 +       } else
251 +               err = notify_change(dentry, &newattrs);
252         up_write(&dentry->d_inode->i_alloc_sem);
253         up(&dentry->d_inode->i_sem);
254         return err;
255 @@ -271,7 +279,7 @@
256         error = locks_verify_truncate(inode, NULL, length);
257         if (!error) {
258                 DQUOT_INIT(inode);
259 -               error = do_truncate(nd.dentry, length);
260 +               error = do_truncate(nd.dentry, length, 0);
261         }
262         put_write_access(inode);
263  
264 @@ -328,7 +336,7 @@
265  
266         error = locks_verify_truncate(inode, file, length);
267         if (!error)
268 -               error = do_truncate(dentry, length);
269 +               error = do_truncate(dentry, length, 0);
270  out_putf:
271         fput(file);
272  out:
273 @@ -402,9 +410,19 @@
274                     (error = permission(inode,MAY_WRITE,&nd)) != 0)
275                         goto dput_and_out;
276         }
277 -       down(&inode->i_sem);
278 -       error = notify_change(nd.dentry, &newattrs);
279 -       up(&inode->i_sem);
280 +       if (inode->i_op->setattr_raw) {
281 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
282 +
283 +               newattrs.ia_valid |= ATTR_RAW;
284 +               error = op->setattr_raw(inode, &newattrs);
285 +               /* the file system wants to use normal vfs path now */
286 +               if (error != -EOPNOTSUPP)
287 +                       goto dput_and_out;
288 +       } else {
289 +                down(&inode->i_sem);
290 +                error = notify_change(nd.dentry, &newattrs);
291 +                up(&inode->i_sem);
292 +        }
293  dput_and_out:
294         path_release(&nd);
295  
296 @@ -613,39 +631,55 @@
297         return error;
298  }
299  
300 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
301 +int chmod_common(struct dentry *dentry, mode_t mode)
302  {
303 -       struct inode * inode;
304 -       struct dentry * dentry;
305 -       struct file * file;
306 -       int err;
307 +       struct inode * inode = dentry->d_inode;
308         struct iattr newattrs;
309 +       int error = -EROFS;
310  
311 -       FSHOOK_BEGIN(fchmod, err, .fd = fd, .mode = mode)
312 -
313 -       err = -EBADF;
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 +               newattrs.ia_mode = mode;
323 +               newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
324 +               newattrs.ia_valid |= ATTR_RAW;
325 +               error = op->setattr_raw(inode, &newattrs);
326 +               /* the file system wants to use the normal vfs path now */
327 +               if (error != -EOPNOTSUPP)
328 +                       goto out;
329 +       }
330  
331 -       dentry = file->f_dentry;
332 -       inode = dentry->d_inode;
333 -
334 -       err = -EROFS;
335 -       if (IS_RDONLY(inode))
336 -               goto out_putf;
337 -       err = -EPERM;
338 +       error = -EPERM;
339         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
340 -               goto out_putf;
341 +               goto out;
342 +
343         down(&inode->i_sem);
344         if (mode == (mode_t) -1)
345                 mode = inode->i_mode;
346         newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
347         newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
348 -       err = notify_change(dentry, &newattrs);
349 +       error = notify_change(dentry, &newattrs);
350         up(&inode->i_sem);
351  
352 -out_putf:
353 +out:
354 +       return error;
355 +}
356 +
357 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
358 +{
359 +       struct file * file;
360 +       int err = -EBADF;
361 +
362 +       FSHOOK_BEGIN(fchmod, err, .fd = fd, .mode = mode)
363 +
364 +       file = fget(fd);
365 +       if (!file)
366 +               goto out;
367 +
368 +       err = chmod_common(file->f_dentry, mode);
369         fput(file);
370  out:
371  
372 @@ -657,9 +691,7 @@
373  asmlinkage long sys_chmod(const char __user * filename, mode_t mode)
374  {
375         struct nameidata nd;
376 -       struct inode * inode;
377         int error;
378 -       struct iattr newattrs;
379  
380         FSHOOK_BEGIN_USER_PATH_WALK(chmod,
381                 error,
382 @@ -669,25 +701,7 @@
383                 .mode = mode,
384                 .link = false)
385  
386 -       inode = nd.dentry->d_inode;
387 -
388 -       error = -EROFS;
389 -       if (IS_RDONLY(inode))
390 -               goto dput_and_out;
391 -       
392 -       error = -EPERM;
393 -       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
394 -               goto dput_and_out;
395 -
396 -       down(&inode->i_sem);
397 -       if (mode == (mode_t) -1)
398 -               mode = inode->i_mode;
399 -       newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
400 -       newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
401 -       error = notify_change(nd.dentry, &newattrs);
402 -       up(&inode->i_sem);
403 -
404 -dput_and_out:
405 +       error = chmod_common(nd.dentry, mode);
406         path_release(&nd);
407  
408         FSHOOK_END_USER_WALK(chmod, error, path)
409 @@ -710,6 +724,18 @@
410         if (IS_RDONLY(inode))
411                 goto out;
412         error = -EPERM;
413 +       if (inode->i_op->setattr_raw) {
414 +               struct inode_operations *op = dentry->d_inode->i_op;
415 +
416 +               newattrs.ia_uid = user;
417 +               newattrs.ia_gid = group;
418 +               newattrs.ia_valid = ATTR_UID | ATTR_GID;
419 +               newattrs.ia_valid |= ATTR_RAW;
420 +               error = op->setattr_raw(inode, &newattrs);
421 +               /* the file system wants to use normal vfs path now */
422 +               if (error != -EOPNOTSUPP)
423 +                       return error;
424 +       }
425         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
426                 goto out;
427         newattrs.ia_valid =  ATTR_CTIME;
428 @@ -723,6 +749,7 @@
429         }
430         if (!S_ISDIR(inode->i_mode))
431                 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
432 +
433         down(&inode->i_sem);
434         error = notify_change(dentry, &newattrs);
435         up(&inode->i_sem);
436 Index: linux-2.6.5-12.1/fs/exec.c
437 ===================================================================
438 --- linux-2.6.5-12.1.orig/fs/exec.c     2004-05-11 15:41:54.000000000 -0400
439 +++ linux-2.6.5-12.1/fs/exec.c  2004-05-11 15:42:00.000000000 -0400
440 @@ -1435,7 +1435,7 @@
441                 goto close_fail;
442         if (!file->f_op->write)
443                 goto close_fail;
444 -       if (do_truncate(file->f_dentry, 0) != 0)
445 +       if (do_truncate(file->f_dentry, 0, 0) != 0)
446                 goto close_fail;
447  
448         retval = binfmt->core_dump(signr, regs, file);
449 Index: linux-2.6.5-12.1/include/linux/fs.h
450 ===================================================================
451 --- linux-2.6.5-12.1.orig/include/linux/fs.h    2004-05-11 15:41:54.000000000 -0400
452 +++ linux-2.6.5-12.1/include/linux/fs.h 2004-05-11 15:42:00.000000000 -0400
453 @@ -878,13 +878,20 @@
454         int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
455         struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
456         int (*link) (struct dentry *,struct inode *,struct dentry *);
457 +       int (*link_raw) (struct nameidata *,struct nameidata *);
458         int (*unlink) (struct inode *,struct dentry *);
459 +       int (*unlink_raw) (struct nameidata *);
460         int (*symlink) (struct inode *,struct dentry *,const char *);
461 +       int (*symlink_raw) (struct nameidata *,const char *);
462         int (*mkdir) (struct inode *,struct dentry *,int);
463 +       int (*mkdir_raw) (struct nameidata *,int);
464         int (*rmdir) (struct inode *,struct dentry *);
465 +       int (*rmdir_raw) (struct nameidata *);
466         int (*mknod) (struct inode *,struct dentry *,int,dev_t);
467 +       int (*mknod_raw) (struct nameidata *,int,dev_t);
468         int (*rename) (struct inode *, struct dentry *,
469                         struct inode *, struct dentry *);
470 +       int (*rename_raw) (struct nameidata *, struct nameidata *);
471         int (*readlink) (struct dentry *, char __user *,int);
472         int (*follow_link) (struct dentry *, struct nameidata *);
473         void (*truncate) (struct inode *);
474 @@ -1182,7 +1189,7 @@
475  
476  /* fs/open.c */
477  
478 -extern int do_truncate(struct dentry *, loff_t start);
479 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
480  extern struct file *filp_open(const char *, int, int);
481  extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
482  extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
483 Index: linux-2.6.5-12.1/net/unix/af_unix.c
484 ===================================================================
485 --- linux-2.6.5-12.1.orig/net/unix/af_unix.c    2004-04-03 22:37:36.000000000 -0500
486 +++ linux-2.6.5-12.1/net/unix/af_unix.c 2004-05-11 15:42:00.000000000 -0400
487 @@ -676,6 +676,7 @@
488         int err = 0;
489         
490         if (sunname->sun_path[0]) {
491 +               intent_init(&nd.intent, IT_LOOKUP);
492                 err = path_lookup(sunname->sun_path, LOOKUP_FOLLOW, &nd);
493                 if (err)
494                         goto fail;