Whamcloud - gitweb
1e659f5534541bb96de318857bcac361b2840b21
[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 @@ -61,6 +61,7 @@ struct vfsmount *alloc_vfsmnt(const char
585                 INIT_LIST_HEAD(&mnt->mnt_mounts);
586                 INIT_LIST_HEAD(&mnt->mnt_list);
587                 INIT_LIST_HEAD(&mnt->mnt_fslink);
588 +               INIT_LIST_HEAD(&mnt->mnt_lustre_list);
589                 if (name) {
590                         int size = strlen(name)+1;
591                         char *newname = kmalloc(size, GFP_KERNEL);
592 @@ -114,6 +115,7 @@ static inline int check_mnt(struct vfsmo
593  
594  static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd)
595  {
596 +       memset(old_nd, 0, sizeof(*old_nd));
597         old_nd->dentry = mnt->mnt_mountpoint;
598         old_nd->mnt = mnt->mnt_parent;
599         mnt->mnt_parent = mnt;
600 @@ -441,6 +442,8 @@ static int do_umount(struct vfsmount *mn
601          */
602  
603         lock_kernel();
604 +       if (sb->s_op->umount_lustre)
605 +               sb->s_op->umount_lustre(sb);
606         if( (flags&MNT_FORCE) && sb->s_op->umount_begin)
607                 sb->s_op->umount_begin(sb);
608         unlock_kernel();
609 @@ -665,7 +668,8 @@ static int do_loopback(struct nameidata 
610                 return err;
611         if (!old_name || !*old_name)
612                 return -EINVAL;
613 -       err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
614 +       intent_init(&old_nd.intent, IT_LOOKUP);
615 +       err = path_lookup_it(old_name, LOOKUP_FOLLOW, &old_nd);
616         if (err)
617                 return err;
618  
619 @@ -739,7 +743,8 @@ static int do_move_mount(struct nameidat
620                 return -EPERM;
621         if (!old_name || !*old_name)
622                 return -EINVAL;
623 -       err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
624 +       intent_init(&old_nd.intent, IT_LOOKUP);
625 +       err = path_lookup_it(old_name, LOOKUP_FOLLOW, &old_nd);
626         if (err)
627                 return err;
628  
629 @@ -1074,7 +1079,8 @@ long do_mount(char * dev_name, char * di
630         flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_ACTIVE);
631  
632         /* ... and get the mountpoint */
633 -       retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
634 +       intent_init(&nd.intent, IT_LOOKUP);     
635 +       retval = path_lookup_it(dir_name, LOOKUP_FOLLOW, &nd);
636         if (retval)
637                 return retval;
638  
639 diff -rup RH_2_6_9_55.orig/fs/nfs/dir.c RH_2_6_9_55/fs/nfs/dir.c
640 --- RH_2_6_9_55.orig/fs/nfs/dir.c
641 +++ RH_2_6_9_55/fs/nfs/dir.c
642 @@ -839,7 +839,7 @@ int nfs_is_exclusive_create(struct inode
643                 return 0;
644         if (!nd || (nd->flags & LOOKUP_CONTINUE) || !(nd->flags & LOOKUP_CREATE))
645                 return 0;
646 -       return (nd->intent.open.flags & O_EXCL) != 0;
647 +       return (nd->intent.it_flags & O_EXCL) != 0;
648  }
649  
650  static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd)
651 @@ -915,7 +915,7 @@ static int is_atomic_open(struct inode *
652         if (nd->flags & LOOKUP_DIRECTORY)
653                 return 0;
654         /* Are we trying to write to a read only partition? */
655 -       if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
656 +       if (IS_RDONLY(dir) && (nd->intent.it_flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
657                 return 0;
658         return 1;
659  }
660 @@ -936,7 +936,7 @@ static struct dentry *nfs_atomic_lookup(
661         dentry->d_op = NFS_PROTO(dir)->dentry_ops;
662  
663         /* Let vfs_create() deal with O_EXCL */
664 -       if (nd->intent.open.flags & O_EXCL)
665 +       if (nd->intent.it_flags & O_EXCL)
666                 goto no_entry;
667  
668         /* Open the file on the server */
669 @@ -948,7 +948,7 @@ static struct dentry *nfs_atomic_lookup(
670                 goto out;
671         }
672  
673 -       if (nd->intent.open.flags & O_CREAT) {
674 +       if (nd->intent.it_flags & O_CREAT) {
675                 nfs_begin_data_update(dir);
676                 inode = nfs4_atomic_open(dir, dentry, nd);
677                 nfs_end_data_update(dir);
678 @@ -967,7 +967,7 @@ static struct dentry *nfs_atomic_lookup(
679                         case -ENOTDIR:
680                                 goto no_open;
681                         case -ELOOP:
682 -                               if (!(nd->intent.open.flags & O_NOFOLLOW))
683 +                               if (!(nd->intent.it_flags & O_NOFOLLOW))
684                                         goto no_open;
685                         /* case -EINVAL: */
686                         default:
687 @@ -1005,7 +1005,7 @@ static int nfs_open_revalidate(struct de
688         /* NFS only supports OPEN on regular files */
689         if (!S_ISREG(inode->i_mode))
690                 goto no_open;
691 -       openflags = nd->intent.open.flags;
692 +       openflags = nd->intent.it_flags;
693         /* We cannot do exclusive creation on a positive dentry */
694         if ((openflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
695                 goto no_open;
696 @@ -1213,7 +1213,7 @@ static int nfs_create(struct inode *dir,
697         attr.ia_valid = ATTR_MODE;
698  
699         if (nd && (nd->flags & LOOKUP_CREATE))
700 -               open_flags = nd->intent.open.flags;
701 +               open_flags = nd->intent.it_flags;
702  
703         /*
704          * The 0 argument passed into the create function should one day
705 diff -rup RH_2_6_9_55.orig/fs/nfs/nfs4proc.c RH_2_6_9_55/fs/nfs/nfs4proc.c
706 --- RH_2_6_9_55.orig/fs/nfs/nfs4proc.c
707 +++ RH_2_6_9_55/fs/nfs/nfs4proc.c
708 @@ -770,17 +770,17 @@ nfs4_atomic_open(struct inode *dir, stru
709         struct nfs4_state *state;
710  
711         if (nd->flags & LOOKUP_CREATE) {
712 -               attr.ia_mode = nd->intent.open.create_mode;
713 +               attr.ia_mode = nd->intent.it_create_mode;
714                 attr.ia_valid = ATTR_MODE;
715                 if (!IS_POSIXACL(dir))
716                         attr.ia_mode &= ~current->fs->umask;
717         } else {
718                 attr.ia_valid = 0;
719 -               BUG_ON(nd->intent.open.flags & O_CREAT);
720 +               BUG_ON(nd->intent.it_flags & O_CREAT);
721         }
722  
723         cred = rpcauth_lookupcred(NFS_SERVER(dir)->client->cl_auth, 0);
724 -       state = nfs4_do_open(dir, &dentry->d_name, nd->intent.open.flags, &attr, cred);
725 +       state = nfs4_do_open(dir, &dentry->d_name, nd->intent.it_flags, &attr, cred);
726         put_rpccred(cred);
727         if (IS_ERR(state))
728                 return (struct inode *)state;
729 diff -rup RH_2_6_9_55.orig/fs/open.c RH_2_6_9_55/fs/open.c
730 --- RH_2_6_9_55.orig/fs/open.c
731 +++ RH_2_6_9_55/fs/open.c
732 @@ -195,6 +195,7 @@ out:
733  int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs)
734  {
735         int err;
736 +       struct inode_operations *op = dentry->d_inode->i_op;
737         struct iattr newattrs;
738  
739         /* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
740 @@ -204,8 +205,16 @@ int do_truncate(struct dentry *dentry, l
741         newattrs.ia_size = length;
742         newattrs.ia_valid = ATTR_SIZE | time_attrs;
743         down(&dentry->d_inode->i_sem);
744 -       err = notify_change(dentry, &newattrs);
745 -       up(&dentry->d_inode->i_sem);
746 +       if (op->setattr_raw) {
747 +               newattrs.ia_valid |= ATTR_RAW;
748 +               newattrs.ia_ctime = CURRENT_TIME;
749 +               down_write(&dentry->d_inode->i_alloc_sem);
750 +               err = op->setattr_raw(dentry->d_inode, &newattrs);
751 +               up_write(&dentry->d_inode->i_alloc_sem);
752 +       } else
753 +               err = notify_change(dentry, &newattrs);
754 +       up(&dentry->d_inode->i_sem);            
755 +
756         return err;
757  }
758
759 @@ -214,12 +223,13 @@ static inline long do_sys_truncate(const
760         struct nameidata nd;
761         struct inode * inode;
762         int error;
763 -
764 +       
765         error = -EINVAL;
766         if (length < 0) /* sorry, but loff_t says... */
767                 goto out;
768 -
769 -       error = user_path_walk(path, &nd);
770 +               
771 +       intent_init(&nd.intent, IT_GETATTR);
772 +       error = user_path_walk_it(path, &nd);
773         if (error)
774                 goto out;
775         inode = nd.dentry->d_inode;
776 @@ -390,9 +400,19 @@ asmlinkage long sys_utime(char __user * 
777                     (error = permission(inode,MAY_WRITE,&nd)) != 0)
778                         goto dput_and_out;
779         }
780 -       down(&inode->i_sem);
781 -       error = notify_change(nd.dentry, &newattrs);
782 -       up(&inode->i_sem);
783 +       if (inode->i_op->setattr_raw) {
784 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
785 +
786 +               newattrs.ia_valid |= ATTR_RAW;
787 +               error = op->setattr_raw(inode, &newattrs);
788 +               /* the file system wants to use normal vfs path now */
789 +               if (error != -EOPNOTSUPP)
790 +                       goto dput_and_out;
791 +       } else {
792 +               down(&inode->i_sem);
793 +               error = notify_change(nd.dentry, &newattrs);
794 +               up(&inode->i_sem);
795 +       }
796  dput_and_out:
797         path_release(&nd);
798  out:
799 @@ -443,9 +463,19 @@ long do_utimes(char __user * filename, s
800                     (error = permission(inode,MAY_WRITE,&nd)) != 0)
801                         goto dput_and_out;
802         }
803 -       down(&inode->i_sem);
804 -       error = notify_change(nd.dentry, &newattrs);
805 -       up(&inode->i_sem);
806 +       if (inode->i_op->setattr_raw) {
807 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
808 +
809 +               newattrs.ia_valid |= ATTR_RAW;
810 +               error = op->setattr_raw(inode, &newattrs);
811 +               /* the file system wants to use normal vfs path now */
812 +               if (error != -EOPNOTSUPP)
813 +                       goto dput_and_out;
814 +       } else {
815 +               down(&inode->i_sem);
816 +               error = notify_change(nd.dentry, &newattrs);
817 +               up(&inode->i_sem);
818 +       }
819  dput_and_out:
820         path_release(&nd);
821  out:
822 @@ -473,6 +503,7 @@ asmlinkage long sys_access(const char __
823         int old_fsuid, old_fsgid;
824         kernel_cap_t old_cap;
825         int res;
826 +       intent_init(&nd.intent, IT_GETATTR);
827  
828         if (mode & ~S_IRWXO)    /* where's F_OK, X_OK, W_OK, R_OK? */
829                 return -EINVAL;
830 @@ -497,13 +528,14 @@ asmlinkage long sys_access(const char __
831         else
832                 current->cap_effective = current->cap_permitted;
833  
834 -       res = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
835 +       res = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
836         if (!res) {
837                 res = permission(nd.dentry->d_inode, mode, &nd);
838                 /* SuS v2 requires we report a read only fs too */
839                 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
840                    && !special_file(nd.dentry->d_inode->i_mode))
841                         res = -EROFS;
842 +
843                 path_release(&nd);
844         }
845  
846 @@ -518,8 +550,9 @@ asmlinkage long sys_chdir(const char __u
847  {
848         struct nameidata nd;
849         int error;
850 +       intent_init(&nd.intent, IT_GETATTR);
851  
852 -       error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
853 +       error = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
854         if (error)
855                 goto out;
856  
857 @@ -571,8 +604,9 @@ asmlinkage long sys_chroot(const char __
858  {
859         struct nameidata nd;
860         int error;
861 +       intent_init(&nd.intent, IT_GETATTR);
862  
863 -       error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
864 +       error = __user_walk_it(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
865         if (error)
866                 goto out;
867  
868 @@ -595,36 +629,52 @@ out:
869  
870  EXPORT_SYMBOL_GPL(sys_chroot);
871  
872 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
873 +int chmod_common(struct dentry *dentry, mode_t mode)
874  {
875 -       struct inode * inode;
876 -       struct dentry * dentry;
877 -       struct file * file;
878 -       int err = -EBADF;
879 +       struct inode * inode = dentry->d_inode;
880         struct iattr newattrs;
881 +       int error = -EROFS;
882  
883 -       file = fget(fd);
884 -       if (!file)
885 +       if (IS_RDONLY(inode))
886                 goto out;
887 +       
888 +       if (inode->i_op->setattr_raw) {
889 +               struct inode_operations *op = dentry->d_inode->i_op;
890  
891 -       dentry = file->f_dentry;
892 -       inode = dentry->d_inode;
893 +               newattrs.ia_mode = mode;
894 +               newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
895 +               newattrs.ia_valid |= ATTR_RAW;
896 +               error = op->setattr_raw(inode, &newattrs);
897 +               /* the file system wants to use the normal vfs path now */
898 +               if (error != -EOPNOTSUPP)
899 +                       goto out;
900 +       }
901  
902 -       err = -EROFS;
903 -       if (IS_RDONLY(inode))
904 -               goto out_putf;
905 -       err = -EPERM;
906 +       error = -EPERM;
907         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
908 -               goto out_putf;
909 +               goto out;
910 +
911         down(&inode->i_sem);
912         if (mode == (mode_t) -1)
913                 mode = inode->i_mode;
914         newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
915         newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
916 -       err = notify_change(dentry, &newattrs);
917 +       error = notify_change(dentry, &newattrs);
918         up(&inode->i_sem);
919 +out:
920 +       return error;
921 +}
922  
923 -out_putf:
924 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
925 +{
926 +       struct file * file;
927 +       int err = -EBADF;
928 +
929 +       file = fget(fd);
930 +       if (!file)
931 +               goto out;
932 +
933 +       err = chmod_common(file->f_dentry, mode);
934         fput(file);
935  out:
936         return err;
937 @@ -633,32 +683,13 @@ out:
938  asmlinkage long sys_chmod(const char __user * filename, mode_t mode)
939  {
940         struct nameidata nd;
941 -       struct inode * inode;
942         int error;
943 -       struct iattr newattrs;
944  
945         error = user_path_walk(filename, &nd);
946         if (error)
947                 goto out;
948 -       inode = nd.dentry->d_inode;
949
950 -       error = -EROFS;
951 -       if (IS_RDONLY(inode))
952 -               goto dput_and_out;
953 -
954 -       error = -EPERM;
955 -       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
956 -               goto dput_and_out;
957 -
958 -       down(&inode->i_sem);
959 -       if (mode == (mode_t) -1)
960 -               mode = inode->i_mode;
961 -       newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
962 -       newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
963 -       error = notify_change(nd.dentry, &newattrs);
964 -       up(&inode->i_sem);
965 -
966 -dput_and_out:
967 +       error = chmod_common(nd.dentry, mode);
968         path_release(&nd);
969  out:
970         return error;
971 @@ -679,6 +710,18 @@ static int chown_common(struct dentry * 
972         if (IS_RDONLY(inode))
973                 goto out;
974         error = -EPERM;
975 +       if (inode->i_op->setattr_raw) {
976 +               struct inode_operations *op = dentry->d_inode->i_op;
977 +
978 +               newattrs.ia_uid = user;
979 +               newattrs.ia_gid = group;
980 +               newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
981 +               newattrs.ia_valid |= ATTR_RAW;
982 +               error = op->setattr_raw(inode, &newattrs);
983 +               /* the file system wants to use normal vfs path now */
984 +               if (error != -EOPNOTSUPP)
985 +                       return error;
986 +       }
987         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
988                 goto out;
989         newattrs.ia_valid =  ATTR_CTIME;
990 @@ -692,6 +735,7 @@ static int chown_common(struct dentry * 
991         }
992         if (!S_ISDIR(inode->i_mode))
993                 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
994 +
995         down(&inode->i_sem);
996         error = notify_change(dentry, &newattrs);
997         up(&inode->i_sem);
998 @@ -739,8 +783,6 @@ asmlinkage long sys_fchown(unsigned int 
999         return error;
1000  }
1001  
1002 -static struct file *__dentry_open(struct dentry *, struct vfsmount *, int, struct file *);
1003 -
1004  /*
1005   * Note that while the flag value (low two bits) for sys_open means:
1006   *     00 - read-only
1007 @@ -758,8 +800,9 @@ static struct file *__dentry_open(struct
1008  struct file *filp_open(const char * filename, int flags, int mode)
1009  {
1010         int namei_flags, error;
1011 +       struct file * temp_filp;
1012         struct nameidata nd;
1013 -       struct file *f;
1014 +       intent_init(&nd.intent, IT_OPEN);
1015  
1016         namei_flags = flags;
1017         if ((namei_flags+1) & O_ACCMODE)
1018 @@ -767,16 +810,11 @@ struct file *filp_open(const char * file
1019         if (namei_flags & O_TRUNC)
1020                 namei_flags |= 2;
1021  
1022 -       error = -ENFILE;
1023 -       f = get_empty_filp();
1024 -       if (f == NULL)
1025 -               return ERR_PTR(error);
1026 -
1027         error = open_namei(filename, namei_flags, mode, &nd);
1028 -       if (!error)
1029 -               return __dentry_open(nd.dentry, nd.mnt, flags, f);
1030 -
1031 -       put_filp(f);
1032 +       if (!error) {
1033 +               temp_filp = dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent);
1034 +               return temp_filp;
1035 +       }       
1036         return ERR_PTR(error);
1037  }
1038  
1039 @@ -784,29 +822,27 @@ EXPORT_SYMBOL(filp_open);
1040  
1041  struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1042  {
1043 -       int error;
1044 -       struct file *f;
1045 +       struct lookup_intent it;
1046 +       intent_init(&it, IT_LOOKUP);
1047  
1048 -       error = -ENFILE;
1049 -       f = get_empty_filp();
1050 -       if (f == NULL) {
1051 -               dput(dentry);
1052 -               mntput(mnt);
1053 -               return ERR_PTR(error);
1054 -       }
1055 -
1056 -       return __dentry_open(dentry, mnt, flags, f);
1057 +       return dentry_open_it(dentry, mnt, flags, &it);
1058  }
1059  
1060  EXPORT_SYMBOL(dentry_open);
1061  
1062 -static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags, struct file *f)
1063 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, struct lookup_intent *it)
1064  {
1065 +       struct file *f;
1066         struct inode *inode;
1067         int error;
1068  
1069 +       error = -ENFILE;
1070 +       f = get_empty_filp();
1071 +       if (!f)
1072 +               goto cleanup_dentry;
1073         f->f_flags = flags;
1074         f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;
1075 +       f->f_it = it;
1076         inode = dentry->d_inode;
1077         if (f->f_mode & FMODE_WRITE) {
1078                 error = get_write_access(inode);
1079 @@ -825,6 +861,7 @@ static struct file *__dentry_open(struct
1080                 error = f->f_op->open(inode,f);
1081                 if (error)
1082                         goto cleanup_all;
1083 +               intent_release(it);
1084         }
1085         f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1086  
1087 @@ -849,6 +886,8 @@ cleanup_all:
1088         f->f_vfsmnt = NULL;
1089  cleanup_file:
1090         put_filp(f);
1091 +cleanup_dentry:
1092 +       intent_release(it);
1093         dput(dentry);
1094         mntput(mnt);
1095         return ERR_PTR(error);
1096 diff -rup RH_2_6_9_55.orig/fs/stat.c RH_2_6_9_55/fs/stat.c
1097 --- RH_2_6_9_55.orig/fs/stat.c
1098 +++ RH_2_6_9_55/fs/stat.c
1099 @@ -37,7 +37,7 @@ void generic_fillattr(struct inode *inod
1100  
1101  EXPORT_SYMBOL(generic_fillattr);
1102  
1103 -int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
1104 +int vfs_getattr_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat *stat)
1105  {
1106         struct inode *inode = dentry->d_inode;
1107         int retval;
1108 @@ -46,6 +46,8 @@ int vfs_getattr(struct vfsmount *mnt, st
1109         if (retval)
1110                 return retval;
1111  
1112 +       if (inode->i_op->getattr_it)
1113 +               return inode->i_op->getattr_it(mnt, dentry, it, stat);
1114         if (inode->i_op->getattr)
1115                 return inode->i_op->getattr(mnt, dentry, stat);
1116  
1117 @@ -62,7 +64,7 @@ int vfs_getattr(struct vfsmount *mnt, st
1118  
1119  EXPORT_SYMBOL(vfs_getattr);
1120  
1121 -int vfs_getattr64(struct vfsmount *mnt, struct dentry *dentry, struct kstat64 *stat)
1122 +int vfs_getattr64_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat64 *stat)
1123  {
1124         struct inode *inode = dentry->d_inode;
1125         int retval;
1126 @@ -79,6 +81,13 @@ int vfs_getattr64(struct vfsmount *mnt, 
1127                 return ixop->getattr64(mnt, dentry, stat);
1128         }
1129
1130 +       if (inode->i_op->getattr_it) {
1131 +               retval = inode->i_op->getattr_it(mnt, dentry, it, (struct kstat *) stat);
1132 +               if (retval == 0)
1133 +                       stat->ino64 = stat->ino;
1134 +               return retval;
1135 +       }
1136 +
1137         if (inode->i_op->getattr) {
1138                 retval = inode->i_op->getattr(mnt, dentry, (struct kstat *) stat);
1139                 if (retval == 0)
1140 @@ -98,16 +107,28 @@ int vfs_getattr64(struct vfsmount *mnt, 
1141         return 0;
1142  }
1143
1144 +
1145  EXPORT_SYMBOL(vfs_getattr64);
1146
1147 +int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
1148 +{
1149 +       return vfs_getattr_it(mnt, dentry, NULL, stat);
1150 +}
1151 +
1152 +int vfs_getattr64(struct vfsmount *mnt, struct dentry *dentry, struct kstat64 *stat)
1153 +{
1154 +       return vfs_getattr64_it(mnt, dentry, NULL, stat);
1155 +}
1156 +
1157  int vfs_stat(char __user *name, struct kstat *stat)
1158  {
1159         struct nameidata nd;
1160         int error;
1161 +       intent_init(&nd.intent, IT_GETATTR);
1162  
1163 -       error = user_path_walk(name, &nd);
1164 +       error = user_path_walk_it(name, &nd);
1165         if (!error) {
1166 -               error = vfs_getattr(nd.mnt, nd.dentry, stat);
1167 +               error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
1168                 path_release(&nd);
1169         }
1170         return error;
1171 @@ -119,10 +140,11 @@ int vfs_lstat(char __user *name, struct 
1172  {
1173         struct nameidata nd;
1174         int error;
1175 +       intent_init(&nd.intent, IT_GETATTR);
1176  
1177 -       error = user_path_walk_link(name, &nd);
1178 +       error = user_path_walk_link_it(name, &nd);
1179         if (!error) {
1180 -               error = vfs_getattr(nd.mnt, nd.dentry, stat);
1181 +               error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
1182                 path_release(&nd);
1183         }
1184         return error;
1185 @@ -134,9 +156,12 @@ int vfs_fstat(unsigned int fd, struct ks
1186  {
1187         struct file *f = fget(fd);
1188         int error = -EBADF;
1189 +       struct nameidata nd;
1190 +       intent_init(&nd.intent, IT_GETATTR);
1191  
1192         if (f) {
1193 -               error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
1194 +               error = vfs_getattr_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
1195 +               intent_release(&nd.intent);
1196                 fput(f);
1197         }
1198         return error;
1199 @@ -148,10 +173,11 @@ int vfs_stat64(char __user *name, struct
1200  {
1201         struct nameidata nd;
1202         int error;
1203 +       intent_init(&nd.intent, IT_GETATTR);
1204
1205         error = user_path_walk(name, &nd);
1206         if (!error) {
1207 -               error = vfs_getattr64(nd.mnt, nd.dentry, stat);
1208 +               error = vfs_getattr64_it(nd.mnt, nd.dentry, &nd.intent, stat);
1209                 path_release(&nd);
1210         }
1211         return error;
1212 @@ -163,10 +189,11 @@ int vfs_lstat64(char __user *name, struc
1213  {
1214         struct nameidata nd;
1215         int error;
1216 +       intent_init(&nd.intent, IT_GETATTR);
1217
1218         error = user_path_walk_link(name, &nd);
1219         if (!error) {
1220 -               error = vfs_getattr64(nd.mnt, nd.dentry, stat);
1221 +               error = vfs_getattr64_it(nd.mnt, nd.dentry, &nd.intent, stat);
1222                 path_release(&nd);
1223         }
1224         return error;
1225 @@ -178,9 +205,11 @@ int vfs_fstat64(unsigned int fd, struct 
1226  {
1227         struct file *f = fget(fd);
1228         int error = -EBADF;
1229 +       struct nameidata nd;
1230 +       intent_init(&nd.intent, IT_GETATTR);
1231
1232         if (f) {
1233 -               error = vfs_getattr64(f->f_vfsmnt, f->f_dentry, stat);
1234 +               error = vfs_getattr64_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
1235                 fput(f);
1236         }
1237         return error;
1238 diff -rup RH_2_6_9_55.orig/include/linux/dcache.h RH_2_6_9_55/include/linux/dcache.h
1239 --- RH_2_6_9_55.orig/include/linux/dcache.h
1240 +++ RH_2_6_9_55/include/linux/dcache.h
1241 @@ -4,6 +4,7 @@
1242  #ifdef __KERNEL__
1243  
1244  #include <asm/atomic.h>
1245 +#include <linux/string.h>
1246  #include <linux/list.h>
1247  #include <linux/spinlock.h>
1248  #include <linux/cache.h>
1249 @@ -37,6 +38,8 @@ struct qstr {
1250         const unsigned char *name;
1251  };
1252  
1253 +#include <linux/namei.h>
1254 +
1255  struct dentry_stat_t {
1256         int nr_dentry;
1257         int nr_unused;
1258 diff -rup RH_2_6_9_55.orig/include/linux/fs.h RH_2_6_9_55/include/linux/fs.h
1259 --- RH_2_6_9_55.orig/include/linux/fs.h
1260 +++ RH_2_6_9_55/include/linux/fs.h
1261 @@ -266,6 +266,8 @@ typedef void (dio_iodone_t)(struct inode
1262  #define ATTR_ATTR_FLAG 1024
1263  #define ATTR_KILL_SUID 2048
1264  #define ATTR_KILL_SGID 4096
1265 +#define ATTR_RAW               8192    /* file system, not vfs will massage attrs */
1266 +#define ATTR_FROM_OPEN         16384    /* called from open path, ie O_TRUNC */
1267  
1268  /*
1269   * This is the Inode Attributes structure, used for notify_change().  It
1270 @@ -464,6 +466,7 @@ struct inode {
1271         struct block_device     *i_bdev;
1272         struct cdev             *i_cdev;
1273         int                     i_cindex;
1274 +       void                    *i_filterdata;
1275  
1276         __u32                   i_generation;
1277  
1278 @@ -597,6 +600,7 @@ struct file {
1279         spinlock_t              f_ep_lock;
1280  #endif /* #ifdef CONFIG_EPOLL */
1281         struct address_space    *f_mapping;
1282 +       struct lookup_intent    *f_it;
1283  };
1284  extern spinlock_t files_lock;
1285  #define file_list_lock() spin_lock(&files_lock);
1286 @@ -967,20 +971,29 @@ struct inode_operations {
1287         int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
1288         struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
1289         int (*link) (struct dentry *,struct inode *,struct dentry *);
1290 +       int (*link_raw) (struct nameidata *,struct nameidata *);
1291         int (*unlink) (struct inode *,struct dentry *);
1292 +       int (*unlink_raw) (struct nameidata *);
1293         int (*symlink) (struct inode *,struct dentry *,const char *);
1294 +       int (*symlink_raw) (struct nameidata *,const char *);
1295         int (*mkdir) (struct inode *,struct dentry *,int);
1296 +       int (*mkdir_raw) (struct nameidata *,int);
1297         int (*rmdir) (struct inode *,struct dentry *);
1298 +       int (*rmdir_raw) (struct nameidata *);
1299         int (*mknod) (struct inode *,struct dentry *,int,dev_t);
1300 +       int (*mknod_raw) (struct nameidata *,int,dev_t);
1301         int (*rename) (struct inode *, struct dentry *,
1302                         struct inode *, struct dentry *);
1303 +       int (*rename_raw) (struct nameidata *, struct nameidata *);
1304         int (*readlink) (struct dentry *, char __user *,int);
1305         int (*follow_link) (struct dentry *, struct nameidata *);
1306         void (*put_link) (struct dentry *, struct nameidata *);
1307         void (*truncate) (struct inode *);
1308         int (*permission) (struct inode *, int, struct nameidata *);
1309         int (*setattr) (struct dentry *, struct iattr *);
1310 +       int (*setattr_raw) (struct inode *, struct iattr *);
1311         int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
1312 +       int (*getattr_it) (struct vfsmount *, struct dentry *, struct lookup_intent *, struct kstat *);
1313         int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
1314         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1315         ssize_t (*listxattr) (struct dentry *, char *, size_t);
1316 @@ -1025,6 +1038,7 @@ struct super_operations {
1317         int (*remount_fs) (struct super_block *, int *, char *);
1318         void (*clear_inode) (struct inode *);
1319         void (*umount_begin) (struct super_block *);
1320 +       void (*umount_lustre) (struct super_block *);
1321  
1322         int (*show_options)(struct seq_file *, struct vfsmount *);
1323  };
1324 @@ -1217,6 +1231,7 @@ extern int unregister_filesystem(struct 
1325  extern struct vfsmount *kern_mount(struct file_system_type *);
1326  extern int may_umount_tree(struct vfsmount *);
1327  extern int may_umount(struct vfsmount *);
1328 +struct vfsmount *do_kern_mount(const char *type, int flags, const char *name, void *data);
1329  extern long do_mount(char *, char *, char *, unsigned long, void *);
1330  
1331  extern int vfs_statfs(struct super_block *, struct kstatfs *);
1332 @@ -1277,10 +1292,10 @@ static inline int break_lease(struct ino
1333  }
1334  
1335  /* fs/open.c */
1336 -
1337  extern int do_truncate(struct dentry *, loff_t start, unsigned int);
1338  extern struct file *filp_open(const char *, int, int);
1339  extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1340 +extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
1341  extern int filp_close(struct file *, fl_owner_t id);
1342  extern char * getname(const char __user *);
1343  
1344 diff -rup RH_2_6_9_55.orig/include/linux/mount.h RH_2_6_9_55/include/linux/mount.h
1345 --- RH_2_6_9_55.orig/include/linux/mount.h
1346 +++ RH_2_6_9_55/include/linux/mount.h
1347 @@ -34,6 +34,8 @@ struct vfsmount
1348         struct list_head mnt_list;
1349         struct list_head mnt_fslink;    /* link in fs-specific expiry list */
1350         struct namespace *mnt_namespace; /* containing namespace */
1351 +       struct list_head mnt_lustre_list; /* GNS mount list */
1352 +       unsigned long mnt_last_used;    /* for GNS auto-umount (jiffies) */
1353  };
1354  
1355  static inline struct vfsmount *mntget(struct vfsmount *mnt)
1356 diff -rup RH_2_6_9_55.orig/include/linux/namei.h RH_2_6_9_55/include/linux/namei.h
1357 --- RH_2_6_9_55.orig/include/linux/namei.h
1358 +++ RH_2_6_9_55/include/linux/namei.h
1359 @@ -2,14 +2,55 @@
1360  #define _LINUX_NAMEI_H
1361  
1362  #include <linux/linkage.h>
1363 +#include <linux/string.h>
1364  
1365  struct vfsmount;
1366 +struct nameidata;
1367  
1368 -struct open_intent {
1369 -       int     flags;
1370 -       int     create_mode;
1371 +/* intent opcodes */
1372 +#define IT_OPEN                (1)
1373 +#define IT_CREAT       (1<<1)
1374 +#define IT_READDIR     (1<<2)
1375 +#define IT_GETATTR     (1<<3)
1376 +#define IT_LOOKUP      (1<<4)
1377 +#define IT_UNLINK      (1<<5)
1378 +#define IT_TRUNC       (1<<6)
1379 +#define IT_GETXATTR    (1<<7)
1380 +
1381 +struct lustre_intent_data {
1382 +       int     it_disposition;
1383 +       int     it_status;
1384 +       __u64   it_lock_handle;
1385 +       void    *it_data;
1386 +       int     it_lock_mode;
1387  };
1388  
1389 +#define INTENT_MAGIC 0x19620323
1390 +struct lookup_intent {
1391 +       int     it_magic;
1392 +       void    (*it_op_release)(struct lookup_intent *);
1393 +       int     it_op;
1394 +       int     it_flags;
1395 +       int     it_create_mode;
1396 +       union {
1397 +               struct lustre_intent_data lustre;
1398 +       } d;
1399 +};
1400 +
1401 +static inline void intent_reset_fs_part(struct lookup_intent *it)
1402 +{
1403 +        memset(&it->d, 0, sizeof(it->d));
1404 +        it->it_magic = INTENT_MAGIC;
1405 +        it->it_op_release = NULL;
1406 +}
1407 +
1408 +static inline void intent_init(struct lookup_intent *it, int op)
1409 +{
1410 +       memset(it, 0, sizeof(*it));
1411 +       it->it_magic = INTENT_MAGIC;
1412 +       it->it_op = op;
1413 +}
1414 +
1415  enum { MAX_NESTED_LINKS = 8 };
1416  
1417  struct nameidata {
1418 @@ -21,10 +62,7 @@ struct nameidata {
1419         unsigned        depth;
1420         char *saved_names[MAX_NESTED_LINKS + 1];
1421  
1422 -       /* Intent data */
1423 -       union {
1424 -               struct open_intent open;
1425 -       } intent;
1426 +       struct lookup_intent intent;
1427  };
1428  
1429  /*
1430 @@ -47,6 +85,8 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA
1431  #define LOOKUP_NOALT           32
1432  #define LOOKUP_ATOMIC          64
1433  #define LOOKUP_REVAL           128
1434 +#define LOOKUP_LAST            (0x1000)
1435 +#define LOOKUP_LINK_NOTLAST    (0x2000)
1436  
1437  /*
1438   * Intent data
1439 @@ -56,11 +96,18 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA
1440  #define LOOKUP_ACCESS          (0x0400)
1441  
1442  extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
1443 +extern int FASTCALL(__user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd));
1444 +#define user_path_walk_it(name,nd) \
1445 +       __user_walk_it(name, LOOKUP_FOLLOW, nd)
1446 +#define user_path_walk_link_it(name,nd) \
1447 +       __user_walk_it(name, 0, nd)
1448 +extern void intent_release(struct lookup_intent *);
1449  #define user_path_walk(name,nd) \
1450         __user_walk(name, LOOKUP_FOLLOW, nd)
1451  #define user_path_walk_link(name,nd) \
1452         __user_walk(name, 0, nd)
1453  extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1454 +extern int FASTCALL(path_lookup_it(const char *, unsigned, struct nameidata *));
1455  extern int FASTCALL(path_walk(const char *, struct nameidata *));
1456  extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
1457  extern void path_release(struct nameidata *);