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