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