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