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