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