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