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