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