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