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