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