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