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