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