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