Whamcloud - gitweb
b=13620
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs_intent-2.6.12.patch
1 --- linux-2.6.12.6.orig/fs/exec.c
2 +++ linux-2.6.12.6/fs/exec.c
3 @@ -122,9 +122,10 @@
4         struct file * file;
5         struct nameidata nd;
6         int error;
7 +       intent_init(&nd.intent, IT_OPEN);
8  
9 -       nd.intent.open.flags = FMODE_READ;
10 -       error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
11 +       nd.intent.it_flags = FMODE_READ|FMODE_EXEC;
12 +       error = __user_walk_it(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
13         if (error)
14                 goto out;
15  
16 @@ -136,7 +137,7 @@
17         if (error)
18                 goto exit;
19  
20 -       file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
21 +       file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
22         error = PTR_ERR(file);
23         if (IS_ERR(file))
24                 goto out;
25 @@ -492,8 +493,9 @@
26         int err;
27         struct file *file;
28  
29 -       nd.intent.open.flags = FMODE_READ;
30 -       err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
31 +       intent_init(&nd.intent, IT_OPEN);
32 +       nd.intent.it_flags = FMODE_READ|FMODE_EXEC;
33 +       err = path_lookup(name, LOOKUP_FOLLOW, &nd);
34         file = ERR_PTR(err);
35  
36         if (!err) {
37 @@ -506,7 +508,7 @@
38                                 err = -EACCES;
39                         file = ERR_PTR(err);
40                         if (!err) {
41 -                               file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
42 +                               file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
43                                 if (!IS_ERR(file)) {
44                                         err = deny_write_access(file);
45                                         if (err) {
46 --- linux-2.6.12.6.orig/fs/namei.c
47 +++ linux-2.6.12.6/fs/namei.c
48 @@ -301,8 +301,19 @@
49         return 0;
50  }
51  
52 +void intent_release(struct lookup_intent *it)
53 +{
54 +       if (!it)
55 +               return;
56 +       if (it->it_magic != INTENT_MAGIC)
57 +               return;
58 +       if (it->it_op_release)
59 +               it->it_op_release(it);
60 +}
61 +
62  void path_release(struct nameidata *nd)
63  {
64 +       intent_release(&nd->intent);
65         dput(nd->dentry);
66         mntput(nd->mnt);
67  }
68 @@ -392,8 +403,11 @@
69  {
70         struct dentry * result;
71         struct inode *dir = parent->d_inode;
72 +       int counter = 0;
73  
74         down(&dir->i_sem);
75 +again:
76 +       counter++;
77         /*
78          * First re-do the cached lookup just in case it was created
79          * while we waited for the directory semaphore..
80 @@ -427,13 +441,16 @@
81          * Uhhuh! Nasty case: the cache was re-populated while
82          * we waited on the semaphore. Need to revalidate.
83          */
84 -       up(&dir->i_sem);
85         if (result->d_op && result->d_op->d_revalidate) {
86                 if (!result->d_op->d_revalidate(result, nd) && !d_invalidate(result)) {
87                         dput(result);
88 -                       result = ERR_PTR(-ENOENT);
89 +                       if (counter > 10)
90 +                               result = ERR_PTR(-ESTALE);
91 +                       if (!IS_ERR(result))
92 +                               goto again;
93                 }
94         }
95 +       up(&dir->i_sem);
96         return result;
97  }
98  
99 @@ -462,6 +479,7 @@
100  {
101         int res = 0;
102         char *name;
103 +
104         if (IS_ERR(link))
105                 goto fail;
106  
107 @@ -471,6 +489,7 @@
108                         /* weird __emul_prefix() stuff did it */
109                         goto out;
110         }
111 +       intent_reset_fs_part(&nd->intent);
112         res = link_path_walk(link, nd);
113  out:
114         if (nd->depth || res || nd->last_type!=LAST_NORM)
115 @@ -703,6 +722,33 @@
116         return PTR_ERR(dentry);
117  }
118  
119 +static int revalidate_special(struct nameidata *nd)
120 +{
121 +       struct dentry *dentry = nd->dentry;
122 +       int err, counter = 0;
123 +
124 + revalidate_again:
125 +       if (!dentry->d_op || !dentry->d_op->d_revalidate)
126 +               return 0;
127 +       if (!dentry->d_op->d_revalidate(dentry, nd)) {
128 +               struct dentry *new;
129 +               if ((err = permission(dentry->d_parent->d_inode, MAY_EXEC, nd)))
130 +                       return err;
131 +               new = real_lookup(dentry->d_parent, &dentry->d_name, nd);
132 +               if (IS_ERR(new))
133 +                       return PTR_ERR(new);
134 +               d_invalidate(dentry);
135 +               dput(dentry);
136 +               nd->dentry = dentry = new;
137 +               counter++;
138 +               if (counter < 10)
139 +                       goto revalidate_again;
140 +               printk("excessive revalidate_it loops\n");
141 +               return -ESTALE;
142 +       }
143 +       return 0;
144 +}
145 +
146  /*
147   * Name resolution.
148   * This is the basic name resolution function, turning a pathname into
149 @@ -800,7 +846,11 @@
150                         goto out_dput;
151  
152                 if (inode->i_op->follow_link) {
153 +                       int save_flags = nd->flags;
154 +                       nd->flags |= LOOKUP_LINK_NOTLAST;
155                         err = do_follow_link(&next, nd);
156 +                       if (!(save_flags & LOOKUP_LINK_NOTLAST))
157 +                               nd->flags &= ~LOOKUP_LINK_NOTLAST;
158                         if (err)
159                                 goto return_err;
160                         err = -ENOENT;
161 @@ -839,6 +889,23 @@
162                                 inode = nd->dentry->d_inode;
163                                 /* fallthrough */
164                         case 1:
165 +                               nd->flags |= LOOKUP_LAST;
166 +                               err = revalidate_special(nd);
167 +                               nd->flags &= ~LOOKUP_LAST;
168 +                               if (!nd->dentry->d_inode)
169 +                                       err = -ENOENT;
170 +                               if (err) {
171 +                                       path_release(nd);
172 +                                       goto return_err;
173 +                               }
174 +                               if (lookup_flags & LOOKUP_DIRECTORY) {
175 +                                       err = -ENOTDIR;
176 +                                       if(!nd->dentry->d_inode->i_op ||
177 +                                         !nd->dentry->d_inode->i_op->lookup) {
178 +                                               path_release(nd);
179 +                                               goto return_err;
180 +                                       }
181 +                               }
182                                 goto return_reval;
183                 }
184                 if (nd->dentry->d_op && nd->dentry->d_op->d_hash) {
185 @@ -846,7 +913,9 @@
186                         if (err < 0)
187                                 break;
188                 }
189 +               nd->flags |= LOOKUP_LAST;
190                 err = do_lookup(nd, &this, &next);
191 +               nd->flags &= ~LOOKUP_LAST;
192                 if (err)
193                         break;
194                 inode = next.dentry->d_inode;
195 @@ -1097,7 +1166,7 @@
196  }
197  
198  /* SMP-safe */
199 -struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
200 +struct dentry * lookup_one_len_it(const char * name, struct dentry * base, int len, struct nameidata *nd)
201  {
202         unsigned long hash;
203         struct qstr this;
204 @@ -1117,11 +1186,16 @@
205         }
206         this.hash = end_name_hash(hash);
207  
208 -       return lookup_hash(&this, base);
209 +       return __lookup_hash(&this, base, nd);
210  access:
211         return ERR_PTR(-EACCES);
212  }
213  
214 +struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
215 +{
216 +       return lookup_one_len_it(name, base, len, NULL);
217 +}
218 +
219  /*
220   *     namei()
221   *
222 @@ -1133,7 +1207,7 @@
223   * that namei follows links, while lnamei does not.
224   * SMP-safe
225   */
226 -int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
227 +int fastcall __user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd)
228  {
229         char *tmp = getname(name);
230         int err = PTR_ERR(tmp);
231 @@ -1145,6 +1219,12 @@
232         return err;
233  }
234  
235 +int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd)
236 +{
237 +       intent_init(&nd->intent, IT_LOOKUP);
238 +       return __user_walk_it(name, flags, nd);
239 +}
240 +
241  /*
242   * It's inline, so penalty for filesystems that don't use sticky bit is
243   * minimal.
244 @@ -1426,8 +1506,8 @@
245                 acc_mode |= MAY_APPEND;
246  
247         /* Fill in the open() intent data */
248 -       nd->intent.open.flags = flag;
249 -       nd->intent.open.create_mode = mode;
250 +       nd->intent.it_flags = flag;
251 +       nd->intent.it_create_mode = mode;
252  
253         /*
254          * The simplest case - just a plain lookup.
255 @@ -1442,6 +1522,7 @@
256         /*
257          * Create - we need to know the parent.
258          */
259 +       nd->intent.it_op |= IT_CREAT;
260         error = path_lookup(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
261         if (error)
262                 return error;
263 @@ -1458,7 +1539,9 @@
264         dir = nd->dentry;
265         nd->flags &= ~LOOKUP_PARENT;
266         down(&dir->d_inode->i_sem);
267 +       nd->flags |= LOOKUP_LAST;
268         path.dentry = __lookup_hash(&nd->last, nd->dentry, nd);
269 +       nd->flags &= ~LOOKUP_LAST;
270         path.mnt = nd->mnt;
271  
272  do_last:
273 @@ -1564,7 +1647,9 @@
274         }
275         dir = nd->dentry;
276         down(&dir->d_inode->i_sem);
277 +       nd->flags |= LOOKUP_LAST;
278         path.dentry = __lookup_hash(&nd->last, nd->dentry, nd);
279 +       nd->flags &= ~LOOKUP_LAST;
280         path.mnt = nd->mnt;
281         putname(nd->last.name);
282         goto do_last;
283 --- linux-2.6.12.6.orig/fs/namespace.c
284 +++ linux-2.6.12.6/fs/namespace.c
285 @@ -62,6 +62,7 @@
286                 INIT_LIST_HEAD(&mnt->mnt_mounts);
287                 INIT_LIST_HEAD(&mnt->mnt_list);
288                 INIT_LIST_HEAD(&mnt->mnt_fslink);
289 +               INIT_LIST_HEAD(&mnt->mnt_lustre_list);
290                 if (name) {
291                         int size = strlen(name)+1;
292                         char *newname = kmalloc(size, GFP_KERNEL);
293 @@ -113,6 +114,7 @@
294  
295  static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd)
296  {
297 +       memset(old_nd, 0, sizeof(*old_nd));
298         old_nd->dentry = mnt->mnt_mountpoint;
299         old_nd->mnt = mnt->mnt_parent;
300         mnt->mnt_parent = mnt;
301 @@ -176,6 +178,9 @@
302  {
303         struct super_block *sb = mnt->mnt_sb;
304         dput(mnt->mnt_root);
305 +       spin_lock(&dcache_lock);
306 +       list_del(&mnt->mnt_lustre_list);
307 +       spin_unlock(&dcache_lock);
308         free_vfsmnt(mnt);
309         deactivate_super(sb);
310  }
311 @@ -402,6 +407,8 @@
312          */
313  
314         lock_kernel();
315 +       if (sb->s_op->umount_lustre)
316 +               sb->s_op->umount_lustre(sb);
317         if( (flags&MNT_FORCE) && sb->s_op->umount_begin)
318                 sb->s_op->umount_begin(sb);
319         unlock_kernel();
320 @@ -627,6 +634,7 @@
321                 return err;
322         if (!old_name || !*old_name)
323                 return -EINVAL;
324 +       intent_init(&old_nd.intent, IT_LOOKUP);
325         err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
326         if (err)
327                 return err;
328 @@ -701,6 +709,7 @@
329                 return -EPERM;
330         if (!old_name || !*old_name)
331                 return -EINVAL;
332 +       intent_init(&old_nd.intent, IT_LOOKUP);
333         err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
334         if (err)
335                 return err;
336 @@ -1012,6 +1021,7 @@
337         int retval = 0;
338         int mnt_flags = 0;
339  
340 +       intent_init(&nd.intent, IT_LOOKUP);
341         /* Discard magic */
342         if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
343                 flags &= ~MS_MGC_MSK;
344 --- linux-2.6.12.6.orig/fs/open.c
345 +++ linux-2.6.12.6/fs/open.c
346 @@ -215,12 +215,12 @@
347         struct nameidata nd;
348         struct inode * inode;
349         int error;
350 -
351 +       intent_init(&nd.intent, IT_GETATTR);
352         error = -EINVAL;
353         if (length < 0) /* sorry, but loff_t says... */
354                 goto out;
355  
356 -       error = user_path_walk(path, &nd);
357 +       error = user_path_walk_it(path, &nd);
358         if (error)
359                 goto out;
360         inode = nd.dentry->d_inode;
361 @@ -474,6 +474,7 @@
362         int old_fsuid, old_fsgid;
363         kernel_cap_t old_cap;
364         int res;
365 +       intent_init(&nd.intent, IT_GETATTR);
366  
367         if (mode & ~S_IRWXO)    /* where's F_OK, X_OK, W_OK, R_OK? */
368                 return -EINVAL;
369 @@ -498,13 +499,14 @@
370         else
371                 current->cap_effective = current->cap_permitted;
372  
373 -       res = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
374 +       res = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
375         if (!res) {
376                 res = permission(nd.dentry->d_inode, mode, &nd);
377                 /* SuS v2 requires we report a read only fs too */
378                 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
379                    && !special_file(nd.dentry->d_inode->i_mode))
380                         res = -EROFS;
381 +
382                 path_release(&nd);
383         }
384  
385 @@ -519,8 +521,9 @@
386  {
387         struct nameidata nd;
388         int error;
389 +       intent_init(&nd.intent, IT_GETATTR);
390  
391 -       error = __user_walk(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
392 +       error = __user_walk_it(filename, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &nd);
393         if (error)
394                 goto out;
395  
396 @@ -570,8 +573,9 @@
397  {
398         struct nameidata nd;
399         int error;
400 +       intent_init(&nd.intent, IT_GETATTR);
401  
402 -       error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
403 +       error = __user_walk_it(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
404         if (error)
405                 goto out;
406  
407 @@ -750,27 +754,8 @@
408   * for the internal routines (ie open_namei()/follow_link() etc). 00 is
409   * used by symlinks.
410   */
411 -struct file *filp_open(const char * filename, int flags, int mode)
412 -{
413 -       int namei_flags, error;
414 -       struct nameidata nd;
415 -
416 -       namei_flags = flags;
417 -       if ((namei_flags+1) & O_ACCMODE)
418 -               namei_flags++;
419 -       if (namei_flags & O_TRUNC)
420 -               namei_flags |= 2;
421 -
422 -       error = open_namei(filename, namei_flags, mode, &nd);
423 -       if (!error)
424 -               return dentry_open(nd.dentry, nd.mnt, flags);
425 -
426 -       return ERR_PTR(error);
427 -}
428 -
429 -EXPORT_SYMBOL(filp_open);
430 -
431 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
432 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags,
433 +                           struct lookup_intent *it)
434  {
435         struct file * f;
436         struct inode *inode;
437 @@ -782,6 +767,7 @@
438                 goto cleanup_dentry;
439         f->f_flags = flags;
440         f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;
441 +       f->f_it = it;
442         inode = dentry->d_inode;
443         if (f->f_mode & FMODE_WRITE) {
444                 error = get_write_access(inode);
445 @@ -800,6 +786,7 @@
446                 error = f->f_op->open(inode,f);
447                 if (error)
448                         goto cleanup_all;
449 +               intent_release(it);
450         }
451         f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
452  
453 @@ -825,6 +812,7 @@
454  cleanup_file:
455         put_filp(f);
456  cleanup_dentry:
457 +       intent_release(it);
458         dput(dentry);
459         mntput(mnt);
460         return ERR_PTR(error);
461 @@ -832,6 +820,36 @@
462  
463  EXPORT_SYMBOL(dentry_open);
464  
465 +struct file *filp_open(const char * filename, int flags, int mode)
466 +{
467 +       int namei_flags, error;
468 +       struct file * temp_filp;
469 +       struct nameidata nd;
470 +       intent_init(&nd.intent, IT_OPEN);
471 +
472 +       namei_flags = flags;
473 +       if ((namei_flags+1) & O_ACCMODE)
474 +               namei_flags++;
475 +       if (namei_flags & O_TRUNC)
476 +               namei_flags |= 2;
477 +
478 +       error = open_namei(filename, namei_flags, mode, &nd);
479 +       if (!error) {
480 +               temp_filp = dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent);
481 +               return temp_filp;
482 +       }
483 +       return ERR_PTR(error);
484 +}
485 +
486 +
487 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
488 +{
489 +       struct lookup_intent it;
490 +       intent_init(&it, IT_LOOKUP);
491 +
492 +       return dentry_open_it(dentry, mnt, flags, &it);
493 +}
494 +
495  /*
496   * Find an empty file descriptor entry, and mark it busy.
497   */
498 --- linux-2.6.12.6.orig/fs/stat.c
499 +++ linux-2.6.12.6/fs/stat.c
500 @@ -38,7 +38,7 @@
501  
502  EXPORT_SYMBOL(generic_fillattr);
503  
504 -int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
505 +int vfs_getattr_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat *stat)
506  {
507         struct inode *inode = dentry->d_inode;
508         int retval;
509 @@ -47,6 +47,8 @@
510         if (retval)
511                 return retval;
512  
513 +       if (inode->i_op->getattr_it)
514 +               return inode->i_op->getattr_it(mnt, dentry, it, stat);
515         if (inode->i_op->getattr)
516                 return inode->i_op->getattr(mnt, dentry, stat);
517  
518 @@ -63,14 +65,20 @@
519  
520  EXPORT_SYMBOL(vfs_getattr);
521  
522 +int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
523 +{
524 +       return vfs_getattr_it(mnt, dentry, NULL, stat);
525 +}
526 +
527  int vfs_stat(char __user *name, struct kstat *stat)
528  {
529         struct nameidata nd;
530         int error;
531 +       intent_init(&nd.intent, IT_GETATTR);
532  
533 -       error = user_path_walk(name, &nd);
534 +       error = user_path_walk_it(name, &nd);
535         if (!error) {
536 -               error = vfs_getattr(nd.mnt, nd.dentry, stat);
537 +               error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
538                 path_release(&nd);
539         }
540         return error;
541 @@ -82,10 +90,11 @@
542  {
543         struct nameidata nd;
544         int error;
545 +       intent_init(&nd.intent, IT_GETATTR);
546  
547 -       error = user_path_walk_link(name, &nd);
548 +       error = user_path_walk_link_it(name, &nd);
549         if (!error) {
550 -               error = vfs_getattr(nd.mnt, nd.dentry, stat);
551 +               error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
552                 path_release(&nd);
553         }
554         return error;
555 @@ -97,9 +106,12 @@
556  {
557         struct file *f = fget(fd);
558         int error = -EBADF;
559 +       struct nameidata nd;
560 +       intent_init(&nd.intent, IT_GETATTR);
561  
562         if (f) {
563 -               error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
564 +               error = vfs_getattr_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
565 +               intent_release(&nd.intent);
566                 fput(f);
567         }
568         return error;
569 --- linux-2.6.12.6.orig/fs/inode.c
570 +++ linux-2.6.12.6/fs/inode.c
571 @@ -230,6 +230,7 @@
572         inodes_stat.nr_unused--;
573  }
574  
575 +EXPORT_SYMBOL(__iget);
576  /**
577   * clear_inode - clear an inode
578   * @inode: inode to clear
579 --- linux-2.6.12.6.orig/include/linux/dcache.h
580 +++ linux-2.6.12.6/include/linux/dcache.h
581 @@ -4,6 +4,7 @@
582  #ifdef __KERNEL__
583  
584  #include <asm/atomic.h>
585 +#include <linux/string.h>
586  #include <linux/list.h>
587  #include <linux/spinlock.h>
588  #include <linux/cache.h>
589 @@ -37,6 +38,8 @@
590         const unsigned char *name;
591  };
592  
593 +#include <linux/namei.h>
594 +
595  struct dentry_stat_t {
596         int nr_dentry;
597         int nr_unused;
598 --- linux-2.6.12.6.orig/include/linux/fs.h
599 +++ linux-2.6.12.6/include/linux/fs.h
600 @@ -58,6 +58,7 @@
601  
602  #define FMODE_READ 1
603  #define FMODE_WRITE 2
604 +#define FMODE_EXEC 4
605  
606  /* Internal kernel extensions */
607  #define FMODE_LSEEK    4
608 @@ -260,6 +261,8 @@
609  #define ATTR_ATTR_FLAG 1024
610  #define ATTR_KILL_SUID 2048
611  #define ATTR_KILL_SGID 4096
612 +#define ATTR_RAW               8192    /* file system, not vfs will massage attrs */
613 +#define ATTR_FROM_OPEN         16384    /* called from open path, ie O_TRUNC */
614  
615  /*
616   * This is the Inode Attributes structure, used for notify_change().  It
617 @@ -463,6 +466,7 @@
618         struct block_device     *i_bdev;
619         struct cdev             *i_cdev;
620         int                     i_cindex;
621 +       void                    *i_filterdata;
622  
623         __u32                   i_generation;
624  
625 @@ -600,6 +604,7 @@
626         spinlock_t              f_ep_lock;
627  #endif /* #ifdef CONFIG_EPOLL */
628         struct address_space    *f_mapping;
629 +       struct lookup_intent    *f_it;
630  };
631  extern spinlock_t files_lock;
632  #define file_list_lock() spin_lock(&files_lock);
633 @@ -968,7 +973,9 @@
634         void (*truncate) (struct inode *);
635         int (*permission) (struct inode *, int, struct nameidata *);
636         int (*setattr) (struct dentry *, struct iattr *);
637 +       int (*setattr_raw) (struct inode *, struct iattr *);
638         int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
639 +       int (*getattr_it) (struct vfsmount *, struct dentry *, struct lookup_intent *, struct kstat *);
640         int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
641         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
642         ssize_t (*listxattr) (struct dentry *, char *, size_t);
643 @@ -1008,6 +1015,7 @@
644         int (*remount_fs) (struct super_block *, int *, char *);
645         void (*clear_inode) (struct inode *);
646         void (*umount_begin) (struct super_block *);
647 +       void (*umount_lustre) (struct super_block *);
648  
649         int (*show_options)(struct seq_file *, struct vfsmount *);
650  
651 @@ -1210,6 +1218,7 @@
652  extern struct vfsmount *kern_mount(struct file_system_type *);
653  extern int may_umount_tree(struct vfsmount *);
654  extern int may_umount(struct vfsmount *);
655 +struct vfsmount *do_kern_mount(const char *type, int flags, const char *name, void *data);
656  extern long do_mount(char *, char *, char *, unsigned long, void *);
657  
658  extern int vfs_statfs(struct super_block *, struct kstatfs *);
659 @@ -1262,6 +1271,7 @@
660  extern int do_truncate(struct dentry *, loff_t start);
661  extern struct file *filp_open(const char *, int, int);
662  extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
663 +extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
664  extern int filp_close(struct file *, fl_owner_t id);
665  extern char * getname(const char __user *);
666  
667 --- linux-2.6.12.6.orig/include/linux/namei.h
668 +++ linux-2.6.12.6/include/linux/namei.h
669 @@ -2,14 +2,55 @@
670  #define _LINUX_NAMEI_H
671  
672  #include <linux/linkage.h>
673 +#include <linux/string.h>
674  
675  struct vfsmount;
676 +struct nameidata;
677  
678 -struct open_intent {
679 -       int     flags;
680 -       int     create_mode;
681 +/* intent opcodes */
682 +#define IT_OPEN                (1)
683 +#define IT_CREAT       (1<<1)
684 +#define IT_READDIR     (1<<2)
685 +#define IT_GETATTR     (1<<3)
686 +#define IT_LOOKUP      (1<<4)
687 +#define IT_UNLINK      (1<<5)
688 +#define IT_TRUNC       (1<<6)
689 +#define IT_GETXATTR    (1<<7)
690 +
691 +struct lustre_intent_data {
692 +       int     it_disposition;
693 +       int     it_status;
694 +       __u64   it_lock_handle;
695 +       void    *it_data;
696 +       int     it_lock_mode;
697  };
698  
699 +#define INTENT_MAGIC 0x19620323
700 +struct lookup_intent {
701 +       int     it_magic;
702 +       void    (*it_op_release)(struct lookup_intent *);
703 +       int     it_op;
704 +       int     it_flags;
705 +       int     it_create_mode;
706 +       union {
707 +               struct lustre_intent_data lustre;
708 +       } d;
709 +};
710 +
711 +static inline void intent_reset_fs_part(struct lookup_intent *it)
712 +{
713 +        memset(&it->d, 0, sizeof(it->d));
714 +        it->it_magic = INTENT_MAGIC;
715 +        it->it_op_release = NULL;
716 +}
717 +
718 +static inline void intent_init(struct lookup_intent *it, int op)
719 +{
720 +       memset(it, 0, sizeof(*it));
721 +       it->it_magic = INTENT_MAGIC;
722 +       it->it_op = op;
723 +}
724 +
725  enum { MAX_NESTED_LINKS = 5 };
726  
727  struct nameidata {
728 @@ -21,10 +62,7 @@
729         unsigned        depth;
730         char *saved_names[MAX_NESTED_LINKS + 1];
731  
732 -       /* Intent data */
733 -       union {
734 -               struct open_intent open;
735 -       } intent;
736 +       struct lookup_intent intent;
737  };
738  
739  /*
740 @@ -47,6 +85,8 @@
741  #define LOOKUP_PARENT          16
742  #define LOOKUP_NOALT           32
743  #define LOOKUP_REVAL           64
744 +#define LOOKUP_LAST            (0x1000)
745 +#define LOOKUP_LINK_NOTLAST    (0x2000)
746  /*
747   * Intent data
748   */
749 @@ -55,6 +95,12 @@
750  #define LOOKUP_ACCESS          (0x0400)
751  
752  extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
753 +extern int FASTCALL(__user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd));
754 +#define user_path_walk_it(name,nd) \
755 +       __user_walk_it(name, LOOKUP_FOLLOW, nd)
756 +#define user_path_walk_link_it(name,nd) \
757 +       __user_walk_it(name, 0, nd)
758 +extern void intent_release(struct lookup_intent *);
759  #define user_path_walk(name,nd) \
760         __user_walk(name, LOOKUP_FOLLOW, nd)
761  #define user_path_walk_link(name,nd) \
762 @@ -67,7 +113,6 @@
763  
764  extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
765  extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
766 -
767  extern int follow_down(struct vfsmount **, struct dentry **);
768  extern int follow_up(struct vfsmount **, struct dentry **);
769  
770 --- linux-2.6.12.6.orig/include/linux/mount.h
771 +++ linux-2.6.12.6/include/linux/mount.h
772 @@ -36,6 +36,8 @@
773         struct list_head mnt_list;
774         struct list_head mnt_fslink;    /* link in fs-specific expiry list */
775         struct namespace *mnt_namespace; /* containing namespace */
776 +       struct list_head mnt_lustre_list; /* GNS mount list */
777 +       unsigned long mnt_last_used;    /* for GNS auto-umount (jiffies) */
778  };
779  
780  static inline struct vfsmount *mntget(struct vfsmount *mnt)