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