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