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