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