Whamcloud - gitweb
- missed patches from suse-2.4.21-2 series added
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs_intent-2.4.21-suse2.patch
1  fs/dcache.c               |   19 ++
2  fs/exec.c                 |   17 +-
3  fs/namei.c                |  295 +++++++++++++++++++++++++++++++++++++++-------
4  fs/namespace.c            |   28 +++-
5  fs/open.c                 |  172 +++++++++++++++++++-------
6  fs/stat.c                 |   52 +++++---
7  include/linux/dcache.h    |   60 +++++++++
8  include/linux/fs.h        |   32 ++++
9  include/linux/fs_struct.h |    4 
10  kernel/exit.c             |    3 
11  kernel/fork.c             |    3 
12  kernel/ksyms.c            |    1 
13  12 files changed, 558 insertions(+), 128 deletions(-)
14
15 Index: kernel-2.4.212lgns/fs/dcache.c
16 ===================================================================
17 --- kernel-2.4.212lgns.orig/fs/dcache.c 2003-10-28 10:33:59.000000000 -0800
18 +++ kernel-2.4.212lgns/fs/dcache.c      2004-05-11 06:41:10.000000000 -0700
19 @@ -186,6 +186,13 @@
20                 spin_unlock(&dcache_lock);
21                 return 0;
22         }
23 +
24 +       /* network invalidation by Lustre */
25 +       if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
26 +               spin_unlock(&dcache_lock);
27 +               return 0;
28 +       }
29 +
30         /*
31          * Check whether to do a partial shrink_dcache
32          * to get rid of unused child entries.
33 @@ -838,13 +845,19 @@
34   * Adds a dentry to the hash according to its name.
35   */
36   
37 -void d_rehash(struct dentry * entry)
38 +void __d_rehash(struct dentry * entry, int lock)
39  {
40         struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
41         if (!list_empty(&entry->d_hash)) BUG();
42 -       spin_lock(&dcache_lock);
43 +       if (lock) spin_lock(&dcache_lock);
44         list_add(&entry->d_hash, list);
45 -       spin_unlock(&dcache_lock);
46 +       if (lock) spin_unlock(&dcache_lock);
47 +}
48 +EXPORT_SYMBOL(__d_rehash);
49 +
50 +void d_rehash(struct dentry * entry)
51 +{
52 +       __d_rehash(entry, 1);
53  }
54  
55  #define do_switch(x,y) do { \
56 Index: kernel-2.4.212lgns/fs/exec.c
57 ===================================================================
58 --- kernel-2.4.212lgns.orig/fs/exec.c   2003-10-28 10:34:17.000000000 -0800
59 +++ kernel-2.4.212lgns/fs/exec.c        2004-05-11 06:41:10.000000000 -0700
60 @@ -112,8 +112,10 @@
61         struct file * file;
62         struct nameidata nd;
63         int error;
64 +       struct lookup_intent it = { .it_op = IT_OPEN,
65 +                                   .it_flags = FMODE_READ|FMODE_EXEC };
66  
67 -       error = user_path_walk(library, &nd);
68 +       error = user_path_walk_it(library, &nd, &it);
69         if (error)
70                 goto out;
71  
72 @@ -125,7 +127,8 @@
73         if (error)
74                 goto exit;
75  
76 -       file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
77 +       file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
78 +       intent_release(&it);
79         error = PTR_ERR(file);
80         if (IS_ERR(file))
81                 goto out;
82 @@ -382,8 +385,10 @@
83         struct inode *inode;
84         struct file *file;
85         int err = 0;
86 +       struct lookup_intent it = { .it_op = IT_OPEN,
87 +                                   .it_flags = FMODE_READ|FMODE_EXEC };
88  
89 -       err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
90 +       err = path_lookup_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
91         file = ERR_PTR(err);
92         if (!err) {
93                 inode = nd.dentry->d_inode;
94 @@ -395,7 +400,8 @@
95                                 err = -EACCES;
96                         file = ERR_PTR(err);
97                         if (!err) {
98 -                               file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
99 +                               file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
100 +                               intent_release(&it);
101                                 if (!IS_ERR(file)) {
102                                         err = deny_write_access(file);
103                                         if (err) {
104 @@ -407,6 +413,7 @@
105                                 return file;
106                         }
107                 }
108 +               intent_release(&it);
109                 path_release(&nd);
110         }
111         goto out;
112 @@ -1150,7 +1157,7 @@
113                 goto close_fail;
114         if (!file->f_op->write)
115                 goto close_fail;
116 -       if (do_truncate(file->f_dentry, 0) != 0)
117 +       if (do_truncate(file->f_dentry, 0, 0) != 0)
118                 goto close_fail;
119  
120         retval = binfmt->core_dump(signr, regs, file);
121 Index: kernel-2.4.212lgns/fs/namei.c
122 ===================================================================
123 --- kernel-2.4.212lgns.orig/fs/namei.c  2003-10-28 10:34:18.000000000 -0800
124 +++ kernel-2.4.212lgns/fs/namei.c       2004-05-11 06:41:10.000000000 -0700
125 @@ -94,6 +94,13 @@
126   * XEmacs seems to be relying on it...
127   */
128  
129 +void intent_release(struct lookup_intent *it)
130 +{
131 +       if (it && it->it_op_release)
132 +               it->it_op_release(it);
133 +
134 +}
135 +
136  /* In order to reduce some races, while at the same time doing additional
137   * checking and hopefully speeding things up, we copy filenames to the
138   * kernel data space before using them..
139 @@ -260,10 +267,19 @@
140   * Internal lookup() using the new generic dcache.
141   * SMP-safe
142   */
143 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
144 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
145 +                                   int flags, struct lookup_intent *it)
146  {
147         struct dentry * dentry = d_lookup(parent, name);
148  
149 +       if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
150 +               if (!dentry->d_op->d_revalidate_it(dentry, flags, NULL, it) &&
151 +                   !d_invalidate(dentry)) {
152 +                       dput(dentry);
153 +                       dentry = NULL;
154 +               }
155 +               return dentry;
156 +       } else
157         if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
158                 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
159                         dput(dentry);
160 @@ -281,11 +297,15 @@
161   * make sure that nobody added the entry to the dcache in the meantime..
162   * SMP-safe
163   */
164 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
165 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
166 +                                 int flags, struct lookup_intent *it)
167  {
168         struct dentry * result;
169         struct inode *dir = parent->d_inode;
170 +       int counter = 0;
171  
172 +again:
173 +       counter++;
174         down(&dir->i_sem);
175         /*
176          * First re-do the cached lookup just in case it was created
177 @@ -300,6 +320,9 @@
178                 result = ERR_PTR(-ENOMEM);
179                 if (dentry) {
180                         lock_kernel();
181 +                       if (dir->i_op->lookup_it)
182 +                               result = dir->i_op->lookup_it(dir, dentry, NULL, it, flags);
183 +                       else
184                         result = dir->i_op->lookup(dir, dentry);
185                         unlock_kernel();
186                         if (result)
187 @@ -321,6 +344,15 @@
188                         dput(result);
189                         result = ERR_PTR(-ENOENT);
190                 }
191 +       } else if (result->d_op && result->d_op->d_revalidate_it) {
192 +               if (!result->d_op->d_revalidate_it(result, flags, NULL, it) &&
193 +                   !d_invalidate(result)) {
194 +                       dput(result);
195 +                       if (counter > 10)
196 +                               result = ERR_PTR(-ESTALE);
197 +                       if (!IS_ERR(result))
198 +                               goto again;
199 +               }
200         }
201         return result;
202  }
203 @@ -332,7 +364,8 @@
204   * Without that kind of total limit, nasty chains of consecutive
205   * symlinks can cause almost arbitrarily long lookups. 
206   */
207 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
208 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
209 +                                struct lookup_intent *it)
210  {
211         int err;
212         if (current->link_count >= 8)
213 @@ -346,10 +379,12 @@
214         current->link_count++;
215         current->total_link_count++;
216         UPDATE_ATIME(dentry->d_inode);
217 +       nd->intent = it;
218         err = dentry->d_inode->i_op->follow_link(dentry, nd);
219         current->link_count--;
220         return err;
221  loop:
222 +       intent_release(it);
223         path_release(nd);
224         return -ELOOP;
225  }
226 @@ -447,7 +482,8 @@
227   *
228   * We expect 'base' to be positive and a directory.
229   */
230 -static inline int __link_path_walk(const char * name, struct nameidata *nd)
231 +static inline int __link_path_walk_it(const char * name, struct nameidata *nd,
232 +                                       struct lookup_intent *it)
233  {
234         struct dentry *dentry;
235         struct inode *inode;
236 @@ -524,12 +560,12 @@
237                                 break;
238                 }
239                 /* This does the actual lookups.. */
240 -               dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
241 +               dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
242                 if (!dentry) {
243                         err = -EWOULDBLOCKIO;
244                         if (atomic)
245                                 break;
246 -                       dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
247 +                       dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
248                         err = PTR_ERR(dentry);
249                         if (IS_ERR(dentry))
250                                 break;
251 @@ -547,7 +583,7 @@
252                         goto out_dput;
253  
254                 if (inode->i_op->follow_link) {
255 -                       err = do_follow_link(dentry, nd);
256 +                       err = do_follow_link(dentry, nd, NULL);
257                         dput(dentry);
258                         if (err)
259                                 goto return_err;
260 @@ -563,7 +599,7 @@
261                         nd->dentry = dentry;
262                 }
263                 err = -ENOTDIR; 
264 -               if (!inode->i_op->lookup)
265 +               if (!inode->i_op->lookup && !inode->i_op->lookup_it)
266                         break;
267                 continue;
268                 /* here ends the main loop */
269 @@ -590,12 +626,12 @@
270                         if (err < 0)
271                                 break;
272                 }
273 -               dentry = cached_lookup(nd->dentry, &this, 0);
274 +               dentry = cached_lookup(nd->dentry, &this, 0, it);
275                 if (!dentry) {
276                         err = -EWOULDBLOCKIO;
277                         if (atomic)
278                                 break;
279 -                       dentry = real_lookup(nd->dentry, &this, 0);
280 +                       dentry = real_lookup(nd->dentry, &this, 0, it);
281                         err = PTR_ERR(dentry);
282                         if (IS_ERR(dentry))
283                                 break;
284 @@ -605,7 +641,7 @@
285                 inode = dentry->d_inode;
286                 if ((lookup_flags & LOOKUP_FOLLOW)
287                     && inode && inode->i_op && inode->i_op->follow_link) {
288 -                       err = do_follow_link(dentry, nd);
289 +                       err = do_follow_link(dentry, nd, it);
290                         dput(dentry);
291                         if (err)
292                                 goto return_err;
293 @@ -619,7 +655,8 @@
294                         goto no_inode;
295                 if (lookup_flags & LOOKUP_DIRECTORY) {
296                         err = -ENOTDIR; 
297 -                       if (!inode->i_op || !inode->i_op->lookup)
298 +                       if (!inode->i_op ||
299 +                           (!inode->i_op->lookup && !inode->i_op->lookup_it))
300                                 break;
301                 }
302                 goto return_base;
303 @@ -643,6 +680,27 @@
304                  * Check the cached dentry for staleness.
305                  */
306                 dentry = nd->dentry;
307 +               if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
308 +                       err = -ESTALE;
309 +                       if (!dentry->d_op->d_revalidate_it(dentry, 0, NULL, it)) {
310 +                               struct dentry *new;
311 +                               err = permission(dentry->d_parent->d_inode,
312 +                                                MAY_EXEC);
313 +                               if (err)
314 +                                       break;
315 +                               new = real_lookup(dentry->d_parent,
316 +                                                 &dentry->d_name, 0, it);
317 +                               if (IS_ERR(new)) {
318 +                                       err = PTR_ERR(new);
319 +                                       break;
320 +                               }
321 +                               d_invalidate(dentry);
322 +                               dput(dentry);
323 +                               nd->dentry = new;
324 +                       }
325 +                       if (!nd->dentry->d_inode)
326 +                               goto no_inode;
327 +               } else
328                 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
329                         err = -ESTALE;
330                         if (!dentry->d_op->d_revalidate(dentry, lookup_flags & LOOKUP_PARENT)) {
331 @@ -656,6 +714,8 @@
332                 dput(dentry);
333                 break;
334         }
335 +       if (err)
336 +               intent_release(it);
337         path_release(nd);
338  return_err:
339         return err;
340 @@ -663,13 +723,13 @@
341  
342  int link_path_walk(const char * name, struct nameidata *nd)
343  {
344 -       return __link_path_walk(name,nd);
345 +       return __link_path_walk_it(name, nd, NULL);
346  }
347  
348  static inline int __path_walk(const char * name, struct nameidata *nd)
349  {
350         current->total_link_count = 0;
351 -       return __link_path_walk(name, nd);
352 +       return __link_path_walk_it(name, nd, NULL);
353  }
354  
355  int path_walk(const char * name, struct nameidata *nd)
356 @@ -677,6 +737,12 @@
357         return __path_walk(name, nd);
358  }
359  
360 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
361 +{
362 +       current->total_link_count = 0;
363 +       return __link_path_walk_it(name, nd, it);
364 +}
365 +
366  /* SMP-safe */
367  /* returns 1 if everything is done */
368  static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
369 @@ -759,6 +825,17 @@
370  }
371  
372  /* SMP-safe */
373 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
374 +                  struct lookup_intent *it)
375 +{
376 +       int error = 0;
377 +       if (path_init(path, flags, nd))
378 +               error = path_walk_it(path, nd, it);
379 +       return error;
380 +}
381 +
382 +
383 +/* SMP-safe */
384  int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
385  {
386         int error = 0;
387 @@ -773,6 +850,7 @@
388  {
389         nd->last_type = LAST_ROOT; /* if there are only slashes... */
390         nd->flags = flags;
391 +       nd->intent = NULL;
392         if (*name=='/')
393                 return walk_init_root(name,nd);
394         read_lock(&current->fs->lock);
395 @@ -787,7 +865,8 @@
396   * needs parent already locked. Doesn't follow mounts.
397   * SMP-safe.
398   */
399 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
400 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
401 +                              struct lookup_intent *it)
402  {
403         struct dentry * dentry;
404         struct inode *inode;
405 @@ -810,13 +889,16 @@
406                         goto out;
407         }
408  
409 -       dentry = cached_lookup(base, name, 0);
410 +       dentry = cached_lookup(base, name, 0, it);
411         if (!dentry) {
412                 struct dentry *new = d_alloc(base, name);
413                 dentry = ERR_PTR(-ENOMEM);
414                 if (!new)
415                         goto out;
416                 lock_kernel();
417 +               if (inode->i_op->lookup_it)
418 +                       dentry = inode->i_op->lookup_it(inode, new, NULL, it, 0);
419 +               else
420                 dentry = inode->i_op->lookup(inode, new);
421                 unlock_kernel();
422                 if (!dentry)
423 @@ -828,6 +910,12 @@
424         return dentry;
425  }
426  
427 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
428 +{
429 +       return lookup_hash_it(name, base, NULL);
430 +}
431 +
432 +
433  /* SMP-safe */
434  struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
435  {
436 @@ -849,7 +937,7 @@
437         }
438         this.hash = end_name_hash(hash);
439  
440 -       return lookup_hash(&this, base);
441 +       return lookup_hash_it(&this, base, NULL);
442  access:
443         return ERR_PTR(-EACCES);
444  }
445 @@ -880,6 +968,23 @@
446         return err;
447  }
448  
449 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
450 +                  struct lookup_intent *it)
451 +{
452 +       char *tmp;
453 +       int err;
454 +
455 +       tmp = getname(name);
456 +       err = PTR_ERR(tmp);
457 +       if (!IS_ERR(tmp)) {
458 +               err = 0;
459 +               if (path_init(tmp, flags, nd))
460 +                       err = path_walk_it(tmp, nd, it);
461 +               putname(tmp);
462 +       }
463 +       return err;
464 +}
465 +
466  /*
467   * It's inline, so penalty for filesystems that don't use sticky bit is
468   * minimal.
469 @@ -977,7 +1082,8 @@
470         return retval;
471  }
472  
473 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
474 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
475 +                        struct lookup_intent *it)
476  {
477         int error;
478  
479 @@ -990,12 +1096,15 @@
480                 goto exit_lock;
481  
482         error = -EACCES;        /* shouldn't it be ENOSYS? */
483 -       if (!dir->i_op || !dir->i_op->create)
484 +       if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
485                 goto exit_lock;
486  
487         DQUOT_INIT(dir);
488         lock_kernel();
489 -       error = dir->i_op->create(dir, dentry, mode);
490 +       if (dir->i_op->create_it)
491 +               error = dir->i_op->create_it(dir, dentry, mode, it);
492 +       else
493 +               error = dir->i_op->create(dir, dentry, mode);
494         unlock_kernel();
495  exit_lock:
496         up(&dir->i_zombie);
497 @@ -1004,6 +1113,11 @@
498         return error;
499  }
500  
501 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
502 +{
503 +       return vfs_create_it(dir, dentry, mode, NULL);
504 +}
505 +
506  /*
507   *     open_namei()
508   *
509 @@ -1018,7 +1132,8 @@
510   * for symlinks (where the permissions are checked later).
511   * SMP-safe
512   */
513 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
514 +int open_namei_it(const char *pathname, int flag, int mode,
515 +                 struct nameidata *nd, struct lookup_intent *it)
516  {
517         int acc_mode, error = 0;
518         struct inode *inode;
519 @@ -1028,11 +1143,14 @@
520  
521         acc_mode = ACC_MODE(flag);
522  
523 +       if (it)
524 +               it->it_flags = flag;
525 +
526         /*
527          * The simplest case - just a plain lookup.
528          */
529         if (!(flag & O_CREAT)) {
530 -               error = path_lookup(pathname, lookup_flags(flag), nd);
531 +               error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
532                 if (error)
533                         return error;
534                 dentry = nd->dentry;
535 @@ -1042,6 +1160,10 @@
536         /*
537          * Create - we need to know the parent.
538          */
539 +       if (it) {
540 +               it->it_create_mode = mode;
541 +               it->it_op |= IT_CREAT;
542 +       }
543         error = path_lookup(pathname, LOOKUP_PARENT, nd);
544         if (error)
545                 return error;
546 @@ -1057,7 +1179,7 @@
547  
548         dir = nd->dentry;
549         down(&dir->d_inode->i_sem);
550 -       dentry = lookup_hash(&nd->last, nd->dentry);
551 +       dentry = lookup_hash_it(&nd->last, nd->dentry, it);
552  
553  do_last:
554         error = PTR_ERR(dentry);
555 @@ -1066,11 +1188,12 @@
556                 goto exit;
557         }
558  
559 +       it->it_create_mode = mode;
560         /* Negative dentry, just create the file */
561         if (!dentry->d_inode) {
562                 if (!IS_POSIXACL(dir->d_inode))
563                         mode &= ~current->fs->umask;
564 -               error = vfs_create(dir->d_inode, dentry, mode);
565 +               error = vfs_create_it(dir->d_inode, dentry, mode, it);
566                 up(&dir->d_inode->i_sem);
567  #ifndef DENTRY_WASTE_RAM
568                 if (error)
569 @@ -1178,7 +1301,7 @@
570                 if (!error) {
571                         DQUOT_INIT(inode);
572                         
573 -                       error = do_truncate(dentry, 0);
574 +                       error = do_truncate(dentry, 0, 1);
575                 }
576                 put_write_access(inode);
577                 if (error)
578 @@ -1190,8 +1313,10 @@
579         return 0;
580  
581  exit_dput:
582 +       intent_release(it);
583         dput(dentry);
584  exit:
585 +       intent_release(it);
586         path_release(nd);
587         return error;
588  
589 @@ -1210,7 +1335,10 @@
590          * are done. Procfs-like symlinks just set LAST_BIND.
591          */
592         UPDATE_ATIME(dentry->d_inode);
593 +       nd->intent = it;
594         error = dentry->d_inode->i_op->follow_link(dentry, nd);
595 +       if (error)
596 +               intent_release(it);
597         dput(dentry);
598         if (error)
599                 return error;
600 @@ -1232,13 +1360,20 @@
601         }
602         dir = nd->dentry;
603         down(&dir->d_inode->i_sem);
604 -       dentry = lookup_hash(&nd->last, nd->dentry);
605 +       dentry = lookup_hash_it(&nd->last, nd->dentry, it);
606         putname(nd->last.name);
607         goto do_last;
608  }
609  
610 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
611 +{
612 +       return open_namei_it(pathname, flag, mode, nd, NULL);
613 +}
614 +
615 +
616  /* SMP-safe */
617 -struct dentry *lookup_create(struct nameidata *nd, int is_dir)
618 +struct dentry *lookup_create(struct nameidata *nd, int is_dir,
619 +                                   struct lookup_intent *it)
620  {
621         struct dentry *dentry;
622  
623 @@ -1246,7 +1381,7 @@
624         dentry = ERR_PTR(-EEXIST);
625         if (nd->last_type != LAST_NORM)
626                 goto fail;
627 -       dentry = lookup_hash(&nd->last, nd->dentry);
628 +       dentry = lookup_hash_it(&nd->last, nd->dentry, it);
629         if (IS_ERR(dentry))
630                 goto fail;
631         if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
632 @@ -1302,7 +1437,20 @@
633         error = path_lookup(tmp, LOOKUP_PARENT, &nd);
634         if (error)
635                 goto out;
636 -       dentry = lookup_create(&nd, 0);
637 +
638 +       if (nd.last_type != LAST_NORM) {
639 +               error = -EEXIST;
640 +               goto out2;
641 +       }
642 +       if (nd.dentry->d_inode->i_op->mknod_raw) {
643 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
644 +               error = op->mknod_raw(&nd, mode, dev);
645 +               /* the file system wants to use normal vfs path now */
646 +               if (error != -EOPNOTSUPP)
647 +                       goto out2;
648 +       }
649 +
650 +       dentry = lookup_create(&nd, 0, NULL);
651         error = PTR_ERR(dentry);
652  
653         if (!IS_POSIXACL(nd.dentry->d_inode))
654 @@ -1324,6 +1472,7 @@
655                 dput(dentry);
656         }
657         up(&nd.dentry->d_inode->i_sem);
658 +out2:
659         path_release(&nd);
660  out:
661         putname(tmp);
662 @@ -1371,7 +1520,18 @@
663                 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
664                 if (error)
665                         goto out;
666 -               dentry = lookup_create(&nd, 1);
667 +               if (nd.last_type != LAST_NORM) {
668 +                       error = -EEXIST;
669 +                       goto out2;
670 +               }
671 +               if (nd.dentry->d_inode->i_op->mkdir_raw) {
672 +                       struct inode_operations *op = nd.dentry->d_inode->i_op;
673 +                       error = op->mkdir_raw(&nd, mode);
674 +                       /* the file system wants to use normal vfs path now */
675 +                       if (error != -EOPNOTSUPP)
676 +                               goto out2;
677 +               }
678 +               dentry = lookup_create(&nd, 1, NULL);
679                 error = PTR_ERR(dentry);
680                 if (!IS_ERR(dentry)) {
681                         if (!IS_POSIXACL(nd.dentry->d_inode))
682 @@ -1380,6 +1540,7 @@
683                         dput(dentry);
684                 }
685                 up(&nd.dentry->d_inode->i_sem);
686 +out2:
687                 path_release(&nd);
688  out:
689                 putname(tmp);
690 @@ -1480,8 +1641,16 @@
691                         error = -EBUSY;
692                         goto exit1;
693         }
694 +       if (nd.dentry->d_inode->i_op->rmdir_raw) {
695 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
696 +
697 +               error = op->rmdir_raw(&nd);
698 +               /* the file system wants to use normal vfs path now */
699 +               if (error != -EOPNOTSUPP)
700 +                       goto exit1;
701 +       }
702         down(&nd.dentry->d_inode->i_sem);
703 -       dentry = lookup_hash(&nd.last, nd.dentry);
704 +       dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
705         error = PTR_ERR(dentry);
706         if (!IS_ERR(dentry)) {
707                 error = vfs_rmdir(nd.dentry->d_inode, dentry);
708 @@ -1539,8 +1708,15 @@
709         error = -EISDIR;
710         if (nd.last_type != LAST_NORM)
711                 goto exit1;
712 +       if (nd.dentry->d_inode->i_op->unlink_raw) {
713 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
714 +               error = op->unlink_raw(&nd);
715 +               /* the file system wants to use normal vfs path now */
716 +               if (error != -EOPNOTSUPP)
717 +                       goto exit1;
718 +       }
719         down(&nd.dentry->d_inode->i_sem);
720 -       dentry = lookup_hash(&nd.last, nd.dentry);
721 +       dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
722         error = PTR_ERR(dentry);
723         if (!IS_ERR(dentry)) {
724                 /* Why not before? Because we want correct error value */
725 @@ -1607,15 +1783,27 @@
726                 error = path_lookup(to, LOOKUP_PARENT, &nd);
727                 if (error)
728                         goto out;
729 -               dentry = lookup_create(&nd, 0);
730 +               if (nd.last_type != LAST_NORM) {
731 +                       error = -EEXIST;
732 +                       goto out2;
733 +               }
734 +               if (nd.dentry->d_inode->i_op->symlink_raw) {
735 +                       struct inode_operations *op = nd.dentry->d_inode->i_op;
736 +                       error = op->symlink_raw(&nd, from);
737 +                       /* the file system wants to use normal vfs path now */
738 +                       if (error != -EOPNOTSUPP)
739 +                               goto out2;
740 +               }
741 +               dentry = lookup_create(&nd, 0, NULL);
742                 error = PTR_ERR(dentry);
743                 if (!IS_ERR(dentry)) {
744                         error = vfs_symlink(nd.dentry->d_inode, dentry, from);
745                         dput(dentry);
746                 }
747                 up(&nd.dentry->d_inode->i_sem);
748 +       out2:
749                 path_release(&nd);
750 -out:
751 +       out:
752                 putname(to);
753         }
754         putname(from);
755 @@ -1691,7 +1879,18 @@
756                 error = -EXDEV;
757                 if (old_nd.mnt != nd.mnt)
758                         goto out_release;
759 -               new_dentry = lookup_create(&nd, 0);
760 +               if (nd.last_type != LAST_NORM) {
761 +                       error = -EEXIST;
762 +                       goto out_release;
763 +               }
764 +               if (nd.dentry->d_inode->i_op->link_raw) {
765 +                       struct inode_operations *op = nd.dentry->d_inode->i_op;
766 +                       error = op->link_raw(&old_nd, &nd);
767 +                       /* the file system wants to use normal vfs path now */
768 +                       if (error != -EOPNOTSUPP)
769 +                               goto out_release;
770 +               }
771 +               new_dentry = lookup_create(&nd, 0, NULL);
772                 error = PTR_ERR(new_dentry);
773                 if (!IS_ERR(new_dentry)) {
774                         error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
775 @@ -1735,7 +1934,7 @@
776   *        locking].
777   */
778  int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
779 -              struct inode *new_dir, struct dentry *new_dentry)
780 +                  struct inode *new_dir, struct dentry *new_dentry)
781  {
782         int error;
783         struct inode *target;
784 @@ -1814,7 +2013,7 @@
785  }
786  
787  int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
788 -              struct inode *new_dir, struct dentry *new_dentry)
789 +                    struct inode *new_dir, struct dentry *new_dentry)
790  {
791         int error;
792  
793 @@ -1902,9 +2101,18 @@
794         if (newnd.last_type != LAST_NORM)
795                 goto exit2;
796  
797 +       if (old_dir->d_inode->i_op->rename_raw) {
798 +               lock_kernel();
799 +               error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
800 +               unlock_kernel();
801 +               /* the file system wants to use normal vfs path now */
802 +               if (error != -EOPNOTSUPP)
803 +                       goto exit2;
804 +       }
805 +
806         double_lock(new_dir, old_dir);
807  
808 -       old_dentry = lookup_hash(&oldnd.last, old_dir);
809 +       old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
810         error = PTR_ERR(old_dentry);
811         if (IS_ERR(old_dentry))
812                 goto exit3;
813 @@ -1920,16 +2128,16 @@
814                 if (newnd.last.name[newnd.last.len])
815                         goto exit4;
816         }
817 -       new_dentry = lookup_hash(&newnd.last, new_dir);
818 +       new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
819         error = PTR_ERR(new_dentry);
820         if (IS_ERR(new_dentry))
821                 goto exit4;
822  
823 +
824         lock_kernel();
825         error = vfs_rename(old_dir->d_inode, old_dentry,
826                                    new_dir->d_inode, new_dentry);
827         unlock_kernel();
828 -
829         dput(new_dentry);
830  exit4:
831         dput(old_dentry);
832 @@ -1980,20 +2188,26 @@
833  }
834  
835  static inline int
836 -__vfs_follow_link(struct nameidata *nd, const char *link)
837 +__vfs_follow_link(struct nameidata *nd, const char *link,
838 +                 struct lookup_intent *it)
839  {
840         int res = 0;
841         char *name;
842         if (IS_ERR(link))
843                 goto fail;
844  
845 +       if (it == NULL)
846 +               it = nd->intent;
847 +       else if (it != nd->intent)
848 +               printk("it != nd->intent: tell phil@clusterfs.com\n");
849 +
850         if (*link == '/') {
851                 path_release(nd);
852                 if (!walk_init_root(link, nd))
853                         /* weird __emul_prefix() stuff did it */
854                         goto out;
855         }
856 -       res = __link_path_walk(link, nd);
857 +       res = __link_path_walk_it(link, nd, it);
858  out:
859         if (current->link_count || res || nd->last_type!=LAST_NORM)
860                 return res;
861 @@ -2017,7 +2231,13 @@
862  
863  int vfs_follow_link(struct nameidata *nd, const char *link)
864  {
865 -       return __vfs_follow_link(nd, link);
866 +       return __vfs_follow_link(nd, link, NULL);
867 +}
868 +
869 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
870 +                      struct lookup_intent *it)
871 +{
872 +       return __vfs_follow_link(nd, link, it);
873  }
874  
875  /* get the link contents into pagecache */
876 @@ -2059,7 +2279,7 @@
877  {
878         struct page *page = NULL;
879         char *s = page_getlink(dentry, &page);
880 -       int res = __vfs_follow_link(nd, s);
881 +       int res = __vfs_follow_link(nd, s, NULL);
882         if (page) {
883                 kunmap(page);
884                 page_cache_release(page);
885 Index: kernel-2.4.212lgns/fs/namespace.c
886 ===================================================================
887 --- kernel-2.4.212lgns.orig/fs/namespace.c      2003-10-28 10:34:12.000000000 -0800
888 +++ kernel-2.4.212lgns/fs/namespace.c   2004-05-11 06:41:10.000000000 -0700
889 @@ -98,6 +98,7 @@
890  {
891         old_nd->dentry = mnt->mnt_mountpoint;
892         old_nd->mnt = mnt->mnt_parent;
893 +       UNPIN(old_nd->dentry, old_nd->mnt, 1);
894         mnt->mnt_parent = mnt;
895         mnt->mnt_mountpoint = mnt->mnt_root;
896         list_del_init(&mnt->mnt_child);
897 @@ -109,6 +110,7 @@
898  {
899         mnt->mnt_parent = mntget(nd->mnt);
900         mnt->mnt_mountpoint = dget(nd->dentry);
901 +       PIN(nd->dentry, nd->mnt, 1);
902         list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
903         list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
904         nd->dentry->d_mounted++;
905 @@ -286,7 +288,7 @@
906         }
907  }
908  
909 -static int do_umount(struct vfsmount *mnt, int flags)
910 +int do_umount(struct vfsmount *mnt, int flags)
911  {
912         struct super_block * sb = mnt->mnt_sb;
913         int retval = 0;
914 @@ -488,14 +490,17 @@
915  {
916         struct nameidata old_nd;
917         struct vfsmount *mnt = NULL;
918 +       struct lookup_intent it = { .it_op = IT_GETATTR };
919         int err = mount_is_safe(nd);
920         if (err)
921                 return err;
922         if (!old_name || !*old_name)
923                 return -EINVAL;
924 -       err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
925 -       if (err)
926 +       err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
927 +       if (err) {
928 +               intent_release(&it);
929                 return err;
930 +       }
931  
932         down_write(&current->namespace->sem);
933         err = -EINVAL;
934 @@ -518,6 +523,7 @@
935         }
936  
937         up_write(&current->namespace->sem);
938 +       intent_release(&it);
939         path_release(&old_nd);
940         return err;
941  }
942 @@ -701,6 +707,7 @@
943                   unsigned long flags, void *data_page)
944  {
945         struct nameidata nd;
946 +       struct lookup_intent it = { .it_op = IT_GETATTR };
947         int retval = 0;
948         int mnt_flags = 0;
949  
950 @@ -725,9 +732,11 @@
951         flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
952  
953         /* ... and get the mountpoint */
954 -       retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
955 -       if (retval)
956 +       retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
957 +       if (retval) {
958 +               intent_release(&it);
959                 return retval;
960 +       }
961  
962         if (flags & MS_REMOUNT)
963                 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
964 @@ -739,6 +748,8 @@
965         else
966                 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
967                                       dev_name, data_page);
968 +
969 +       intent_release(&it);
970         path_release(&nd);
971         return retval;
972  }
973 @@ -904,6 +915,8 @@
974  {
975         struct vfsmount *tmp;
976         struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
977 +       struct lookup_intent new_it = { .it_op = IT_GETATTR };
978 +       struct lookup_intent old_it = { .it_op = IT_GETATTR };
979         int error;
980  
981         if (!capable(CAP_SYS_ADMIN))
982 @@ -911,14 +924,14 @@
983  
984         lock_kernel();
985  
986 -       error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
987 +       error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
988         if (error)
989                 goto out0;
990         error = -EINVAL;
991         if (!check_mnt(new_nd.mnt))
992                 goto out1;
993  
994 -       error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
995 +       error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
996         if (error)
997                 goto out1;
998  
999 @@ -973,8 +986,10 @@
1000         up(&old_nd.dentry->d_inode->i_zombie);
1001         up_write(&current->namespace->sem);
1002         path_release(&user_nd);
1003 +       intent_release(&old_it);
1004         path_release(&old_nd);
1005  out1:
1006 +       intent_release(&new_it);
1007         path_release(&new_nd);
1008  out0:
1009         unlock_kernel();
1010 Index: kernel-2.4.212lgns/fs/open.c
1011 ===================================================================
1012 --- kernel-2.4.212lgns.orig/fs/open.c   2003-10-28 10:33:59.000000000 -0800
1013 +++ kernel-2.4.212lgns/fs/open.c        2004-05-11 06:41:10.000000000 -0700
1014 @@ -19,6 +19,8 @@
1015  #include <asm/uaccess.h>
1016  
1017  #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1018 +extern int path_walk_it(const char *name, struct nameidata *nd,
1019 +                       struct lookup_intent *it);
1020  
1021  int vfs_statfs(struct super_block *sb, struct statfs *buf)
1022  {
1023 @@ -95,9 +97,10 @@
1024         write_unlock(&files->file_lock);
1025  }
1026  
1027 -int do_truncate(struct dentry *dentry, loff_t length)
1028 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1029  {
1030         struct inode *inode = dentry->d_inode;
1031 +       struct inode_operations *op = dentry->d_inode->i_op;
1032         int error;
1033         struct iattr newattrs;
1034  
1035 @@ -109,7 +112,13 @@
1036         down(&inode->i_sem);
1037         newattrs.ia_size = length;
1038         newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1039 -       error = notify_change(dentry, &newattrs);
1040 +       if (called_from_open)
1041 +               newattrs.ia_valid |= ATTR_FROM_OPEN;
1042 +       if (op->setattr_raw) {
1043 +               newattrs.ia_valid |= ATTR_RAW;
1044 +               error = op->setattr_raw(inode, &newattrs);
1045 +       } else
1046 +               error = notify_change(dentry, &newattrs);
1047         up(&inode->i_sem);
1048         up_write(&inode->i_alloc_sem);
1049         return error;
1050 @@ -120,12 +129,13 @@
1051         struct nameidata nd;
1052         struct inode * inode;
1053         int error;
1054 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1055  
1056         error = -EINVAL;
1057         if (length < 0) /* sorry, but loff_t says... */
1058                 goto out;
1059  
1060 -       error = user_path_walk(path, &nd);
1061 +       error = user_path_walk_it(path, &nd, &it);
1062         if (error)
1063                 goto out;
1064         inode = nd.dentry->d_inode;
1065 @@ -165,11 +175,13 @@
1066         error = locks_verify_truncate(inode, NULL, length);
1067         if (!error) {
1068                 DQUOT_INIT(inode);
1069 -               error = do_truncate(nd.dentry, length);
1070 +               intent_release(&it);
1071 +               error = do_truncate(nd.dentry, length, 0);
1072         }
1073         put_write_access(inode);
1074  
1075  dput_and_out:
1076 +       intent_release(&it);
1077         path_release(&nd);
1078  out:
1079         return error;
1080 @@ -217,7 +229,7 @@
1081  
1082         error = locks_verify_truncate(inode, file, length);
1083         if (!error)
1084 -               error = do_truncate(dentry, length);
1085 +               error = do_truncate(dentry, length, 0);
1086  out_putf:
1087         fput(file);
1088  out:
1089 @@ -262,11 +274,13 @@
1090         struct inode * inode;
1091         struct iattr newattrs;
1092  
1093 -       error = user_path_walk(filename, &nd);
1094 +       error = user_path_walk_it(filename, &nd, NULL);
1095         if (error)
1096                 goto out;
1097         inode = nd.dentry->d_inode;
1098  
1099 +       /* this is safe without a Lustre lock because it only depends
1100 +          on the super block */
1101         error = -EROFS;
1102         if (IS_RDONLY(inode))
1103                 goto dput_and_out;
1104 @@ -281,11 +295,25 @@
1105                         goto dput_and_out;
1106  
1107                 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1108 -       } else {
1109 +       }
1110 +
1111 +       if (inode->i_op->setattr_raw) {
1112 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
1113 +
1114 +               newattrs.ia_valid |= ATTR_RAW;
1115 +               error = op->setattr_raw(inode, &newattrs);
1116 +               /* the file system wants to use normal vfs path now */
1117 +               if (error != -EOPNOTSUPP)
1118 +                       goto dput_and_out;
1119 +       }
1120 +
1121 +       error = -EPERM;
1122 +       if (!times) {
1123                 if (current->fsuid != inode->i_uid &&
1124                     (error = permission(inode,MAY_WRITE)) != 0)
1125                         goto dput_and_out;
1126         }
1127 +
1128         error = notify_change(nd.dentry, &newattrs);
1129  dput_and_out:
1130         path_release(&nd);
1131 @@ -306,12 +334,14 @@
1132         struct inode * inode;
1133         struct iattr newattrs;
1134  
1135 -       error = user_path_walk(filename, &nd);
1136 +       error = user_path_walk_it(filename, &nd, NULL);
1137  
1138         if (error)
1139                 goto out;
1140         inode = nd.dentry->d_inode;
1141  
1142 +       /* this is safe without a Lustre lock because it only depends
1143 +          on the super block */
1144         error = -EROFS;
1145         if (IS_RDONLY(inode))
1146                 goto dput_and_out;
1147 @@ -326,7 +356,20 @@
1148                 newattrs.ia_atime = times[0].tv_sec;
1149                 newattrs.ia_mtime = times[1].tv_sec;
1150                 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1151 -       } else {
1152 +       }
1153 +
1154 +       if (inode->i_op->setattr_raw) {
1155 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
1156 +
1157 +               newattrs.ia_valid |= ATTR_RAW;
1158 +               error = op->setattr_raw(inode, &newattrs);
1159 +               /* the file system wants to use normal vfs path now */
1160 +               if (error != -EOPNOTSUPP)
1161 +                       goto dput_and_out;
1162 +       }
1163 +
1164 +       error = -EPERM;
1165 +       if (!utimes) {
1166                 if (current->fsuid != inode->i_uid &&
1167                     (error = permission(inode,MAY_WRITE)) != 0)
1168                         goto dput_and_out;
1169 @@ -349,6 +392,7 @@
1170         int old_fsuid, old_fsgid;
1171         kernel_cap_t old_cap;
1172         int res;
1173 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1174  
1175         if (mode & ~S_IRWXO)    /* where's F_OK, X_OK, W_OK, R_OK? */
1176                 return -EINVAL;
1177 @@ -366,13 +410,14 @@
1178         else
1179                 current->cap_effective = current->cap_permitted;
1180  
1181 -       res = user_path_walk(filename, &nd);
1182 +       res = user_path_walk_it(filename, &nd, &it);
1183         if (!res) {
1184                 res = permission(nd.dentry->d_inode, mode);
1185                 /* SuS v2 requires we report a read only fs too */
1186                 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1187                    && !special_file(nd.dentry->d_inode->i_mode))
1188                         res = -EROFS;
1189 +               intent_release(&it);
1190                 path_release(&nd);
1191         }
1192  
1193 @@ -387,8 +432,9 @@
1194  {
1195         int error;
1196         struct nameidata nd;
1197 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1198  
1199 -       error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1200 +       error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1201         if (error)
1202                 goto out;
1203  
1204 @@ -399,6 +445,7 @@
1205         set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1206  
1207  dput_and_out:
1208 +       intent_release(&it);
1209         path_release(&nd);
1210  out:
1211         return error;
1212 @@ -438,9 +485,10 @@
1213  {
1214         int error;
1215         struct nameidata nd;
1216 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1217  
1218 -       error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1219 -                     LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1220 +       error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1221 +                              LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1222         if (error)
1223                 goto out;
1224  
1225 @@ -456,39 +504,56 @@
1226         set_fs_altroot();
1227         error = 0;
1228  dput_and_out:
1229 +       intent_release(&it);
1230         path_release(&nd);
1231  out:
1232         return error;
1233  }
1234  
1235 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1236 +int chmod_common(struct dentry *dentry, mode_t mode)
1237  {
1238 -       struct inode * inode;
1239 -       struct dentry * dentry;
1240 -       struct file * file;
1241 -       int err = -EBADF;
1242 +       struct inode *inode = dentry->d_inode;
1243         struct iattr newattrs;
1244 +       int err = -EROFS;
1245  
1246 -       file = fget(fd);
1247 -       if (!file)
1248 +       if (IS_RDONLY(inode))
1249                 goto out;
1250  
1251 -       dentry = file->f_dentry;
1252 -       inode = dentry->d_inode;
1253 +       if (inode->i_op->setattr_raw) {
1254 +               newattrs.ia_mode = mode;
1255 +               newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1256 +               newattrs.ia_valid |= ATTR_RAW;
1257 +               err = inode->i_op->setattr_raw(inode, &newattrs);
1258 +               /* the file system wants to use normal vfs path now */
1259 +               if (err != -EOPNOTSUPP)
1260 +                       goto out;
1261 +       }
1262  
1263 -       err = -EROFS;
1264 -       if (IS_RDONLY(inode))
1265 -               goto out_putf;
1266         err = -EPERM;
1267         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1268 -               goto out_putf;
1269 +               goto out;
1270 +
1271         if (mode == (mode_t) -1)
1272                 mode = inode->i_mode;
1273         newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1274         newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1275         err = notify_change(dentry, &newattrs);
1276  
1277 -out_putf:
1278 +out:
1279 +       return err;
1280 +}
1281 +
1282 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1283 +{
1284 +       struct file * file;
1285 +       int err = -EBADF;
1286 +
1287 +       file = fget(fd);
1288 +       if (!file)
1289 +               goto out;
1290 +
1291 +       err = chmod_common(file->f_dentry, mode);
1292 +
1293         fput(file);
1294  out:
1295         return err;
1296 @@ -497,30 +562,14 @@
1297  asmlinkage long sys_chmod(const char * filename, mode_t mode)
1298  {
1299         struct nameidata nd;
1300 -       struct inode * inode;
1301         int error;
1302 -       struct iattr newattrs;
1303  
1304         error = user_path_walk(filename, &nd);
1305         if (error)
1306                 goto out;
1307 -       inode = nd.dentry->d_inode;
1308 -
1309 -       error = -EROFS;
1310 -       if (IS_RDONLY(inode))
1311 -               goto dput_and_out;
1312  
1313 -       error = -EPERM;
1314 -       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1315 -               goto dput_and_out;
1316 +       error = chmod_common(nd.dentry, mode);
1317  
1318 -       if (mode == (mode_t) -1)
1319 -               mode = inode->i_mode;
1320 -       newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1321 -       newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1322 -       error = notify_change(nd.dentry, &newattrs);
1323 -
1324 -dput_and_out:
1325         path_release(&nd);
1326  out:
1327         return error;
1328 @@ -540,6 +589,20 @@
1329         error = -EROFS;
1330         if (IS_RDONLY(inode))
1331                 goto out;
1332 +
1333 +       if (inode->i_op->setattr_raw) {
1334 +               struct inode_operations *op = dentry->d_inode->i_op;
1335 +
1336 +               newattrs.ia_uid = user;
1337 +               newattrs.ia_gid = group;
1338 +               newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1339 +               newattrs.ia_valid |= ATTR_RAW;
1340 +               error = op->setattr_raw(inode, &newattrs);
1341 +               /* the file system wants to use normal vfs path now */
1342 +               if (error != -EOPNOTSUPP)
1343 +                       return error;
1344 +       }
1345 +
1346         error = -EPERM;
1347         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1348                 goto out;
1349 @@ -644,6 +707,7 @@
1350  {
1351         int namei_flags, error;
1352         struct nameidata nd;
1353 +       struct lookup_intent it = { .it_op = IT_OPEN };
1354  
1355         namei_flags = flags;
1356         if ((namei_flags+1) & O_ACCMODE)
1357 @@ -651,14 +715,15 @@
1358         if (namei_flags & O_TRUNC)
1359                 namei_flags |= 2;
1360  
1361 -       error = open_namei(filename, namei_flags, mode, &nd);
1362 -       if (!error)
1363 -               return dentry_open(nd.dentry, nd.mnt, flags);
1364 +       error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1365 +       if (error)
1366 +               return ERR_PTR(error);
1367  
1368 -       return ERR_PTR(error);
1369 +       return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1370  }
1371  
1372 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1373 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1374 +                           int flags, struct lookup_intent *it)
1375  {
1376         struct file * f;
1377         struct inode *inode;
1378 @@ -686,7 +751,9 @@
1379         file_move(f, &inode->i_sb->s_files);
1380  
1381         if (f->f_op && f->f_op->open) {
1382 +               f->f_it = it;
1383                 error = f->f_op->open(inode,f);
1384 +               f->f_it = NULL;
1385                 if (error)
1386                         goto cleanup_all;
1387         }
1388 @@ -698,6 +765,7 @@
1389                                       !inode->i_mapping->a_ops->direct_IO))
1390                 goto cleanup_all;
1391  
1392 +       intent_release(it);
1393         return f;
1394  
1395  cleanup_all:
1396 @@ -710,11 +778,17 @@
1397  cleanup_file:
1398         put_filp(f);
1399  cleanup_dentry:
1400 +       intent_release(it);
1401         dput(dentry);
1402         mntput(mnt);
1403         return ERR_PTR(error);
1404  }
1405  
1406 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1407 +{
1408 +       return dentry_open_it(dentry, mnt, flags, NULL);
1409 +}
1410 +
1411  /*
1412   * Find an empty file descriptor entry, and mark it busy.
1413   */
1414 Index: kernel-2.4.212lgns/fs/stat.c
1415 ===================================================================
1416 --- kernel-2.4.212lgns.orig/fs/stat.c   2003-10-28 10:33:58.000000000 -0800
1417 +++ kernel-2.4.212lgns/fs/stat.c        2004-05-11 06:41:10.000000000 -0700
1418 @@ -17,10 +17,12 @@
1419   * Revalidate the inode. This is required for proper NFS attribute caching.
1420   */
1421  static __inline__ int
1422 -do_revalidate(struct dentry *dentry)
1423 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1424  {
1425         struct inode * inode = dentry->d_inode;
1426 -       if (inode->i_op && inode->i_op->revalidate)
1427 +       if (inode->i_op && inode->i_op->revalidate_it)
1428 +               return inode->i_op->revalidate_it(dentry, it);
1429 +       else if (inode->i_op && inode->i_op->revalidate)
1430                 return inode->i_op->revalidate(dentry);
1431         return 0;
1432  }
1433 @@ -141,13 +143,15 @@
1434  asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1435  {
1436         struct nameidata nd;
1437 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1438         int error;
1439  
1440 -       error = user_path_walk(filename, &nd);
1441 +       error = user_path_walk_it(filename, &nd, &it);
1442         if (!error) {
1443 -               error = do_revalidate(nd.dentry);
1444 +               error = do_revalidate(nd.dentry, &it);
1445                 if (!error)
1446                         error = cp_old_stat(nd.dentry->d_inode, statbuf);
1447 +               intent_release(&it);
1448                 path_release(&nd);
1449         }
1450         return error;
1451 @@ -157,13 +161,15 @@
1452  asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1453  {
1454         struct nameidata nd;
1455 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1456         int error;
1457  
1458 -       error = user_path_walk(filename, &nd);
1459 +       error = user_path_walk_it(filename, &nd, &it);
1460         if (!error) {
1461 -               error = do_revalidate(nd.dentry);
1462 +               error = do_revalidate(nd.dentry, &it);
1463                 if (!error)
1464                         error = cp_new_stat(nd.dentry->d_inode, statbuf);
1465 +               intent_release(&it);
1466                 path_release(&nd);
1467         }
1468         return error;
1469 @@ -178,13 +184,15 @@
1470  asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1471  {
1472         struct nameidata nd;
1473 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1474         int error;
1475  
1476 -       error = user_path_walk_link(filename, &nd);
1477 +       error = user_path_walk_link_it(filename, &nd, &it);
1478         if (!error) {
1479 -               error = do_revalidate(nd.dentry);
1480 +               error = do_revalidate(nd.dentry, &it);
1481                 if (!error)
1482                         error = cp_old_stat(nd.dentry->d_inode, statbuf);
1483 +               intent_release(&it);
1484                 path_release(&nd);
1485         }
1486         return error;
1487 @@ -195,13 +203,15 @@
1488  asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1489  {
1490         struct nameidata nd;
1491 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1492         int error;
1493  
1494 -       error = user_path_walk_link(filename, &nd);
1495 +       error = user_path_walk_link_it(filename, &nd, &it);
1496         if (!error) {
1497 -               error = do_revalidate(nd.dentry);
1498 +               error = do_revalidate(nd.dentry, &it);
1499                 if (!error)
1500                         error = cp_new_stat(nd.dentry->d_inode, statbuf);
1501 +               intent_release(&it);
1502                 path_release(&nd);
1503         }
1504         return error;
1505 @@ -222,7 +232,7 @@
1506         if (f) {
1507                 struct dentry * dentry = f->f_dentry;
1508  
1509 -               err = do_revalidate(dentry);
1510 +               err = do_revalidate(dentry, NULL);
1511                 if (!err)
1512                         err = cp_old_stat(dentry->d_inode, statbuf);
1513                 fput(f);
1514 @@ -241,7 +251,7 @@
1515         if (f) {
1516                 struct dentry * dentry = f->f_dentry;
1517  
1518 -               err = do_revalidate(dentry);
1519 +               err = do_revalidate(dentry, NULL);
1520                 if (!err)
1521                         err = cp_new_stat(dentry->d_inode, statbuf);
1522                 fput(f);
1523 @@ -263,7 +273,7 @@
1524  
1525                 error = -EINVAL;
1526                 if (inode->i_op && inode->i_op->readlink &&
1527 -                   !(error = do_revalidate(nd.dentry))) {
1528 +                   !(error = do_revalidate(nd.dentry, NULL))) {
1529                         UPDATE_ATIME(inode);
1530                         error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1531                 }
1532 @@ -339,12 +349,14 @@
1533  {
1534         struct nameidata nd;
1535         int error;
1536 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1537  
1538 -       error = user_path_walk(filename, &nd);
1539 +       error = user_path_walk_it(filename, &nd, &it);
1540         if (!error) {
1541 -               error = do_revalidate(nd.dentry);
1542 +               error = do_revalidate(nd.dentry, &it);
1543                 if (!error)
1544                         error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1545 +               intent_release(&it);
1546                 path_release(&nd);
1547         }
1548         return error;
1549 @@ -354,12 +366,14 @@
1550  {
1551         struct nameidata nd;
1552         int error;
1553 +       struct lookup_intent it = { .it_op = IT_GETATTR };
1554  
1555 -       error = user_path_walk_link(filename, &nd);
1556 +       error = user_path_walk_link_it(filename, &nd, &it);
1557         if (!error) {
1558 -               error = do_revalidate(nd.dentry);
1559 +               error = do_revalidate(nd.dentry, &it);
1560                 if (!error)
1561                         error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1562 +               intent_release(&it);
1563                 path_release(&nd);
1564         }
1565         return error;
1566 @@ -374,7 +388,7 @@
1567         if (f) {
1568                 struct dentry * dentry = f->f_dentry;
1569  
1570 -               err = do_revalidate(dentry);
1571 +               err = do_revalidate(dentry, NULL);
1572                 if (!err)
1573                         err = cp_new_stat64(dentry->d_inode, statbuf);
1574                 fput(f);
1575 Index: kernel-2.4.212lgns/include/linux/dcache.h
1576 ===================================================================
1577 --- kernel-2.4.212lgns.orig/include/linux/dcache.h      2003-11-10 16:44:28.000000000 -0800
1578 +++ kernel-2.4.212lgns/include/linux/dcache.h   2004-05-11 06:41:10.000000000 -0700
1579 @@ -7,6 +7,52 @@
1580  #include <linux/gdb.h>
1581  #include <linux/mount.h>
1582  #include <linux/kernel.h>
1583 +#include <linux/string.h>
1584 +
1585 +#define IT_OPEN     0x0001
1586 +#define IT_CREAT    0x0002
1587 +#define IT_READDIR  0x0004
1588 +#define IT_GETATTR  0x0008
1589 +#define IT_LOOKUP   0x0010
1590 +#define IT_UNLINK   0x0020
1591 +#define IT_GETXATTR 0x0040
1592 +#define IT_EXEC     0x0080
1593 +#define IT_PIN      0x0100
1594 +#define IT_CHDIR    0x0200
1595 +
1596 +#define IT_FL_LOCKED   0x0001
1597 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1598 +
1599 +#define INTENT_MAGIC 0x19620323
1600 +
1601 +
1602 +struct lustre_intent_data {
1603 +       int       it_disposition;
1604 +       int       it_status;
1605 +       __u64     it_lock_handle;
1606 +       void     *it_data;
1607 +       int       it_lock_mode;
1608 +       int it_int_flags;
1609 +};
1610 +struct lookup_intent {
1611 +       int     it_magic;
1612 +       void    (*it_op_release)(struct lookup_intent *);
1613 +       int     it_op;
1614 +       int     it_flags;
1615 +       int     it_create_mode;
1616 +       union {
1617 +               struct lustre_intent_data lustre;
1618 +       } d;
1619 +};
1620 +
1621 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1622 +{
1623 +       memset(it, 0, sizeof(*it));
1624 +       it->it_magic = INTENT_MAGIC;
1625 +       it->it_op = op;
1626 +       it->it_flags = flags;
1627 +}
1628 +
1629  
1630  /*
1631   * linux/include/linux/dcache.h
1632 @@ -87,6 +133,8 @@
1633         unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */
1634  };
1635  
1636 +struct nameidata;
1637 +
1638  struct dentry_operations {
1639         int (*d_revalidate)(struct dentry *, int);
1640         int (*d_hash) (struct dentry *, struct qstr *);
1641 @@ -94,8 +142,22 @@
1642         int (*d_delete)(struct dentry *);
1643         void (*d_release)(struct dentry *);
1644         void (*d_iput)(struct dentry *, struct inode *);
1645 +       int (*d_revalidate_it)(struct dentry *, int, struct nameidata *, struct lookup_intent *);
1646 +       void (*d_pin)(struct dentry *, struct vfsmount * , int);
1647 +       void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1648  };
1649  
1650 +#define PIN(de,mnt,flag)  if (de && de->d_op && de->d_op->d_pin) \
1651 +                               de->d_op->d_pin(de, mnt, flag);
1652 +#define UNPIN(de,mnt,flag)  if (de && de->d_op && de->d_op->d_unpin) \
1653 +                               de->d_op->d_unpin(de, mnt, flag);
1654 +
1655 +
1656 +/* defined in fs/namei.c */
1657 +extern void intent_release(struct lookup_intent *it);
1658 +/* defined in fs/dcache.c */
1659 +extern void __d_rehash(struct dentry * entry, int lock);
1660 +
1661  /* the dentry parameter passed to d_hash and d_compare is the parent
1662   * directory of the entries to be compared. It is used in case these
1663   * functions need any directory specific information for determining
1664 @@ -127,6 +189,7 @@
1665                                          * s_nfsd_free_path semaphore will be down
1666                                          */
1667  #define DCACHE_REFERENCED      0x0008  /* Recently used, don't discard. */
1668 +#define DCACHE_LUSTRE_INVALID  0x0010  /* Lustre invalidated */
1669  
1670  extern spinlock_t dcache_lock;
1671  
1672 Index: kernel-2.4.212lgns/include/linux/fs.h
1673 ===================================================================
1674 --- kernel-2.4.212lgns.orig/include/linux/fs.h  2004-05-11 06:37:51.000000000 -0700
1675 +++ kernel-2.4.212lgns/include/linux/fs.h       2004-05-11 06:48:41.000000000 -0700
1676 @@ -74,6 +74,7 @@
1677  
1678  #define FMODE_READ 1
1679  #define FMODE_WRITE 2
1680 +#define FMODE_EXEC 4
1681  
1682  #define READ 0
1683  #define WRITE 1
1684 @@ -361,6 +362,9 @@
1685  #define ATTR_MTIME_SET 256
1686  #define ATTR_FORCE     512     /* Not a change, but a change it */
1687  #define ATTR_ATTR_FLAG 1024
1688 +#define ATTR_RAW       0x0800  /* file system, not vfs will massage attrs */
1689 +#define ATTR_FROM_OPEN 0x1000  /* called from open path, ie O_TRUNC */
1690 +#define ATTR_CTIME_SET 0x2000
1691  
1692  /*
1693   * This is the Inode Attributes structure, used for notify_change().  It
1694 @@ -505,6 +509,7 @@
1695         struct pipe_inode_info  *i_pipe;
1696         struct block_device     *i_bdev;
1697         struct char_device      *i_cdev;
1698 +       void                    *i_filterdata;
1699  
1700         unsigned long           i_dnotify_mask; /* Directory notify events */
1701         struct dnotify_struct   *i_dnotify; /* for directory notifications */
1702 @@ -667,6 +672,7 @@
1703  
1704         /* needed for tty driver, and maybe others */
1705         void                    *private_data;
1706 +       struct lookup_intent    *f_it;
1707         struct list_head        f_ep_links;
1708         spinlock_t              f_ep_lock;
1709  };
1710 @@ -796,6 +802,7 @@
1711         struct qstr last;
1712         unsigned int flags;
1713         int last_type;
1714 +       struct lookup_intent *intent;
1715  };
1716  
1717  /*
1718 @@ -917,7 +924,8 @@
1719  extern int __vfs_rmdir(struct inode *, struct dentry *);
1720  extern int vfs_rmdir(struct inode *, struct dentry *);
1721  extern int vfs_unlink(struct inode *, struct dentry *);
1722 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1723 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1724 +              struct inode *new_dir, struct dentry *new_dentry);
1725  
1726  /*
1727   * File types
1728 @@ -992,21 +1000,32 @@
1729  
1730  struct inode_operations {
1731         int (*create) (struct inode *,struct dentry *,int);
1732 +       int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1733         struct dentry * (*lookup) (struct inode *,struct dentry *);
1734 +       struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct nameidata *, struct lookup_intent *, int flags);
1735         int (*link) (struct dentry *,struct inode *,struct dentry *);
1736 +       int (*link_raw) (struct nameidata *,struct nameidata *);
1737         int (*unlink) (struct inode *,struct dentry *);
1738 +       int (*unlink_raw) (struct nameidata *);
1739         int (*symlink) (struct inode *,struct dentry *,const char *);
1740 +       int (*symlink_raw) (struct nameidata *,const char *);
1741         int (*mkdir) (struct inode *,struct dentry *,int);
1742 +       int (*mkdir_raw) (struct nameidata *,int);
1743         int (*rmdir) (struct inode *,struct dentry *);
1744 +       int (*rmdir_raw) (struct nameidata *);
1745         int (*mknod) (struct inode *,struct dentry *,int,int);
1746 +       int (*mknod_raw) (struct nameidata *,int,dev_t);
1747         int (*rename) (struct inode *, struct dentry *,
1748                         struct inode *, struct dentry *);
1749 +       int (*rename_raw) (struct nameidata *, struct nameidata *);
1750         int (*readlink) (struct dentry *, char *,int);
1751         int (*follow_link) (struct dentry *, struct nameidata *);
1752         void (*truncate) (struct inode *);
1753         int (*permission) (struct inode *, int);
1754         int (*revalidate) (struct dentry *);
1755 +       int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1756         int (*setattr) (struct dentry *, struct iattr *);
1757 +       int (*setattr_raw) (struct inode *, struct iattr *);
1758         int (*getattr) (struct dentry *, struct iattr *);
1759         int (*setxattr) (struct dentry *, const char *, const void *, size_t, int);
1760         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1761 @@ -1046,6 +1065,7 @@
1762         int (*remount_fs) (struct super_block *, int *, char *);
1763         void (*clear_inode) (struct inode *);
1764         void (*umount_begin) (struct super_block *);
1765 +       void (*umount_lustre) (struct super_block *);
1766  
1767         /* Following are for knfsd to interact with "interesting" filesystems
1768          * Currently just reiserfs, but possibly FAT and others later
1769 @@ -1205,10 +1225,16 @@
1770  
1771  asmlinkage long sys_open(const char *, int, int);
1772  asmlinkage long sys_close(unsigned int);       /* yes, it's really unsigned */
1773 -extern int do_truncate(struct dentry *, loff_t start);
1774 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1775 +struct dentry *lookup_create(struct nameidata *nd, int is_dir,
1776 +                                   struct lookup_intent *it);
1777  
1778  extern struct file *filp_open(const char *, int, int);
1779  extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1780 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1781 +                        struct nameidata *nd, struct lookup_intent *it);
1782 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1783 +                           int flags, struct lookup_intent *it);
1784  extern int filp_close(struct file *, fl_owner_t id);
1785  extern char * getname(const char *);
1786  
1787 @@ -1504,6 +1530,7 @@
1788  extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1789  
1790  extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1791 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1792  extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1793  extern int FASTCALL(path_walk(const char *, struct nameidata *));
1794  extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1795 @@ -1516,6 +1543,8 @@
1796  extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1797  #define user_path_walk(name,nd)         __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1798  #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1799 +#define user_path_walk_it(name,nd,it)  __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1800 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1801  
1802  extern void inode_init_once(struct inode *);
1803  extern void _inode_init_once(struct inode *);
1804 @@ -1667,6 +1696,8 @@
1805  
1806  extern int vfs_readlink(struct dentry *, char *, int, const char *);
1807  extern int vfs_follow_link(struct nameidata *, const char *);
1808 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1809 +                             struct lookup_intent *it);
1810  extern int page_readlink(struct dentry *, char *, int);
1811  extern int page_follow_link(struct dentry *, struct nameidata *);
1812  extern struct inode_operations page_symlink_inode_operations;
1813 Index: kernel-2.4.212lgns/include/linux/fs_struct.h
1814 ===================================================================
1815 --- kernel-2.4.212lgns.orig/include/linux/fs_struct.h   2001-07-13 15:10:44.000000000 -0700
1816 +++ kernel-2.4.212lgns/include/linux/fs_struct.h        2004-05-11 06:41:10.000000000 -0700
1817 @@ -34,10 +34,12 @@
1818         write_lock(&fs->lock);
1819         old_root = fs->root;
1820         old_rootmnt = fs->rootmnt;
1821 +       PIN(dentry, mnt, 1);
1822         fs->rootmnt = mntget(mnt);
1823         fs->root = dget(dentry);
1824         write_unlock(&fs->lock);
1825         if (old_root) {
1826 +               UNPIN(old_root, old_rootmnt, 1);
1827                 dput(old_root);
1828                 mntput(old_rootmnt);
1829         }
1830 @@ -57,10 +59,12 @@
1831         write_lock(&fs->lock);
1832         old_pwd = fs->pwd;
1833         old_pwdmnt = fs->pwdmnt;
1834 +       PIN(dentry, mnt, 0);
1835         fs->pwdmnt = mntget(mnt);
1836         fs->pwd = dget(dentry);
1837         write_unlock(&fs->lock);
1838         if (old_pwd) {
1839 +               UNPIN(old_pwd, old_pwdmnt, 0);
1840                 dput(old_pwd);
1841                 mntput(old_pwdmnt);
1842         }
1843 Index: kernel-2.4.212lgns/include/linux/mount.h
1844 ===================================================================
1845 --- kernel-2.4.212lgns.orig/include/linux/mount.h       2003-11-06 14:18:54.000000000 -0800
1846 +++ kernel-2.4.212lgns/include/linux/mount.h    2004-05-11 06:41:10.000000000 -0700
1847 @@ -29,6 +29,8 @@
1848         int mnt_flags;
1849         char *mnt_devname;              /* Name of device e.g. /dev/dsk/hda1 */
1850         struct list_head mnt_list;
1851 +       struct list_head mnt_lustre_list; /* GNS mount list */
1852 +       unsigned long mnt_last_used;      /* for GNS auto-umount (jiffies) */
1853  };
1854  
1855  static inline struct vfsmount *mntget(struct vfsmount *mnt)
1856 @@ -39,6 +41,7 @@
1857  }
1858  
1859  extern void __mntput(struct vfsmount *mnt);
1860 +extern int do_umount(struct vfsmount *mnt, int flags);
1861  
1862  static inline void mntput(struct vfsmount *mnt)
1863  {
1864 Index: kernel-2.4.212lgns/kernel/exit.c
1865 ===================================================================
1866 --- kernel-2.4.212lgns.orig/kernel/exit.c       2003-10-28 10:34:13.000000000 -0800
1867 +++ kernel-2.4.212lgns/kernel/exit.c    2004-05-11 06:41:10.000000000 -0700
1868 @@ -288,11 +288,14 @@
1869  {
1870         /* No need to hold fs->lock if we are killing it */
1871         if (atomic_dec_and_test(&fs->count)) {
1872 +               UNPIN(fs->pwd, fs->pwdmnt, 0);
1873 +               UNPIN(fs->root, fs->rootmnt, 1);
1874                 dput(fs->root);
1875                 mntput(fs->rootmnt);
1876                 dput(fs->pwd);
1877                 mntput(fs->pwdmnt);
1878                 if (fs->altroot) {
1879 +                       UNPIN(fs->altroot, fs->altrootmnt, 1);
1880                         dput(fs->altroot);
1881                         mntput(fs->altrootmnt);
1882                 }
1883 Index: kernel-2.4.212lgns/kernel/fork.c
1884 ===================================================================
1885 --- kernel-2.4.212lgns.orig/kernel/fork.c       2003-10-28 10:34:17.000000000 -0800
1886 +++ kernel-2.4.212lgns/kernel/fork.c    2004-05-11 06:41:10.000000000 -0700
1887 @@ -461,10 +461,13 @@
1888                 fs->umask = old->umask;
1889                 read_lock(&old->lock);
1890                 fs->rootmnt = mntget(old->rootmnt);
1891 +               PIN(old->pwd, old->pwdmnt, 0);
1892 +               PIN(old->root, old->rootmnt, 1);
1893                 fs->root = dget(old->root);
1894                 fs->pwdmnt = mntget(old->pwdmnt);
1895                 fs->pwd = dget(old->pwd);
1896                 if (old->altroot) {
1897 +                       PIN(old->altroot, old->altrootmnt, 1);
1898                         fs->altrootmnt = mntget(old->altrootmnt);
1899                         fs->altroot = dget(old->altroot);
1900                 } else {
1901 Index: kernel-2.4.212lgns/kernel/ksyms.c
1902 ===================================================================
1903 --- kernel-2.4.212lgns.orig/kernel/ksyms.c      2004-05-11 06:37:51.000000000 -0700
1904 +++ kernel-2.4.212lgns/kernel/ksyms.c   2004-05-11 06:41:10.000000000 -0700
1905 @@ -327,6 +327,9 @@
1906  EXPORT_SYMBOL(set_page_dirty);
1907  EXPORT_SYMBOL(vfs_readlink);
1908  EXPORT_SYMBOL(vfs_follow_link);
1909 +EXPORT_SYMBOL(vfs_follow_link_it);
1910 +EXPORT_SYMBOL(do_umount);
1911 +EXPORT_SYMBOL(lookup_create);
1912  EXPORT_SYMBOL(page_readlink);
1913  EXPORT_SYMBOL(page_follow_link);
1914  EXPORT_SYMBOL(page_symlink_inode_operations);