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