Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs_intent-2.6-rhel4.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              |   57 ++++++++++++++--------------
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, 225 insertions(+), 55 deletions(-)
13
14 --- linux-2.6.9.orig/fs/exec.c
15 +++ linux-2.6.9/fs/exec.c
16 @@ -126,9 +126,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 @@ -140,7 +141,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 @@ -489,8 +490,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 @@ -503,7 +505,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.9.orig/fs/inode.c
60 +++ linux-2.6.9/fs/inode.c
61 @@ -235,6 +235,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.9.orig/fs/namei.c
70 +++ linux-2.6.9/fs/namei.c
71 @@ -274,8 +274,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 @@ -367,7 +378,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 @@ -406,7 +420,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 @@ -437,6 +454,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 @@ -446,6 +464,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 @@ -654,6 +673,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   * This is the basic name resolution function, turning a pathname into
164 @@ -755,8 +801,12 @@ static fastcall int __link_path_walk(con
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 @@ -795,14 +845,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 @@ -1053,7 +1123,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 @@ -1073,11 +1143,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 @@ -1089,7 +1164,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 @@ -1101,6 +1176,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 @@ -1387,8 +1468,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 @@ -1403,6 +1484,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 @@ -1419,7 +1501,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 @@ -1532,7 +1616,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.9.orig/fs/namespace.c
301 +++ linux-2.6.9/fs/namespace.c
302 @@ -61,6 +61,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 @@ -114,6 +115,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 @@ -177,6 +179,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 @@ -403,6 +408,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.9.orig/fs/open.c
362 +++ linux-2.6.9/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 @@ -741,8 +745,6 @@ asmlinkage long sys_fchown(unsigned int 
425         return error;
426  }
427  
428 -static struct file *__dentry_open(struct dentry *, struct vfsmount *, int, struct file *);
429 -
430  /*
431   * Note that while the flag value (low two bits) for sys_open means:
432   *     00 - read-only
433 @@ -760,8 +762,9 @@ static struct file *__dentry_open(struct
434  struct file *filp_open(const char * filename, int flags, int mode)
435  {
436         int namei_flags, error;
437 +       struct file * temp_filp;
438         struct nameidata nd;
439 -       struct file *f;
440 +       intent_init(&nd.intent, IT_OPEN);
441  
442         namei_flags = flags;
443         if ((namei_flags+1) & O_ACCMODE)
444 @@ -769,16 +772,11 @@ struct file *filp_open(const char * file
445         if (namei_flags & O_TRUNC)
446                 namei_flags |= 2;
447  
448 -       error = -ENFILE;
449 -       f = get_empty_filp();
450 -       if (f == NULL)
451 -               return ERR_PTR(error);
452 -
453         error = open_namei(filename, namei_flags, mode, &nd);
454 -       if (!error)
455 -               return __dentry_open(nd.dentry, nd.mnt, flags, f);
456 -
457 -       put_filp(f);
458 +       if (!error) {
459 +               temp_filp = dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent);
460 +               return temp_filp;
461 +       }
462         return ERR_PTR(error);
463  }
464  
465 @@ -786,29 +784,27 @@ EXPORT_SYMBOL(filp_open);
466  
467  struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
468  {
469 -       int error;
470 -       struct file *f;
471 -
472 -       error = -ENFILE;
473 -       f = get_empty_filp();
474 -       if (f == NULL) {
475 -               dput(dentry);
476 -               mntput(mnt);
477 -               return ERR_PTR(error);
478 -       }
479 +       struct lookup_intent it;
480 +       intent_init(&it, IT_LOOKUP);
481  
482 -       return __dentry_open(dentry, mnt, flags, f);
483 +       return dentry_open_it(dentry, mnt, flags, &it);
484  }
485  
486  EXPORT_SYMBOL(dentry_open);
487  
488 -static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags, struct file *f)
489 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags, struct lookup_intent *it)
490  {
491 +       struct file *f;
492         struct inode *inode;
493         int error;
494  
495 +       error = -ENFILE;
496 +       f = get_empty_filp();
497 +       if (!f)
498 +               goto cleanup_dentry;
499         f->f_flags = flags;
500         f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;
501 +       f->f_it = it;
502         inode = dentry->d_inode;
503         if (f->f_mode & FMODE_WRITE) {
504                 error = get_write_access(inode);
505 @@ -827,6 +823,7 @@ static struct file *__dentry_open(struct
506                 error = f->f_op->open(inode,f);
507                 if (error)
508                         goto cleanup_all;
509 +               intent_release(it);
510         }
511         f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
512  
513 @@ -851,6 +848,8 @@ cleanup_all:
514         f->f_vfsmnt = NULL;
515  cleanup_file:
516         put_filp(f);
517 +cleanup_dentry:
518 +       intent_release(it);
519         dput(dentry);
520         mntput(mnt);
521         return ERR_PTR(error);
522 --- linux-2.6.9.orig/fs/stat.c
523 +++ linux-2.6.9/fs/stat.c
524 @@ -37,7 +37,7 @@ void generic_fillattr(struct inode *inod
525  
526  EXPORT_SYMBOL(generic_fillattr);
527  
528 -int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
529 +int vfs_getattr_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat *stat)
530  {
531         struct inode *inode = dentry->d_inode;
532         int retval;
533 @@ -46,6 +46,8 @@ int vfs_getattr(struct vfsmount *mnt, st
534         if (retval)
535                 return retval;
536  
537 +       if (inode->i_op->getattr_it)
538 +               return inode->i_op->getattr_it(mnt, dentry, it, stat);
539         if (inode->i_op->getattr)
540                 return inode->i_op->getattr(mnt, dentry, stat);
541  
542 @@ -62,14 +64,20 @@ int vfs_getattr(struct vfsmount *mnt, st
543  
544  EXPORT_SYMBOL(vfs_getattr);
545  
546 +int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
547 +{
548 +       return vfs_getattr_it(mnt, dentry, NULL, stat);
549 +}
550 +
551  int vfs_stat(char __user *name, struct kstat *stat)
552  {
553         struct nameidata nd;
554         int error;
555 +       intent_init(&nd.intent, IT_GETATTR);
556  
557 -       error = user_path_walk(name, &nd);
558 +       error = user_path_walk_it(name, &nd);
559         if (!error) {
560 -               error = vfs_getattr(nd.mnt, nd.dentry, stat);
561 +               error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
562                 path_release(&nd);
563         }
564         return error;
565 @@ -81,10 +89,11 @@ int vfs_lstat(char __user *name, struct 
566  {
567         struct nameidata nd;
568         int error;
569 +       intent_init(&nd.intent, IT_GETATTR);
570  
571 -       error = user_path_walk_link(name, &nd);
572 +       error = user_path_walk_link_it(name, &nd);
573         if (!error) {
574 -               error = vfs_getattr(nd.mnt, nd.dentry, stat);
575 +               error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
576                 path_release(&nd);
577         }
578         return error;
579 @@ -96,9 +105,12 @@ int vfs_fstat(unsigned int fd, struct ks
580  {
581         struct file *f = fget(fd);
582         int error = -EBADF;
583 +       struct nameidata nd;
584 +       intent_init(&nd.intent, IT_GETATTR);
585  
586         if (f) {
587 -               error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
588 +               error = vfs_getattr_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
589 +               intent_release(&nd.intent);
590                 fput(f);
591         }
592         return error;
593 --- linux-2.6.9.orig/include/linux/dcache.h
594 +++ linux-2.6.9/include/linux/dcache.h
595 @@ -4,6 +4,7 @@
596  #ifdef __KERNEL__
597  
598  #include <asm/atomic.h>
599 +#include <linux/string.h>
600  #include <linux/list.h>
601  #include <linux/spinlock.h>
602  #include <linux/cache.h>
603 @@ -37,6 +38,8 @@ struct qstr {
604         const unsigned char *name;
605  };
606  
607 +#include <linux/namei.h>
608 +
609  struct dentry_stat_t {
610         int nr_dentry;
611         int nr_unused;
612 --- linux-2.6.9.orig/include/linux/fs.h
613 +++ linux-2.6.9/include/linux/fs.h
614 @@ -81,6 +81,11 @@ extern int leases_enable, dir_notify_ena
615  #define FMODE_PREAD    8
616  #define FMODE_PWRITE   FMODE_PREAD     /* These go hand in hand */
617  
618 +/* File is being opened for execution. Primary users of this flag are
619 +   distributed filesystems that can use it to achieve correct ETXTBUSY
620 +   behavior for cross-node execution/opening_for_writing of files */
621 +#define FMODE_EXEC     16
622 +
623  #define RW_MASK                1
624  #define RWA_MASK       2
625  #define READ 0
626 @@ -259,6 +260,8 @@ typedef void (dio_iodone_t)(struct inode
627  #define ATTR_ATTR_FLAG 1024
628  #define ATTR_KILL_SUID 2048
629  #define ATTR_KILL_SGID 4096
630 +#define ATTR_RAW               8192    /* file system, not vfs will massage attrs */
631 +#define ATTR_FROM_OPEN         16384    /* called from open path, ie O_TRUNC */
632  
633  /*
634   * This is the Inode Attributes structure, used for notify_change().  It
635 @@ -457,6 +460,7 @@ struct inode {
636         struct block_device     *i_bdev;
637         struct cdev             *i_cdev;
638         int                     i_cindex;
639 +       void                    *i_filterdata;
640  
641         __u32                   i_generation;
642  
643 @@ -590,6 +594,7 @@ struct file {
644         spinlock_t              f_ep_lock;
645  #endif /* #ifdef CONFIG_EPOLL */
646         struct address_space    *f_mapping;
647 +       struct lookup_intent    *f_it;
648  };
649  extern spinlock_t files_lock;
650  #define file_list_lock() spin_lock(&files_lock);
651 @@ -962,7 +967,9 @@ struct inode_operations {
652         void (*truncate) (struct inode *);
653         int (*permission) (struct inode *, int, struct nameidata *);
654         int (*setattr) (struct dentry *, struct iattr *);
655 +       int (*setattr_raw) (struct inode *, struct iattr *);
656         int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
657 +       int (*getattr_it) (struct vfsmount *, struct dentry *, struct lookup_intent *, struct kstat *);
658         int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
659         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
660         ssize_t (*listxattr) (struct dentry *, char *, size_t);
661 @@ -1002,6 +1009,7 @@ struct super_operations {
662         int (*remount_fs) (struct super_block *, int *, char *);
663         void (*clear_inode) (struct inode *);
664         void (*umount_begin) (struct super_block *);
665 +       void (*umount_lustre) (struct super_block *);
666  
667         int (*show_options)(struct seq_file *, struct vfsmount *);
668  };
669 @@ -1194,6 +1202,7 @@ extern int unregister_filesystem(struct 
670  extern struct vfsmount *kern_mount(struct file_system_type *);
671  extern int may_umount_tree(struct vfsmount *);
672  extern int may_umount(struct vfsmount *);
673 +struct vfsmount *do_kern_mount(const char *type, int flags, const char *name, void *data);
674  extern long do_mount(char *, char *, char *, unsigned long, void *);
675  
676  extern int vfs_statfs(struct super_block *, struct kstatfs *);
677 @@ -1258,6 +1267,7 @@ static inline int break_lease(struct ino
678  extern int do_truncate(struct dentry *, loff_t start);
679  extern struct file *filp_open(const char *, int, int);
680  extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
681 +extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
682  extern int filp_close(struct file *, fl_owner_t id);
683  extern char * getname(const char __user *);
684  
685 --- linux-2.6.9.orig/include/linux/mount.h
686 +++ linux-2.6.9/include/linux/mount.h
687 @@ -34,6 +34,8 @@ struct vfsmount
688         struct list_head mnt_list;
689         struct list_head mnt_fslink;    /* link in fs-specific expiry list */
690         struct namespace *mnt_namespace; /* containing namespace */
691 +       struct list_head mnt_lustre_list; /* GNS mount list */
692 +       unsigned long mnt_last_used;    /* for GNS auto-umount (jiffies) */
693  };
694  
695  static inline struct vfsmount *mntget(struct vfsmount *mnt)
696 --- linux-2.6.9.orig/include/linux/namei.h
697 +++ linux-2.6.9/include/linux/namei.h
698 @@ -2,14 +2,55 @@
699  #define _LINUX_NAMEI_H
700  
701  #include <linux/linkage.h>
702 +#include <linux/string.h>
703  
704  struct vfsmount;
705 +struct nameidata;
706  
707 -struct open_intent {
708 -       int     flags;
709 -       int     create_mode;
710 +/* intent opcodes */
711 +#define IT_OPEN                (1)
712 +#define IT_CREAT       (1<<1)
713 +#define IT_READDIR     (1<<2)
714 +#define IT_GETATTR     (1<<3)
715 +#define IT_LOOKUP      (1<<4)
716 +#define IT_UNLINK      (1<<5)
717 +#define IT_TRUNC       (1<<6)
718 +#define IT_GETXATTR    (1<<7)
719 +
720 +struct lustre_intent_data {
721 +       int     it_disposition;
722 +       int     it_status;
723 +       __u64   it_lock_handle;
724 +       void    *it_data;
725 +       int     it_lock_mode;
726  };
727  
728 +#define INTENT_MAGIC 0x19620323
729 +struct lookup_intent {
730 +       int     it_magic;
731 +       void    (*it_op_release)(struct lookup_intent *);
732 +       int     it_op;
733 +       int     it_flags;
734 +       int     it_create_mode;
735 +       union {
736 +               struct lustre_intent_data lustre;
737 +       } d;
738 +};
739 +
740 +static inline void intent_reset_fs_part(struct lookup_intent *it)
741 +{
742 +        memset(&it->d, 0, sizeof(it->d));
743 +        it->it_magic = INTENT_MAGIC;
744 +        it->it_op_release = NULL;
745 +}
746 +
747 +static inline void intent_init(struct lookup_intent *it, int op)
748 +{
749 +       memset(it, 0, sizeof(*it));
750 +       it->it_magic = INTENT_MAGIC;
751 +       it->it_op = op;
752 +}
753 +
754  enum { MAX_NESTED_LINKS = 8 };
755  
756  struct nameidata {
757 @@ -21,10 +62,7 @@ struct nameidata {
758         unsigned        depth;
759         char *saved_names[MAX_NESTED_LINKS + 1];
760  
761 -       /* Intent data */
762 -       union {
763 -               struct open_intent open;
764 -       } intent;
765 +       struct lookup_intent intent;
766  };
767  
768  /*
769 @@ -47,6 +85,8 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA
770  #define LOOKUP_NOALT           32
771  #define LOOKUP_ATOMIC          64
772  #define LOOKUP_REVAL           128
773 +#define LOOKUP_LAST            (0x1000)
774 +#define LOOKUP_LINK_NOTLAST    (0x2000)
775  
776  /*
777   * Intent data
778 @@ -56,6 +96,12 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA
779  #define LOOKUP_ACCESS          (0x0400)
780  
781  extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
782 +extern int FASTCALL(__user_walk_it(const char __user *name, unsigned flags, struct nameidata *nd));
783 +#define user_path_walk_it(name,nd) \
784 +       __user_walk_it(name, LOOKUP_FOLLOW, nd)
785 +#define user_path_walk_link_it(name,nd) \
786 +       __user_walk_it(name, 0, nd)
787 +extern void intent_release(struct lookup_intent *);
788  #define user_path_walk(name,nd) \
789         __user_walk(name, LOOKUP_FOLLOW, nd)
790  #define user_path_walk_link(name,nd) \
791 @@ -68,7 +114,6 @@ extern void path_release_on_umount(struc
792  
793  extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
794  extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
795 -
796  extern int follow_down(struct vfsmount **, struct dentry **);
797  extern int follow_up(struct vfsmount **, struct dentry **);
798