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