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