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