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