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