Whamcloud - gitweb
Branch b1_8
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs_intent-2.6-rhel4.patch
1 diff -rup RH_2_6_9_55.orig/fs/cifs/dir.c RH_2_6_9_55/fs/cifs/dir.c
2 --- RH_2_6_9_55.orig/fs/cifs/dir.c
3 +++ RH_2_6_9_55/fs/cifs/dir.c
4 @@ -157,11 +157,7 @@ cifs_create(struct inode *inode, struct 
5
6  #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)
7         if(nd && (nd->flags & LOOKUP_OPEN)) {
8 -#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,5) /* SUSE included Lustre patch */
9                 int oflags = nd->intent.it_flags;
10 -#else
11 -               int oflags = nd->intent.open.flags;
12 -#endif
13
14                 desiredAccess = 0;
15                 if (oflags & FMODE_READ)
16 diff -rup RH_2_6_9_55.orig/fs/exec.c RH_2_6_9_55/fs/exec.c
17 --- RH_2_6_9_55.orig/fs/exec.c
18 +++ RH_2_6_9_55/fs/exec.c
19 @@ -126,9 +126,10 @@ asmlinkage long sys_uselib(const char __
20         struct file * file;
21         struct nameidata nd;
22         int error;
23 -
24 -       nd.intent.open.flags = FMODE_READ|FMODE_EXEC;
25 -       error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
26 +       intent_init(&nd.intent, IT_OPEN);
27 +  
28 +       nd.intent.it_flags = FMODE_READ|FMODE_EXEC;
29 +       error = __user_walk_it(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
30         if (error)
31                 goto out;
32  
33 @@ -140,7 +141,7 @@ asmlinkage long sys_uselib(const char __
34         if (error)
35                 goto exit;
36  
37 -       file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
38 +       file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
39         error = PTR_ERR(file);
40         if (IS_ERR(file))
41                 goto out;
42 @@ -489,8 +490,9 @@ struct file *open_exec(const char *name)
43         int err;
44         struct file *file;
45  
46 -       nd.intent.open.flags = FMODE_READ|FMODE_EXEC;
47 -       err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
48 +       intent_init(&nd.intent, IT_OPEN);
49 +       nd.intent.it_flags = FMODE_READ|FMODE_EXEC;
50 +       err = path_lookup_it(name, LOOKUP_FOLLOW, &nd);
51         file = ERR_PTR(err);
52  
53         if (!err) {
54 @@ -501,9 +503,10 @@ struct file *open_exec(const char *name)
55                         int err = permission(inode, MAY_EXEC, &nd);
56                         file = ERR_PTR(err);
57                         if (!err) {
58 -                               file = dentry_open(nd.dentry, nd.mnt, 
59 +                               file = dentry_open_it(nd.dentry, nd.mnt, 
60                                         force_o_largefile() ? 
61 -                                       O_RDONLY|O_LARGEFILE : O_RDONLY);
62 +                                       O_RDONLY|O_LARGEFILE : O_RDONLY,
63 +                                       &nd.intent);
64                                 if (!IS_ERR(file)) {
65                                         err = deny_write_access(file);
66                                         if (err) {
67 diff -rup RH_2_6_9_55.orig/fs/inode.c RH_2_6_9_55/fs/inode.c
68 --- RH_2_6_9_55.orig/fs/inode.c
69 +++ RH_2_6_9_55/fs/inode.c
70 @@ -235,6 +235,7 @@ void __iget(struct inode * inode)
71         inodes_stat.nr_unused--;
72  }
73  
74 +EXPORT_SYMBOL(__iget);
75  /**
76   * clear_inode - clear an inode
77   * @inode: inode to clear
78 diff -rup RH_2_6_9_55.orig/fs/namei.c RH_2_6_9_55/fs/namei.c
79 --- RH_2_6_9_55.orig/fs/namei.c
80 +++ RH_2_6_9_55/fs/namei.c
81 @@ -282,8 +282,19 @@ int deny_write_access(struct file * file
82         return 0;
83  }
84  
85 +void intent_release(struct lookup_intent *it)
86 +{
87 +       if (!it)
88 +               return;
89 +       if (it->it_magic != INTENT_MAGIC)
90 +               return;
91 +       if (it->it_op_release)
92 +               it->it_op_release(it);
93 +}
94 +
95  void path_release(struct nameidata *nd)
96  {
97 +       intent_release(&nd->intent);
98         dput(nd->dentry);
99         mntput(nd->mnt);
100  }
101 @@ -395,8 +406,12 @@ static struct dentry * real_lookup(struc
102  {
103         struct dentry * result;
104         struct inode *dir = parent->d_inode;
105 -
106 +       int counter = 0;
107 +       
108 +again:
109         down(&dir->i_sem);
110 +       counter++;
111 +
112         /*
113          * First re-do the cached lookup just in case it was created
114          * while we waited for the directory semaphore..
115 @@ -433,8 +448,12 @@ static struct dentry * real_lookup(struc
116         up(&dir->i_sem);
117         if (result->d_op && result->d_op->d_revalidate) {
118                 result = do_revalidate(result, nd);
119 -               if (!result)
120 -                       result = ERR_PTR(-ENOENT);
121 +               if (!result) {
122 +                       if (counter > 10)
123 +                               result = ERR_PTR(-ESTALE);
124 +                       if (!IS_ERR(result))
125 +                               goto again;
126 +               }
127         }
128         return result;
129  }
130 @@ -464,6 +483,7 @@ static inline int __vfs_follow_link(stru
131  {
132         int res = 0;
133         char *name;
134 +
135         if (IS_ERR(link))
136                 goto fail;
137  
138 @@ -473,6 +493,7 @@ static inline int __vfs_follow_link(stru
139                         /* weird __emul_prefix() stuff did it */
140                         goto out;
141         }
142 +       intent_reset_fs_part(&nd->intent);
143         res = link_path_walk(link, nd);
144  out:
145         if (nd->depth || res || nd->last_type!=LAST_NORM)
146 @@ -681,6 +702,33 @@ fail:
147         return PTR_ERR(dentry);
148  }
149  
150 +static int revalidate_special(struct nameidata *nd)
151 +{
152 +       struct dentry *dentry = nd->dentry;
153 +       int err, counter = 0;
154 +
155 + revalidate_again:
156 +       if (!dentry->d_op || !dentry->d_op->d_revalidate)
157 +               return 0;
158 +       if (!dentry->d_op->d_revalidate(dentry, nd)) {
159 +               struct dentry *new;
160 +               if ((err = permission(dentry->d_parent->d_inode, MAY_EXEC, nd)))
161 +                       return err;
162 +               new = real_lookup(dentry->d_parent, &dentry->d_name, nd);
163 +               if (IS_ERR(new))
164 +                       return PTR_ERR(new);
165 +               d_invalidate(dentry);
166 +               dput(dentry);
167 +               nd->dentry = dentry = new;
168 +               counter++;
169 +               if (counter < 10)
170 +                       goto revalidate_again;
171 +               //printk("excessive revalidate_it loops\n");
172 +               return -ESTALE;
173 +       }
174 +       return 0;
175 +}
176 +
177  /*
178   * Name resolution.
179   * This is the basic name resolution function, turning a pathname into
180 @@ -782,13 +830,17 @@ static fastcall int __link_path_walk(con
181                         goto out_dput;
182  
183                 if (inode->i_op->follow_link) {
184 +                       int save_flags = nd->flags;
185                         mntget(next.mnt);
186                         if (next.mnt != nd->mnt) {
187                                 dput(nd->dentry);
188                                 nd->mnt = next.mnt;
189                                 nd->dentry = dget(next.dentry);
190                         }
191 +                       nd->flags |= LOOKUP_LINK_NOTLAST;
192                         err = do_follow_link(next.dentry, nd);
193 +                       if (!(save_flags & LOOKUP_LINK_NOTLAST))
194 +                               nd->flags &= ~LOOKUP_LINK_NOTLAST;
195                         dput(next.dentry);
196                         mntput(next.mnt);
197                         if (err)
198 @@ -828,14 +880,34 @@ last_component:
199                                 inode = nd->dentry->d_inode;
200                                 /* fallthrough */
201                         case 1:
202 +                               nd->flags |= LOOKUP_LAST;
203 +                               err = revalidate_special(nd);
204 +                               nd->flags &= ~LOOKUP_LAST;
205 +                               if (!nd->dentry->d_inode)
206 +                                       err = -ENOENT;
207 +                               if (err) {
208 +                                       path_release(nd);
209 +                                       goto return_err;
210 +                               }
211 +                               if (lookup_flags & LOOKUP_DIRECTORY) {
212 +                                       err = -ENOTDIR;
213 +                                       if (!nd->dentry->d_inode->i_op ||
214 +                                           !nd->dentry->d_inode->i_op->lookup){
215 +                                               path_release(nd);
216 +                                               goto return_err;
217 +                                       }
218 +                               }
219                                 goto return_reval;
220                 }
221 +               
222                 if (nd->dentry->d_op && nd->dentry->d_op->d_hash) {
223                         err = nd->dentry->d_op->d_hash(nd->dentry, &this);
224                         if (err < 0)
225                                 break;
226                 }
227 +               nd->flags |= LOOKUP_LAST;
228                 err = do_lookup(nd, &this, &next, atomic);
229 +               nd->flags &= ~LOOKUP_LAST;
230                 if (err)
231                         break;
232                 follow_mount(&next.mnt, &next.dentry);
233 @@ -1007,7 +1079,7 @@ set_it:
234  }
235  
236  /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
237 -int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata *nd)
238 +int fastcall path_lookup_it(const char *name, unsigned int flags, struct nameidata *nd)
239  {
240         int retval = 0;
241  
242 @@ -1041,6 +1113,12 @@ out:
243         return retval;
244  }
245  
246 +int fastcall path_lookup(const char *name, unsigned int flags, struct nameidata *nd)
247 +{
248 +       intent_init(&nd->intent, IT_GETATTR);
249 +       return path_lookup_it(name, flags, nd);
250 +}
251 +
252  /*
253   * Restricted form of lookup. Doesn't follow links, single-component only,
254   * needs parent already locked. Doesn't follow mounts.
255 @@ -1091,7 +1169,7 @@ struct dentry * lookup_hash(struct qstr 
256  }
257  
258  /* SMP-safe */
259 -struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
260 +struct dentry * lookup_one_len_it(const char * name, struct dentry * base, int len, struct nameidata *nd)
261  {
262         unsigned long hash;
263         struct qstr this;
264 @@ -1111,11 +1189,16 @@ struct dentry * lookup_one_len(const cha
265         }
266         this.hash = end_name_hash(hash);
267  
268 -       return lookup_hash(&this, base);
269 +       return __lookup_hash(&this, base, nd);
270  access:
271         return ERR_PTR(-EACCES);
272  }
273  
274 +struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
275 +{
276 +       return lookup_one_len_it(name, base, len, NULL);
277 +}
278 +
279  /*
280   *     namei()
281   *
282 @@ -1127,18 +1210,24 @@ access:
283   * that namei follows links, while lnamei does not.
284   * SMP-safe
285   */
286 -int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
287 +int fastcall __user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd)
288  {
289         char *tmp = getname(name);
290         int err = PTR_ERR(tmp);
291  
292         if (!IS_ERR(tmp)) {
293 -               err = path_lookup(tmp, flags, nd);
294 +               err = path_lookup_it(tmp, flags, nd);
295                 putname(tmp);
296         }
297         return err;
298  }
299  
300 +int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
301 +{
302 +       intent_init(&nd->intent, IT_LOOKUP);
303 +       return __user_walk_it(name, flags, nd);
304 +}
305 +
306  /*
307   * It's inline, so penalty for filesystems that don't use sticky bit is
308   * minimal.
309 @@ -1384,7 +1473,7 @@ int may_open(struct nameidata *nd, int a
310                 if (!error) {
311                         DQUOT_INIT(inode);
312                         
313 -                       error = do_truncate(dentry, 0, ATTR_MTIME|ATTR_CTIME);
314 +                       error = do_truncate(dentry, 0, ATTR_MTIME|ATTR_CTIME|ATTR_FROM_OPEN);
315                 }
316                 put_write_access(inode);
317                 if (error)
318 @@ -1425,14 +1514,14 @@ int open_namei(const char * pathname, in
319                 acc_mode |= MAY_APPEND;
320  
321         /* Fill in the open() intent data */
322 -       nd->intent.open.flags = flag;
323 -       nd->intent.open.create_mode = mode;
324 +       nd->intent.it_flags = flag;
325 +       nd->intent.it_create_mode = mode;
326  
327         /*
328          * The simplest case - just a plain lookup.
329          */
330         if (!(flag & O_CREAT)) {
331 -               error = path_lookup(pathname, lookup_flags(flag)|LOOKUP_OPEN, nd);
332 +               error = path_lookup_it(pathname, lookup_flags(flag)|LOOKUP_OPEN, nd);
333                 if (error)
334                         return error;
335                 goto ok;
336 @@ -1441,7 +1530,8 @@ int open_namei(const char * pathname, in
337         /*
338          * Create - we need to know the parent.
339          */
340 -       error = path_lookup(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
341 +       nd->intent.it_op |= IT_CREAT;
342 +       error = path_lookup_it(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
343         if (error)
344                 return error;
345  
346 @@ -1457,7 +1547,9 @@ int open_namei(const char * pathname, in
347         dir = nd->dentry;
348         nd->flags &= ~LOOKUP_PARENT;
349         down(&dir->d_inode->i_sem);
350 +       nd->flags |= LOOKUP_LAST;
351         dentry = __lookup_hash(&nd->last, nd->dentry, nd);
352 +       nd->flags &= ~LOOKUP_LAST;
353  
354  do_last:
355         error = PTR_ERR(dentry);
356 @@ -1570,7 +1662,9 @@ do_link:
357         }
358         dir = nd->dentry;
359         down(&dir->d_inode->i_sem);
360 +       nd->flags |= LOOKUP_LAST;
361         dentry = __lookup_hash(&nd->last, nd->dentry, nd);
362 +       nd->flags &= ~LOOKUP_LAST;
363         __putname(nd->last.name);
364         goto do_last;
365  }
366 @@ -1644,10 +1738,20 @@ asmlinkage long sys_mknod(const char __u
367         tmp = getname(filename);
368         if (IS_ERR(tmp))
369                 return PTR_ERR(tmp);
370 -
371 -       error = path_lookup(tmp, LOOKUP_PARENT, &nd);
372 +               
373 +       intent_init(&nd.intent, IT_LOOKUP);
374 +       error = path_lookup_it(tmp, LOOKUP_PARENT, &nd);
375         if (error)
376                 goto out;
377 +
378 +       if (nd.dentry->d_inode->i_op->mknod_raw) {
379 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
380 +               error = op->mknod_raw(&nd, mode, dev);
381 +               /* the file system wants to use normal vfs path now */
382 +               if (error != -EOPNOTSUPP)
383 +                       goto out2;
384 +       }
385 +
386         dentry = lookup_create(&nd, 0);
387         error = PTR_ERR(dentry);
388  
389 @@ -1674,6 +1778,7 @@ asmlinkage long sys_mknod(const char __u
390                 dput(dentry);
391         }
392         up(&nd.dentry->d_inode->i_sem);
393 +out2:
394         path_release(&nd);
395  out:
396         putname(tmp);
397 @@ -1716,10 +1821,20 @@ asmlinkage long sys_mkdir(const char __u
398         if (!IS_ERR(tmp)) {
399                 struct dentry *dentry;
400                 struct nameidata nd;
401 +               intent_init(&nd.intent, IT_LOOKUP);
402  
403 -               error = path_lookup(tmp, LOOKUP_PARENT, &nd);
404 +               error = path_lookup_it(tmp, LOOKUP_PARENT, &nd);
405                 if (error)
406                         goto out;
407 +
408 +               if (nd.dentry->d_inode->i_op->mkdir_raw) {
409 +                       struct inode_operations *op = nd.dentry->d_inode->i_op;
410 +                       error = op->mkdir_raw(&nd, mode);
411 +                       /* the file system wants to use normal vfs path now */
412 +                       if (error != -EOPNOTSUPP)
413 +                               goto out2;
414 +               }
415 +
416                 dentry = lookup_create(&nd, 1);
417                 error = PTR_ERR(dentry);
418                 if (!IS_ERR(dentry)) {
419 @@ -1729,6 +1844,7 @@ asmlinkage long sys_mkdir(const char __u
420                         dput(dentry);
421                 }
422                 up(&nd.dentry->d_inode->i_sem);
423 +out2:
424                 path_release(&nd);
425  out:
426                 putname(tmp);
427 @@ -1814,7 +1930,8 @@ asmlinkage long sys_rmdir(const char __u
428         if(IS_ERR(name))
429                 return PTR_ERR(name);
430  
431 -       error = path_lookup(name, LOOKUP_PARENT, &nd);
432 +       intent_init(&nd.intent, IT_LOOKUP);
433 +       error = path_lookup_it(name, LOOKUP_PARENT, &nd);
434         if (error)
435                 goto exit;
436  
437 @@ -1829,6 +1946,16 @@ asmlinkage long sys_rmdir(const char __u
438                         error = -EBUSY;
439                         goto exit1;
440         }
441 +
442 +       if (nd.dentry->d_inode->i_op->rmdir_raw) {
443 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
444 +
445 +               error = op->rmdir_raw(&nd);
446 +               /* the file system wants to use normal vfs path now */
447 +               if (error != -EOPNOTSUPP)
448 +                       goto exit1;
449 +       }
450 +
451         down(&nd.dentry->d_inode->i_sem);
452         dentry = lookup_hash(&nd.last, nd.dentry);
453         error = PTR_ERR(dentry);
454 @@ -1892,12 +2019,22 @@ asmlinkage long sys_unlink(const char __
455         if(IS_ERR(name))
456                 return PTR_ERR(name);
457  
458 -       error = path_lookup(name, LOOKUP_PARENT, &nd);
459 +       intent_init(&nd.intent, IT_LOOKUP);
460 +       error = path_lookup_it(name, LOOKUP_PARENT, &nd);
461         if (error)
462                 goto exit;
463         error = -EISDIR;
464         if (nd.last_type != LAST_NORM)
465                 goto exit1;
466 +       
467 +       if (nd.dentry->d_inode->i_op->unlink_raw) {
468 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
469 +               error = op->unlink_raw(&nd);
470 +               /* the file system wants to use normal vfs path now */
471 +               if (error != -EOPNOTSUPP)
472 +                       goto exit1;
473 +       }
474 +
475         down(&nd.dentry->d_inode->i_sem);
476         dentry = lookup_hash(&nd.last, nd.dentry);
477         error = PTR_ERR(dentry);
478 @@ -1965,10 +2102,20 @@ asmlinkage long sys_symlink(const char _
479         if (!IS_ERR(to)) {
480                 struct dentry *dentry;
481                 struct nameidata nd;
482 +               intent_init(&nd.intent, IT_LOOKUP);
483  
484 -               error = path_lookup(to, LOOKUP_PARENT, &nd);
485 +               error = path_lookup_it(to, LOOKUP_PARENT, &nd);
486                 if (error)
487                         goto out;
488 +
489 +               if (nd.dentry->d_inode->i_op->symlink_raw) {
490 +                       struct inode_operations *op = nd.dentry->d_inode->i_op;
491 +                       error = op->symlink_raw(&nd, from);
492 +                       /* the file system wants to use normal vfs path now */
493 +                       if (error != -EOPNOTSUPP)
494 +                               goto out2;
495 +               }
496 +
497                 dentry = lookup_create(&nd, 0);
498                 error = PTR_ERR(dentry);
499                 if (!IS_ERR(dentry)) {
500 @@ -1976,6 +2123,7 @@ asmlinkage long sys_symlink(const char _
501                         dput(dentry);
502                 }
503                 up(&nd.dentry->d_inode->i_sem);
504 +out2:
505                 path_release(&nd);
506  out:
507                 putname(to);
508 @@ -2045,15 +2193,26 @@ asmlinkage long sys_link(const char __us
509         if (IS_ERR(to))
510                 return PTR_ERR(to);
511  
512 -       error = __user_walk(oldname, 0, &old_nd);
513 +       intent_init(&old_nd.intent, IT_LOOKUP);
514 +       error = __user_walk_it(oldname, 0, &old_nd);
515         if (error)
516                 goto exit;
517 -       error = path_lookup(to, LOOKUP_PARENT, &nd);
518 +               
519 +       intent_init(&nd.intent, IT_LOOKUP);             
520 +       error = path_lookup_it(to, LOOKUP_PARENT, &nd);
521         if (error)
522                 goto out;
523         error = -EXDEV;
524         if (old_nd.mnt != nd.mnt)
525                 goto out_release;
526 +       if (nd.dentry->d_inode->i_op->link_raw) {
527 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
528 +               error = op->link_raw(&old_nd, &nd);
529 +               /* the file system wants to use normal vfs path now */
530 +               if (error != -EOPNOTSUPP)
531 +                       goto out_release;
532 +       }
533 +
534         new_dentry = lookup_create(&nd, 0);
535         error = PTR_ERR(new_dentry);
536         if (!IS_ERR(new_dentry)) {
537 @@ -2229,11 +2388,13 @@ static inline int do_rename(const char *
538         struct dentry * trap;
539         struct nameidata oldnd, newnd;
540  
541 -       error = path_lookup(oldname, LOOKUP_PARENT, &oldnd);
542 +       intent_init(&oldnd.intent, IT_LOOKUP);
543 +       error = path_lookup_it(oldname, LOOKUP_PARENT, &oldnd);
544         if (error)
545                 goto exit;
546  
547 -       error = path_lookup(newname, LOOKUP_PARENT, &newnd);
548 +       intent_init(&newnd.intent, IT_LOOKUP);
549 +       error = path_lookup_it(newname, LOOKUP_PARENT, &newnd);
550         if (error)
551                 goto exit1;
552  
553 @@ -2250,6 +2411,13 @@ static inline int do_rename(const char *
554         if (newnd.last_type != LAST_NORM)
555                 goto exit2;
556  
557 +       if (old_dir->d_inode->i_op->rename_raw) {
558 +               error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
559 +               /* the file system wants to use normal vfs path now */
560 +               if (error != -EOPNOTSUPP)
561 +                       goto exit2;
562 +       }
563 +
564         trap = lock_rename(new_dir, old_dir);
565  
566         old_dentry = lookup_hash(&oldnd.last, old_dir);
567 @@ -2281,8 +2449,7 @@ static inline int do_rename(const char *
568         if (new_dentry == trap)
569                 goto exit5;
570  
571 -       error = vfs_rename(old_dir->d_inode, old_dentry,
572 -                                  new_dir->d_inode, new_dentry);
573 +       error = vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry);
574  exit5:
575         dput(new_dentry);
576  exit4:
577 @@ -2473,6 +2640,7 @@ EXPORT_SYMBOL(page_readlink);
578  EXPORT_SYMBOL(page_symlink);
579  EXPORT_SYMBOL(page_symlink_inode_operations);
580  EXPORT_SYMBOL(path_lookup);
581 +EXPORT_SYMBOL(path_lookup_it);
582  EXPORT_SYMBOL(path_release);
583  EXPORT_SYMBOL(path_walk);
584  EXPORT_SYMBOL(permission);
585 diff -urNp RH_2_6_9_42_0_3.orig/fs/namespace.c RH_2_6_9_42_0_3/fs/namespace.c
586 --- RH_2_6_9_42_0_3.orig/fs/namespace.c
587 +++ RH_2_6_9_42_0_3/fs/namespace.c
588 @@ -114,6 +115,7 @@ static inline int check_mnt(struct vfsmo
589  
590  static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd)
591  {
592 +       memset(old_nd, 0, sizeof(*old_nd));
593         old_nd->dentry = mnt->mnt_mountpoint;
594         old_nd->mnt = mnt->mnt_parent;
595         mnt->mnt_parent = mnt;
596 @@ -441,6 +442,8 @@ static int do_umount(struct vfsmount *mn
597          */
598  
599         lock_kernel();
600 +       if (sb->s_op->umount_lustre)
601 +               sb->s_op->umount_lustre(sb);
602         if( (flags&MNT_FORCE) && sb->s_op->umount_begin)
603                 sb->s_op->umount_begin(sb);
604         unlock_kernel();
605 @@ -665,7 +668,8 @@ static int do_loopback(struct nameidata 
606                 return err;
607         if (!old_name || !*old_name)
608                 return -EINVAL;
609 -       err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
610 +       intent_init(&old_nd.intent, IT_LOOKUP);
611 +       err = path_lookup_it(old_name, LOOKUP_FOLLOW, &old_nd);
612         if (err)
613                 return err;
614  
615 @@ -739,7 +743,8 @@ static int do_move_mount(struct nameidat
616                 return -EPERM;
617         if (!old_name || !*old_name)
618                 return -EINVAL;
619 -       err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
620 +       intent_init(&old_nd.intent, IT_LOOKUP);
621 +       err = path_lookup_it(old_name, LOOKUP_FOLLOW, &old_nd);
622         if (err)
623                 return err;
624  
625 @@ -1074,7 +1079,8 @@ long do_mount(char * dev_name, char * di
626         flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_ACTIVE);
627  
628         /* ... and get the mountpoint */
629 -       retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
630 +       intent_init(&nd.intent, IT_LOOKUP);     
631 +       retval = path_lookup_it(dir_name, LOOKUP_FOLLOW, &nd);
632         if (retval)
633                 return retval;
634  
635 diff -rup RH_2_6_9_55.orig/fs/nfs/dir.c RH_2_6_9_55/fs/nfs/dir.c
636 --- RH_2_6_9_55.orig/fs/nfs/dir.c
637 +++ RH_2_6_9_55/fs/nfs/dir.c
638 @@ -839,7 +839,7 @@ int nfs_is_exclusive_create(struct inode
639                 return 0;
640         if (!nd || (nd->flags & LOOKUP_CONTINUE) || !(nd->flags & LOOKUP_CREATE))
641                 return 0;
642 -       return (nd->intent.open.flags & O_EXCL) != 0;
643 +       return (nd->intent.it_flags & O_EXCL) != 0;
644  }
645  
646  static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd)
647 @@ -915,7 +915,7 @@ static int is_atomic_open(struct inode *
648         if (nd->flags & LOOKUP_DIRECTORY)
649                 return 0;
650         /* Are we trying to write to a read only partition? */
651 -       if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
652 +       if (IS_RDONLY(dir) && (nd->intent.it_flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
653                 return 0;
654         return 1;
655  }
656 @@ -936,7 +936,7 @@ static struct dentry *nfs_atomic_lookup(
657         dentry->d_op = NFS_PROTO(dir)->dentry_ops;
658  
659         /* Let vfs_create() deal with O_EXCL */
660 -       if (nd->intent.open.flags & O_EXCL)
661 +       if (nd->intent.it_flags & O_EXCL)
662                 goto no_entry;
663  
664         /* Open the file on the server */
665 @@ -948,7 +948,7 @@ static struct dentry *nfs_atomic_lookup(
666                 goto out;
667         }
668  
669 -       if (nd->intent.open.flags & O_CREAT) {
670 +       if (nd->intent.it_flags & O_CREAT) {
671                 nfs_begin_data_update(dir);
672                 inode = nfs4_atomic_open(dir, dentry, nd);
673                 nfs_end_data_update(dir);
674 @@ -967,7 +967,7 @@ static struct dentry *nfs_atomic_lookup(
675                         case -ENOTDIR:
676                                 goto no_open;
677                         case -ELOOP:
678 -                               if (!(nd->intent.open.flags & O_NOFOLLOW))
679 +                               if (!(nd->intent.it_flags & O_NOFOLLOW))
680                                         goto no_open;
681                         /* case -EINVAL: */
682                         default:
683 @@ -1005,7 +1005,7 @@ static int nfs_open_revalidate(struct de
684         /* NFS only supports OPEN on regular files */
685         if (!S_ISREG(inode->i_mode))
686                 goto no_open;
687 -       openflags = nd->intent.open.flags;
688 +       openflags = nd->intent.it_flags;
689         /* We cannot do exclusive creation on a positive dentry */
690         if ((openflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
691                 goto no_open;
692 @@ -1213,7 +1213,7 @@ static int nfs_create(struct inode *dir,
693         attr.ia_valid = ATTR_MODE;
694  
695         if (nd && (nd->flags & LOOKUP_CREATE))
696 -               open_flags = nd->intent.open.flags;
697 +               open_flags = nd->intent.it_flags;
698  
699         /*
700          * The 0 argument passed into the create function should one day
701 diff -rup RH_2_6_9_55.orig/fs/nfs/nfs4proc.c RH_2_6_9_55/fs/nfs/nfs4proc.c
702 --- RH_2_6_9_55.orig/fs/nfs/nfs4proc.c
703 +++ RH_2_6_9_55/fs/nfs/nfs4proc.c
704 @@ -770,27 +770,27 @@ nfs4_atomic_open(struct inode *dir, stru
705         struct nfs4_inc_open *inc_open;
706  
707         if (nd->flags & LOOKUP_CREATE) {
708 -               attr.ia_mode = nd->intent.open.create_mode;
709 +               attr.ia_mode = nd->intent.it_create_mode;
710                 attr.ia_valid = ATTR_MODE;
711                 if (!IS_POSIXACL(dir))
712                         attr.ia_mode &= ~current->fs->umask;
713         } else {
714                 attr.ia_valid = 0;
715 -               BUG_ON(nd->intent.open.flags & O_CREAT);
716 +               BUG_ON(nd->intent.it_flags & O_CREAT);
717         }
718  
719         /* track info in case the open never completes */
720         if (!(inc_open = kmalloc(sizeof(*inc_open), GFP_KERNEL)))
721                 return ERR_PTR(-ENOMEM);
722         cred = rpcauth_lookupcred(NFS_SERVER(dir)->client->cl_auth, 0);
723 -       state = nfs4_do_open(dir, &dentry->d_name, nd->intent.open.flags, &attr, cred);
724 +       state = nfs4_do_open(dir, &dentry->d_name, nd->intent.it_flags, &attr, cred);
725         put_rpccred(cred);
726         if (IS_ERR(state)) {
727                 kfree(inc_open);
728                 return (struct inode *)state;
729         }
730         inc_open->task = current;
731 -       inc_open->flags = nd->intent.open.flags;
732 +       inc_open->flags = nd->intent.it_flags;
733         INIT_LIST_HEAD(&inc_open->state);
734         spin_lock(&state->inode->i_lock);
735         list_add(&inc_open->state, &state->inc_open);
736 diff -rup RH_2_6_9_55.orig/fs/open.c RH_2_6_9_55/fs/open.c
737 --- RH_2_6_9_55.orig/fs/open.c
738 +++ RH_2_6_9_55/fs/open.c
739 @@ -195,6 +195,7 @@ out:
740  int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs)
741  {
742         int err;
743 +       struct inode_operations *op = dentry->d_inode->i_op;
744         struct iattr newattrs;
745  
746         /* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
747 @@ -204,8 +205,16 @@ int do_truncate(struct dentry *dentry, l
748         newattrs.ia_size = length;
749         newattrs.ia_valid = ATTR_SIZE | time_attrs;
750         down(&dentry->d_inode->i_sem);
751 -       err = notify_change(dentry, &newattrs);
752 -       up(&dentry->d_inode->i_sem);
753 +       if (op->setattr_raw) {
754 +               newattrs.ia_valid |= ATTR_RAW;
755 +               newattrs.ia_ctime = CURRENT_TIME;
756 +               down_write(&dentry->d_inode->i_alloc_sem);
757 +               err = op->setattr_raw(dentry->d_inode, &newattrs);
758 +               up_write(&dentry->d_inode->i_alloc_sem);
759 +       } else
760 +               err = notify_change(dentry, &newattrs);
761 +       up(&dentry->d_inode->i_sem);            
762 +
763         return err;
764  }
765
766 @@ -214,12 +223,13 @@ static inline long do_sys_truncate(const
767         struct nameidata nd;
768         struct inode * inode;
769         int error;
770 -
771 +       
772         error = -EINVAL;
773         if (length < 0) /* sorry, but loff_t says... */
774                 goto out;
775 -
776 -       error = user_path_walk(path, &nd);
777 +               
778 +       intent_init(&nd.intent, IT_GETATTR);
779 +       error = user_path_walk_it(path, &nd);
780         if (error)
781                 goto out;
782         inode = nd.dentry->d_inode;
783 @@ -390,9 +400,19 @@ asmlinkage long sys_utime(char __user * 
784                     (error = permission(inode,MAY_WRITE,&nd)) != 0)
785                         goto dput_and_out;
786         }
787 -       down(&inode->i_sem);
788 -       error = notify_change(nd.dentry, &newattrs);
789 -       up(&inode->i_sem);
790 +       if (inode->i_op->setattr_raw) {
791 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
792 +
793 +               newattrs.ia_valid |= ATTR_RAW;
794 +               error = op->setattr_raw(inode, &newattrs);
795 +               /* the file system wants to use normal vfs path now */
796 +               if (error != -EOPNOTSUPP)
797 +                       goto dput_and_out;
798 +       } else {
799 +               down(&inode->i_sem);
800 +               error = notify_change(nd.dentry, &newattrs);
801 +               up(&inode->i_sem);
802 +       }
803  dput_and_out:
804         path_release(&nd);
805  out:
806 @@ -443,9 +463,19 @@ long do_utimes(char __user * filename, s
807                     (error = permission(inode,MAY_WRITE,&nd)) != 0)
808                         goto dput_and_out;
809         }
810 -       down(&inode->i_sem);
811 -       error = notify_change(nd.dentry, &newattrs);
812 -       up(&inode->i_sem);
813 +       if (inode->i_op->setattr_raw) {
814 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
815 +
816 +               newattrs.ia_valid |= ATTR_RAW;
817 +               error = op->setattr_raw(inode, &newattrs);
818 +               /* the file system wants to use normal vfs path now */
819 +               if (error != -EOPNOTSUPP)
820 +                       goto dput_and_out;
821 +       } else {
822 +               down(&inode->i_sem);
823 +               error = notify_change(nd.dentry, &newattrs);
824 +               up(&inode->i_sem);
825 +       }
826  dput_and_out:
827         path_release(&nd);
828  out:
829 @@ -473,6 +503,7 @@ asmlinkage long sys_access(const char __
830         int old_fsuid, old_fsgid;
831         kernel_cap_t old_cap;
832         int res;
833 +       intent_init(&nd.intent, IT_GETATTR);
834  
835         if (mode & ~S_IRWXO)    /* where's F_OK, X_OK, W_OK, R_OK? */
836                 return -EINVAL;
837 @@ -497,13 +528,14 @@ asmlinkage long sys_access(const char __
838         else
839                 current->cap_effective = current->cap_permitted;
840  
841 -       res = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
842 +       res = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
843         if (!res) {
844                 res = permission(nd.dentry->d_inode, mode, &nd);
845                 /* SuS v2 requires we report a read only fs too */
846                 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
847                    && !special_file(nd.dentry->d_inode->i_mode))
848                         res = -EROFS;
849 +
850                 path_release(&nd);
851         }
852  
853 @@ -518,8 +550,9 @@ asmlinkage long sys_chdir(const char __u
854  {
855         struct nameidata nd;
856         int error;
857 +       intent_init(&nd.intent, IT_GETATTR);
858  
859 -       error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
860 +       error = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
861         if (error)
862                 goto out;
863  
864 @@ -571,8 +604,9 @@ asmlinkage long sys_chroot(const char __
865  {
866         struct nameidata nd;
867         int error;
868 +       intent_init(&nd.intent, IT_GETATTR);
869  
870 -       error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
871 +       error = __user_walk_it(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
872         if (error)
873                 goto out;
874  
875 @@ -595,36 +629,52 @@ out:
876  
877  EXPORT_SYMBOL_GPL(sys_chroot);
878  
879 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
880 +int chmod_common(struct dentry *dentry, mode_t mode)
881  {
882 -       struct inode * inode;
883 -       struct dentry * dentry;
884 -       struct file * file;
885 -       int err = -EBADF;
886 +       struct inode * inode = dentry->d_inode;
887         struct iattr newattrs;
888 +       int error = -EROFS;
889  
890 -       file = fget(fd);
891 -       if (!file)
892 +       if (IS_RDONLY(inode))
893                 goto out;
894 +       
895 +       if (inode->i_op->setattr_raw) {
896 +               struct inode_operations *op = dentry->d_inode->i_op;
897  
898 -       dentry = file->f_dentry;
899 -       inode = dentry->d_inode;
900 +               newattrs.ia_mode = mode;
901 +               newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
902 +               newattrs.ia_valid |= ATTR_RAW;
903 +               error = op->setattr_raw(inode, &newattrs);
904 +               /* the file system wants to use the normal vfs path now */
905 +               if (error != -EOPNOTSUPP)
906 +                       goto out;
907 +       }
908  
909 -       err = -EROFS;
910 -       if (IS_RDONLY(inode))
911 -               goto out_putf;
912 -       err = -EPERM;
913 +       error = -EPERM;
914         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
915 -               goto out_putf;
916 +               goto out;
917 +
918         down(&inode->i_sem);
919         if (mode == (mode_t) -1)
920                 mode = inode->i_mode;
921         newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
922         newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
923 -       err = notify_change(dentry, &newattrs);
924 +       error = notify_change(dentry, &newattrs);
925         up(&inode->i_sem);
926 +out:
927 +       return error;
928 +}
929  
930 -out_putf:
931 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
932 +{
933 +       struct file * file;
934 +       int err = -EBADF;
935 +
936 +       file = fget(fd);
937 +       if (!file)
938 +               goto out;
939 +
940 +       err = chmod_common(file->f_dentry, mode);
941         fput(file);
942  out:
943         return err;
944 @@ -633,32 +683,13 @@ out:
945  asmlinkage long sys_chmod(const char __user * filename, mode_t mode)
946  {
947         struct nameidata nd;
948 -       struct inode * inode;
949         int error;
950 -       struct iattr newattrs;
951  
952         error = user_path_walk(filename, &nd);
953         if (error)
954                 goto out;
955 -       inode = nd.dentry->d_inode;
956
957 -       error = -EROFS;
958 -       if (IS_RDONLY(inode))
959 -               goto dput_and_out;
960 -
961 -       error = -EPERM;
962 -       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
963 -               goto dput_and_out;
964 -
965 -       down(&inode->i_sem);
966 -       if (mode == (mode_t) -1)
967 -               mode = inode->i_mode;
968 -       newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
969 -       newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
970 -       error = notify_change(nd.dentry, &newattrs);
971 -       up(&inode->i_sem);
972 -
973 -dput_and_out:
974 +       error = chmod_common(nd.dentry, mode);
975         path_release(&nd);
976  out:
977         return error;
978 @@ -679,6 +710,18 @@ static int chown_common(struct dentry * 
979         if (IS_RDONLY(inode))
980                 goto out;
981         error = -EPERM;
982 +       if (inode->i_op->setattr_raw) {
983 +               struct inode_operations *op = dentry->d_inode->i_op;
984 +
985 +               newattrs.ia_uid = user;
986 +               newattrs.ia_gid = group;
987 +               newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
988 +               newattrs.ia_valid |= ATTR_RAW;
989 +               error = op->setattr_raw(inode, &newattrs);
990 +               /* the file system wants to use normal vfs path now */
991 +               if (error != -EOPNOTSUPP)
992 +                       return error;
993 +       }
994         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
995                 goto out;
996         newattrs.ia_valid =  ATTR_CTIME;
997 @@ -692,6 +735,7 @@ static int chown_common(struct dentry * 
998         }
999         if (!S_ISDIR(inode->i_mode))
1000                 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
1001 +
1002         down(&inode->i_sem);
1003         error = notify_change(dentry, &newattrs);
1004         up(&inode->i_sem);
1005 @@ -739,8 +783,6 @@ asmlinkage long sys_fchown(unsigned int 
1006         return error;
1007  }
1008  
1009 -static struct file *__dentry_open(struct dentry *, struct vfsmount *, int, struct file *);
1010 -
1011  /*
1012   * Note that while the flag value (low two bits) for sys_open means:
1013   *     00 - read-only
1014 @@ -758,8 +800,9 @@ static struct file *__dentry_open(struct
1015  struct file *filp_open(const char * filename, int flags, int mode)
1016  {
1017         int namei_flags, error;
1018 +       struct file * temp_filp;
1019         struct nameidata nd;
1020 -       struct file *f;
1021 +       intent_init(&nd.intent, IT_OPEN);
1022  
1023         namei_flags = flags;
1024         if ((namei_flags+1) & O_ACCMODE)
1025 @@ -767,16 +810,11 @@ struct file *filp_open(const char * file
1026         if (namei_flags & O_TRUNC)
1027                 namei_flags |= 2;
1028  
1029 -       error = -ENFILE;
1030 -       f = get_empty_filp();
1031 -       if (f == NULL)
1032 -               return ERR_PTR(error);
1033 -
1034         error = open_namei(filename, namei_flags, mode, &nd);
1035 -       if (!error)
1036 -               return __dentry_open(nd.dentry, nd.mnt, flags, f);
1037 -
1038 -       put_filp(f);
1039 +       if (!error) {
1040 +               temp_filp = dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent);
1041 +               return temp_filp;
1042 +       }       
1043         return ERR_PTR(error);
1044  }
1045  
1046 @@ -784,29 +822,27 @@ EXPORT_SYMBOL(filp_open);
1047  
1048  struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1049  {
1050 -       int error;
1051 -       struct file *f;
1052 +       struct lookup_intent it;
1053 +       intent_init(&it, IT_LOOKUP);
1054  
1055 -       error = -ENFILE;
1056 -       f = get_empty_filp();
1057 -       if (f == NULL) {
1058 -               dput(dentry);
1059 -               mntput(mnt);
1060 -               return ERR_PTR(error);
1061 -       }
1062 -
1063 -       return __dentry_open(dentry, mnt, flags, f);
1064 +       return dentry_open_it(dentry, mnt, flags, &it);
1065  }
1066  
1067  EXPORT_SYMBOL(dentry_open);
1068  
1069 -static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags, struct file *f)
1070 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, struct lookup_intent *it)
1071  {
1072 +       struct file *f;
1073         struct inode *inode;
1074         int error;
1075  
1076 +       error = -ENFILE;
1077 +       f = get_empty_filp();
1078 +       if (!f)
1079 +               goto cleanup_dentry;
1080         f->f_flags = flags;
1081         f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;
1082 +       f->f_it = it;
1083         inode = dentry->d_inode;
1084         if (f->f_mode & FMODE_WRITE) {
1085                 error = get_write_access(inode);
1086 @@ -825,6 +861,7 @@ static struct file *__dentry_open(struct
1087                 error = f->f_op->open(inode,f);
1088                 if (error)
1089                         goto cleanup_all;
1090 +               intent_release(it);
1091         }
1092         f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1093  
1094 @@ -849,6 +886,8 @@ cleanup_all:
1095         f->f_vfsmnt = NULL;
1096  cleanup_file:
1097         put_filp(f);
1098 +cleanup_dentry:
1099 +       intent_release(it);
1100         dput(dentry);
1101         mntput(mnt);
1102         return ERR_PTR(error);
1103 diff -rup RH_2_6_9_55.orig/fs/stat.c RH_2_6_9_55/fs/stat.c
1104 --- RH_2_6_9_55.orig/fs/stat.c
1105 +++ RH_2_6_9_55/fs/stat.c
1106 @@ -37,7 +37,7 @@ void generic_fillattr(struct inode *inod
1107  
1108  EXPORT_SYMBOL(generic_fillattr);
1109  
1110 -int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
1111 +int vfs_getattr_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat *stat)
1112  {
1113         struct inode *inode = dentry->d_inode;
1114         int retval;
1115 @@ -46,6 +46,8 @@ int vfs_getattr(struct vfsmount *mnt, st
1116         if (retval)
1117                 return retval;
1118  
1119 +       if (inode->i_op->getattr_it)
1120 +               return inode->i_op->getattr_it(mnt, dentry, it, stat);
1121         if (inode->i_op->getattr)
1122                 return inode->i_op->getattr(mnt, dentry, stat);
1123  
1124 @@ -62,7 +64,7 @@ int vfs_getattr(struct vfsmount *mnt, st
1125  
1126  EXPORT_SYMBOL(vfs_getattr);
1127  
1128 -int vfs_getattr64(struct vfsmount *mnt, struct dentry *dentry, struct kstat64 *stat)
1129 +int vfs_getattr64_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat64 *stat)
1130  {
1131         struct inode *inode = dentry->d_inode;
1132         int retval;
1133 @@ -79,6 +81,13 @@ int vfs_getattr64(struct vfsmount *mnt, 
1134                 return ixop->getattr64(mnt, dentry, stat);
1135         }
1136
1137 +       if (inode->i_op->getattr_it) {
1138 +               retval = inode->i_op->getattr_it(mnt, dentry, it, (struct kstat *) stat);
1139 +               if (retval == 0)
1140 +                       stat->ino64 = stat->ino;
1141 +               return retval;
1142 +       }
1143 +
1144         if (inode->i_op->getattr) {
1145                 retval = inode->i_op->getattr(mnt, dentry, (struct kstat *) stat);
1146                 if (retval == 0)
1147 @@ -98,16 +107,28 @@ int vfs_getattr64(struct vfsmount *mnt, 
1148         return 0;
1149  }
1150
1151 +
1152  EXPORT_SYMBOL(vfs_getattr64);
1153
1154 +int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
1155 +{
1156 +       return vfs_getattr_it(mnt, dentry, NULL, stat);
1157 +}
1158 +
1159 +int vfs_getattr64(struct vfsmount *mnt, struct dentry *dentry, struct kstat64 *stat)
1160 +{
1161 +       return vfs_getattr64_it(mnt, dentry, NULL, stat);
1162 +}
1163 +
1164  int vfs_stat(char __user *name, struct kstat *stat)
1165  {
1166         struct nameidata nd;
1167         int error;
1168 +       intent_init(&nd.intent, IT_GETATTR);
1169  
1170 -       error = user_path_walk(name, &nd);
1171 +       error = user_path_walk_it(name, &nd);
1172         if (!error) {
1173 -               error = vfs_getattr(nd.mnt, nd.dentry, stat);
1174 +               error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
1175                 path_release(&nd);
1176         }
1177         return error;
1178 @@ -119,10 +140,11 @@ int vfs_lstat(char __user *name, struct 
1179  {
1180         struct nameidata nd;
1181         int error;
1182 +       intent_init(&nd.intent, IT_GETATTR);
1183  
1184 -       error = user_path_walk_link(name, &nd);
1185 +       error = user_path_walk_link_it(name, &nd);
1186         if (!error) {
1187 -               error = vfs_getattr(nd.mnt, nd.dentry, stat);
1188 +               error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
1189                 path_release(&nd);
1190         }
1191         return error;
1192 @@ -134,9 +156,12 @@ int vfs_fstat(unsigned int fd, struct ks
1193  {
1194         struct file *f = fget(fd);
1195         int error = -EBADF;
1196 +       struct nameidata nd;
1197 +       intent_init(&nd.intent, IT_GETATTR);
1198  
1199         if (f) {
1200 -               error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
1201 +               error = vfs_getattr_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
1202 +               intent_release(&nd.intent);
1203                 fput(f);
1204         }
1205         return error;
1206 @@ -148,10 +173,11 @@ int vfs_stat64(char __user *name, struct
1207  {
1208         struct nameidata nd;
1209         int error;
1210 +       intent_init(&nd.intent, IT_GETATTR);
1211
1212 -       error = user_path_walk(name, &nd);
1213 +       error = user_path_walk_it(name, &nd);
1214         if (!error) {
1215 -               error = vfs_getattr64(nd.mnt, nd.dentry, stat);
1216 +               error = vfs_getattr64_it(nd.mnt, nd.dentry, &nd.intent, stat);
1217                 path_release(&nd);
1218         }
1219         return error;
1220 @@ -163,10 +189,11 @@ int vfs_lstat64(char __user *name, struc
1221  {
1222         struct nameidata nd;
1223         int error;
1224 +       intent_init(&nd.intent, IT_GETATTR);
1225
1226 -       error = user_path_walk_link(name, &nd);
1227 +       error = user_path_walk_link_it(name, &nd);
1228         if (!error) {
1229 -               error = vfs_getattr64(nd.mnt, nd.dentry, stat);
1230 +               error = vfs_getattr64_it(nd.mnt, nd.dentry, &nd.intent, stat);
1231                 path_release(&nd);
1232         }
1233         return error;
1234 @@ -178,9 +205,11 @@ int vfs_fstat64(unsigned int fd, struct 
1235  {
1236         struct file *f = fget(fd);
1237         int error = -EBADF;
1238 +       struct nameidata nd;
1239 +       intent_init(&nd.intent, IT_GETATTR);
1240
1241         if (f) {
1242 -               error = vfs_getattr64(f->f_vfsmnt, f->f_dentry, stat);
1243 +               error = vfs_getattr64_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
1244                 fput(f);
1245         }
1246         return error;
1247 diff -rup RH_2_6_9_55.orig/include/linux/dcache.h RH_2_6_9_55/include/linux/dcache.h
1248 --- RH_2_6_9_55.orig/include/linux/dcache.h
1249 +++ RH_2_6_9_55/include/linux/dcache.h
1250 @@ -4,6 +4,7 @@
1251  #ifdef __KERNEL__
1252  
1253  #include <asm/atomic.h>
1254 +#include <linux/string.h>
1255  #include <linux/list.h>
1256  #include <linux/spinlock.h>
1257  #include <linux/cache.h>
1258 @@ -37,6 +38,8 @@ struct qstr {
1259         const unsigned char *name;
1260  };
1261  
1262 +#include <linux/namei.h>
1263 +
1264  struct dentry_stat_t {
1265         int nr_dentry;
1266         int nr_unused;
1267 diff -rup RH_2_6_9_55.orig/include/linux/fs.h RH_2_6_9_55/include/linux/fs.h
1268 --- RH_2_6_9_55.orig/include/linux/fs.h
1269 +++ RH_2_6_9_55/include/linux/fs.h
1270 @@ -266,6 +266,8 @@ typedef void (dio_iodone_t)(struct inode
1271  #define ATTR_ATTR_FLAG 1024
1272  #define ATTR_KILL_SUID 2048
1273  #define ATTR_KILL_SGID 4096
1274 +#define ATTR_RAW               8192    /* file system, not vfs will massage attrs */
1275 +#define ATTR_FROM_OPEN         16384    /* called from open path, ie O_TRUNC */
1276  
1277  /*
1278   * This is the Inode Attributes structure, used for notify_change().  It
1279 @@ -464,6 +466,7 @@ struct inode {
1280         struct block_device     *i_bdev;
1281         struct cdev             *i_cdev;
1282         int                     i_cindex;
1283 +       void                    *i_filterdata;
1284  
1285         __u32                   i_generation;
1286  
1287 @@ -597,6 +600,7 @@ struct file {
1288         spinlock_t              f_ep_lock;
1289  #endif /* #ifdef CONFIG_EPOLL */
1290         struct address_space    *f_mapping;
1291 +       struct lookup_intent    *f_it;
1292  };
1293  extern spinlock_t files_lock;
1294  #define file_list_lock() spin_lock(&files_lock);
1295 @@ -967,20 +971,29 @@ struct inode_operations {
1296         int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
1297         struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
1298         int (*link) (struct dentry *,struct inode *,struct dentry *);
1299 +       int (*link_raw) (struct nameidata *,struct nameidata *);
1300         int (*unlink) (struct inode *,struct dentry *);
1301 +       int (*unlink_raw) (struct nameidata *);
1302         int (*symlink) (struct inode *,struct dentry *,const char *);
1303 +       int (*symlink_raw) (struct nameidata *,const char *);
1304         int (*mkdir) (struct inode *,struct dentry *,int);
1305 +       int (*mkdir_raw) (struct nameidata *,int);
1306         int (*rmdir) (struct inode *,struct dentry *);
1307 +       int (*rmdir_raw) (struct nameidata *);
1308         int (*mknod) (struct inode *,struct dentry *,int,dev_t);
1309 +       int (*mknod_raw) (struct nameidata *,int,dev_t);
1310         int (*rename) (struct inode *, struct dentry *,
1311                         struct inode *, struct dentry *);
1312 +       int (*rename_raw) (struct nameidata *, struct nameidata *);
1313         int (*readlink) (struct dentry *, char __user *,int);
1314         int (*follow_link) (struct dentry *, struct nameidata *);
1315         void (*put_link) (struct dentry *, struct nameidata *);
1316         void (*truncate) (struct inode *);
1317         int (*permission) (struct inode *, int, struct nameidata *);
1318         int (*setattr) (struct dentry *, struct iattr *);
1319 +       int (*setattr_raw) (struct inode *, struct iattr *);
1320         int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
1321 +       int (*getattr_it) (struct vfsmount *, struct dentry *, struct lookup_intent *, struct kstat *);
1322         int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
1323         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1324         ssize_t (*listxattr) (struct dentry *, char *, size_t);
1325 @@ -1025,6 +1038,7 @@ struct super_operations {
1326         int (*remount_fs) (struct super_block *, int *, char *);
1327         void (*clear_inode) (struct inode *);
1328         void (*umount_begin) (struct super_block *);
1329 +       void (*umount_lustre) (struct super_block *);
1330  
1331         int (*show_options)(struct seq_file *, struct vfsmount *);
1332  };
1333 @@ -1217,6 +1231,7 @@ extern int unregister_filesystem(struct 
1334  extern struct vfsmount *kern_mount(struct file_system_type *);
1335  extern int may_umount_tree(struct vfsmount *);
1336  extern int may_umount(struct vfsmount *);
1337 +struct vfsmount *do_kern_mount(const char *type, int flags, const char *name, void *data);
1338  extern long do_mount(char *, char *, char *, unsigned long, void *);
1339  
1340  extern int vfs_statfs(struct super_block *, struct kstatfs *);
1341 @@ -1277,10 +1292,10 @@ static inline int break_lease(struct ino
1342  }
1343  
1344  /* fs/open.c */
1345 -
1346  extern int do_truncate(struct dentry *, loff_t start, unsigned int);
1347  extern struct file *filp_open(const char *, int, int);
1348  extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1349 +extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
1350  extern int filp_close(struct file *, fl_owner_t id);
1351  extern char * getname(const char __user *);
1352  
1353 diff -rup RH_2_6_9_55.orig/include/linux/mount.h RH_2_6_9_55/include/linux/mount.h
1354 --- RH_2_6_9_55.orig/include/linux/mount.h
1355 +++ RH_2_6_9_55/include/linux/mount.h
1356 @@ -34,6 +34,7 @@ struct vfsmount
1357         struct list_head mnt_list;
1358         struct list_head mnt_fslink;    /* link in fs-specific expiry list */
1359         struct namespace *mnt_namespace; /* containing namespace */
1360 +       unsigned long mnt_last_used;    /* for GNS auto-umount (jiffies) */
1361  };
1362  
1363  static inline struct vfsmount *mntget(struct vfsmount *mnt)
1364 diff -rup RH_2_6_9_55.orig/include/linux/namei.h RH_2_6_9_55/include/linux/namei.h
1365 --- RH_2_6_9_55.orig/include/linux/namei.h
1366 +++ RH_2_6_9_55/include/linux/namei.h
1367 @@ -2,14 +2,55 @@
1368  #define _LINUX_NAMEI_H
1369  
1370  #include <linux/linkage.h>
1371 +#include <linux/string.h>
1372  
1373  struct vfsmount;
1374 +struct nameidata;
1375  
1376 -struct open_intent {
1377 -       int     flags;
1378 -       int     create_mode;
1379 +/* intent opcodes */
1380 +#define IT_OPEN                (1)
1381 +#define IT_CREAT       (1<<1)
1382 +#define IT_READDIR     (1<<2)
1383 +#define IT_GETATTR     (1<<3)
1384 +#define IT_LOOKUP      (1<<4)
1385 +#define IT_UNLINK      (1<<5)
1386 +#define IT_TRUNC       (1<<6)
1387 +#define IT_GETXATTR    (1<<7)
1388 +
1389 +struct lustre_intent_data {
1390 +       int     it_disposition;
1391 +       int     it_status;
1392 +       __u64   it_lock_handle;
1393 +       void    *it_data;
1394 +       int     it_lock_mode;
1395  };
1396  
1397 +#define INTENT_MAGIC 0x19620323
1398 +struct lookup_intent {
1399 +       int     it_magic;
1400 +       void    (*it_op_release)(struct lookup_intent *);
1401 +       int     it_op;
1402 +       int     it_flags;
1403 +       int     it_create_mode;
1404 +       union {
1405 +               struct lustre_intent_data lustre;
1406 +       } d;
1407 +};
1408 +
1409 +static inline void intent_reset_fs_part(struct lookup_intent *it)
1410 +{
1411 +        memset(&it->d, 0, sizeof(it->d));
1412 +        it->it_magic = INTENT_MAGIC;
1413 +        it->it_op_release = NULL;
1414 +}
1415 +
1416 +static inline void intent_init(struct lookup_intent *it, int op)
1417 +{
1418 +       memset(it, 0, sizeof(*it));
1419 +       it->it_magic = INTENT_MAGIC;
1420 +       it->it_op = op;
1421 +}
1422 +
1423  enum { MAX_NESTED_LINKS = 8 };
1424  
1425  struct nameidata {
1426 @@ -21,10 +62,7 @@ struct nameidata {
1427         unsigned        depth;
1428         char *saved_names[MAX_NESTED_LINKS + 1];
1429  
1430 -       /* Intent data */
1431 -       union {
1432 -               struct open_intent open;
1433 -       } intent;
1434 +       struct lookup_intent intent;
1435  };
1436  
1437  /*
1438 @@ -47,6 +85,8 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA
1439  #define LOOKUP_NOALT           32
1440  #define LOOKUP_ATOMIC          64
1441  #define LOOKUP_REVAL           128
1442 +#define LOOKUP_LAST            (0x1000)
1443 +#define LOOKUP_LINK_NOTLAST    (0x2000)
1444  
1445  /*
1446   * Intent data
1447 @@ -56,11 +96,18 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA
1448  #define LOOKUP_ACCESS          (0x0400)
1449  
1450  extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
1451 +extern int FASTCALL(__user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd));
1452 +#define user_path_walk_it(name,nd) \
1453 +       __user_walk_it(name, LOOKUP_FOLLOW, nd)
1454 +#define user_path_walk_link_it(name,nd) \
1455 +       __user_walk_it(name, 0, nd)
1456 +extern void intent_release(struct lookup_intent *);
1457  #define user_path_walk(name,nd) \
1458         __user_walk(name, LOOKUP_FOLLOW, nd)
1459  #define user_path_walk_link(name,nd) \
1460         __user_walk(name, 0, nd)
1461  extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1462 +extern int FASTCALL(path_lookup_it(const char *, unsigned, struct nameidata *));
1463  extern int FASTCALL(path_walk(const char *, struct nameidata *));
1464  extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
1465  extern void path_release(struct nameidata *);