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