3 fs/namei.c | 355 +++++++++++++++++++++++++++++++++++++++++--------
4 fs/namespace.c | 30 +++-
5 fs/open.c | 122 ++++++++++++++--
8 include/linux/dcache.h | 54 +++++++
9 include/linux/fs.h | 31 ++++
13 12 files changed, 564 insertions(+), 99 deletions(-)
15 --- linux-2.4.18-p4smp/fs/exec.c~vfs_intent-2.4.18-18-chaos65 2003-07-09 12:17:30.000000000 -0600
16 +++ linux-2.4.18-p4smp-braam/fs/exec.c 2003-07-09 13:20:37.000000000 -0600
17 @@ -117,8 +117,9 @@ asmlinkage long sys_uselib(const char *
21 + struct lookup_intent it = { .it_op = IT_OPEN, .it_flags = O_RDONLY };
23 - error = user_path_walk(library, &nd);
24 + error = user_path_walk_it(library, &nd, &it);
28 @@ -130,7 +131,8 @@ asmlinkage long sys_uselib(const char *
32 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
33 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
34 + intent_release(&it);
35 error = PTR_ERR(file);
38 @@ -359,8 +361,9 @@ struct file *open_exec(const char *name)
42 + struct lookup_intent it = { .it_op = IT_OPEN, .it_flags = O_RDONLY };
44 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
45 + err = path_lookup_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
48 inode = nd.dentry->d_inode;
49 @@ -372,7 +375,8 @@ struct file *open_exec(const char *name)
53 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
54 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
55 + intent_release(&it);
57 err = deny_write_access(file);
59 @@ -384,6 +388,7 @@ out:
63 + intent_release(&it);
67 @@ -1104,7 +1109,7 @@ int do_coredump(long signr, struct pt_re
69 if (!file->f_op->write)
71 - if (do_truncate(file->f_dentry, 0) != 0)
72 + if (do_truncate(file->f_dentry, 0, 0) != 0)
75 retval = binfmt->core_dump(signr, regs, file);
76 --- linux-2.4.18-p4smp/fs/dcache.c~vfs_intent-2.4.18-18-chaos65 2003-07-09 12:17:30.000000000 -0600
77 +++ linux-2.4.18-p4smp-braam/fs/dcache.c 2003-07-09 13:20:37.000000000 -0600
78 @@ -186,6 +186,13 @@ int d_invalidate(struct dentry * dentry)
79 spin_unlock(&dcache_lock);
83 + /* network invalidation by Lustre */
84 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
85 + spin_unlock(&dcache_lock);
90 * Check whether to do a partial shrink_dcache
91 * to get rid of unused child entries.
92 @@ -859,13 +866,19 @@ void d_delete(struct dentry * dentry)
93 * Adds a dentry to the hash according to its name.
96 -void d_rehash(struct dentry * entry)
97 +void __d_rehash(struct dentry * entry, int lock)
99 struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
100 if (!list_empty(&entry->d_hash)) BUG();
101 - spin_lock(&dcache_lock);
102 + if (lock) spin_lock(&dcache_lock);
103 list_add(&entry->d_hash, list);
104 - spin_unlock(&dcache_lock);
105 + if (lock) spin_unlock(&dcache_lock);
107 +EXPORT_SYMBOL(__d_rehash);
109 +void d_rehash(struct dentry * entry)
111 + __d_rehash(entry, 1);
114 #define do_switch(x,y) do { \
115 --- linux-2.4.18-p4smp/fs/namespace.c~vfs_intent-2.4.18-18-chaos65 2002-06-25 22:16:14.000000000 -0600
116 +++ linux-2.4.18-p4smp-braam/fs/namespace.c 2003-07-09 13:20:37.000000000 -0600
117 @@ -99,6 +99,7 @@ static void detach_mnt(struct vfsmount *
119 old_nd->dentry = mnt->mnt_mountpoint;
120 old_nd->mnt = mnt->mnt_parent;
121 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
122 mnt->mnt_parent = mnt;
123 mnt->mnt_mountpoint = mnt->mnt_root;
124 list_del_init(&mnt->mnt_child);
125 @@ -110,6 +111,7 @@ static void attach_mnt(struct vfsmount *
127 mnt->mnt_parent = mntget(nd->mnt);
128 mnt->mnt_mountpoint = dget(nd->dentry);
129 + PIN(nd->dentry, nd->mnt, 1);
130 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
131 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
132 nd->dentry->d_mounted++;
133 @@ -485,14 +487,17 @@ static int do_loopback(struct nameidata
135 struct nameidata old_nd;
136 struct vfsmount *mnt = NULL;
137 + struct lookup_intent it = { .it_op = IT_GETATTR };
138 int err = mount_is_safe(nd);
141 if (!old_name || !*old_name)
143 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
145 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
147 + intent_release(&it);
151 down_write(¤t->namespace->sem);
153 @@ -515,6 +520,7 @@ static int do_loopback(struct nameidata
156 up_write(¤t->namespace->sem);
157 + intent_release(&it);
158 path_release(&old_nd);
161 @@ -698,7 +704,8 @@ long do_mount(char * dev_name, char * di
162 unsigned long flags, void *data_page)
166 + struct lookup_intent it = { .it_op = IT_GETATTR };
171 @@ -722,10 +729,11 @@ long do_mount(char * dev_name, char * di
172 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
174 /* ... and get the mountpoint */
175 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
177 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
179 + intent_release(&it);
183 if (flags & MS_REMOUNT)
184 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
186 @@ -736,6 +744,8 @@ long do_mount(char * dev_name, char * di
188 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
189 dev_name, data_page);
191 + intent_release(&it);
195 @@ -901,6 +911,8 @@ asmlinkage long sys_pivot_root(const cha
197 struct vfsmount *tmp;
198 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
199 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
200 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
203 if (!capable(CAP_SYS_ADMIN))
204 @@ -908,14 +920,14 @@ asmlinkage long sys_pivot_root(const cha
208 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
209 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
213 if (!check_mnt(new_nd.mnt))
216 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
217 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
221 @@ -970,8 +982,10 @@ out2:
222 up(&old_nd.dentry->d_inode->i_zombie);
223 up_write(¤t->namespace->sem);
224 path_release(&user_nd);
225 + intent_release(&old_it);
226 path_release(&old_nd);
228 + intent_release(&new_it);
229 path_release(&new_nd);
232 --- linux-2.4.18-p4smp/fs/namei.c~vfs_intent-2.4.18-18-chaos65 2003-07-09 12:17:30.000000000 -0600
233 +++ linux-2.4.18-p4smp-braam/fs/namei.c 2003-07-09 13:20:37.000000000 -0600
235 * XEmacs seems to be relying on it...
238 +void intent_release(struct lookup_intent *it)
240 + if (it && it->it_op_release)
241 + it->it_op_release(it);
245 /* In order to reduce some races, while at the same time doing additional
246 * checking and hopefully speeding things up, we copy filenames to the
247 * kernel data space before using them..
248 @@ -260,10 +267,19 @@ void path_release(struct nameidata *nd)
249 * Internal lookup() using the new generic dcache.
252 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
253 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
254 + int flags, struct lookup_intent *it)
256 struct dentry * dentry = d_lookup(parent, name);
258 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
259 + if (!dentry->d_op->d_revalidate_it(dentry, flags, it) &&
260 + !d_invalidate(dentry)) {
266 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
267 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
269 @@ -281,11 +297,14 @@ static struct dentry * cached_lookup(str
270 * make sure that nobody added the entry to the dcache in the meantime..
273 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
274 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
275 + int flags, struct lookup_intent *it)
277 struct dentry * result;
278 struct inode *dir = parent->d_inode;
284 * First re-do the cached lookup just in case it was created
285 @@ -300,6 +319,9 @@ static struct dentry * real_lookup(struc
286 result = ERR_PTR(-ENOMEM);
289 + if (dir->i_op->lookup_it)
290 + result = dir->i_op->lookup_it(dir, dentry, it, flags);
292 result = dir->i_op->lookup(dir, dentry);
295 @@ -321,6 +343,12 @@ static struct dentry * real_lookup(struc
297 result = ERR_PTR(-ENOENT);
299 + } else if (result->d_op && result->d_op->d_revalidate_it) {
300 + if (!result->d_op->d_revalidate_it(result, flags, it) &&
301 + !d_invalidate(result)) {
308 @@ -334,7 +362,8 @@ int max_recursive_link = 5;
309 * Without that kind of total limit, nasty chains of consecutive
310 * symlinks can cause almost arbitrarily long lookups.
312 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
313 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
314 + struct lookup_intent *it)
317 if (current->link_count >= max_recursive_link)
318 @@ -348,10 +377,21 @@ static inline int do_follow_link(struct
319 current->link_count++;
320 current->total_link_count++;
321 UPDATE_ATIME(dentry->d_inode);
322 - err = dentry->d_inode->i_op->follow_link(dentry, nd);
324 + if (dentry->d_inode->i_op->follow_link2)
325 + err = dentry->d_inode->i_op->follow_link2(dentry, nd, it);
327 + err = dentry->d_inode->i_op->follow_link(dentry, nd);
328 + if (!err && it != NULL && !(it->it_int_flags & IT_FL_FOLLOWED)) {
329 + /* vfs_follow_link was never called */
330 + intent_release(it);
334 current->link_count--;
337 + intent_release(it);
341 @@ -381,15 +421,26 @@ int follow_up(struct vfsmount **mnt, str
342 return __follow_up(mnt, dentry);
345 -static inline int __follow_down(struct vfsmount **mnt, struct dentry **dentry)
346 +static inline int __follow_down(struct vfsmount **mnt, struct dentry **dentry,
347 + struct lookup_intent *it)
349 struct vfsmount *mounted;
351 spin_lock(&dcache_lock);
352 mounted = lookup_mnt(*mnt, *dentry);
354 + int opc = 0, mode = 0;
355 *mnt = mntget(mounted);
356 spin_unlock(&dcache_lock);
359 + mode = it->it_mode;
361 + intent_release(it);
364 + it->it_mode = mode;
367 mntput(mounted->mnt_parent);
368 *dentry = dget(mounted->mnt_root);
369 @@ -401,7 +452,7 @@ static inline int __follow_down(struct v
371 int follow_down(struct vfsmount **mnt, struct dentry **dentry)
373 - return __follow_down(mnt,dentry);
374 + return __follow_down(mnt,dentry,NULL);
377 static inline void follow_dotdot(struct nameidata *nd)
378 @@ -437,7 +488,7 @@ static inline void follow_dotdot(struct
382 - while (d_mountpoint(nd->dentry) && __follow_down(&nd->mnt, &nd->dentry))
383 + while (d_mountpoint(nd->dentry) && __follow_down(&nd->mnt, &nd->dentry, NULL))
387 @@ -449,7 +500,8 @@ static inline void follow_dotdot(struct
389 * We expect 'base' to be positive and a directory.
391 -int link_path_walk(const char * name, struct nameidata *nd)
392 +int link_path_walk_it(const char *name, struct nameidata *nd,
393 + struct lookup_intent *it)
395 struct dentry *dentry;
397 @@ -526,18 +578,18 @@ int link_path_walk(const char * name, st
400 /* This does the actual lookups.. */
401 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
402 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
404 err = -EWOULDBLOCKIO;
407 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
408 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
409 err = PTR_ERR(dentry);
413 /* Check mountpoints.. */
414 - while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry))
415 + while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry, NULL))
419 @@ -548,8 +600,8 @@ int link_path_walk(const char * name, st
423 - if (inode->i_op->follow_link) {
424 - err = do_follow_link(dentry, nd);
425 + if (inode->i_op->follow_link || inode->i_op->follow_link2) {
426 + err = do_follow_link(dentry, nd, NULL);
430 @@ -565,7 +617,7 @@ int link_path_walk(const char * name, st
434 - if (!inode->i_op->lookup)
435 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
438 /* here ends the main loop */
439 @@ -592,22 +644,23 @@ last_component:
443 - dentry = cached_lookup(nd->dentry, &this, 0);
444 + dentry = cached_lookup(nd->dentry, &this, 0, it);
446 err = -EWOULDBLOCKIO;
449 - dentry = real_lookup(nd->dentry, &this, 0);
450 + dentry = real_lookup(nd->dentry, &this, 0, it);
451 err = PTR_ERR(dentry);
455 - while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry))
456 + while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry, it))
458 inode = dentry->d_inode;
459 if ((lookup_flags & LOOKUP_FOLLOW)
460 - && inode && inode->i_op && inode->i_op->follow_link) {
461 - err = do_follow_link(dentry, nd);
462 + && inode && inode->i_op &&
463 + (inode->i_op->follow_link || inode->i_op->follow_link2)) {
464 + err = do_follow_link(dentry, nd, it);
468 @@ -621,7 +674,8 @@ last_component:
470 if (lookup_flags & LOOKUP_DIRECTORY) {
472 - if (!inode->i_op || !inode->i_op->lookup)
473 + if (!inode->i_op ||
474 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
478 @@ -645,7 +699,24 @@ return_reval:
479 * Check the cached dentry for staleness.
482 - if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
484 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
486 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
487 + struct dentry *new;
488 + err = permission(dentry->d_parent->d_inode,
492 + new = real_lookup(dentry->d_parent,
493 + &dentry->d_name, 0, NULL);
494 + d_invalidate(dentry);
497 + goto revalidate_again;
500 + else if (dentry && dentry->d_op && dentry->d_op->d_revalidate){
502 if (!dentry->d_op->d_revalidate(dentry, 0)) {
503 d_invalidate(dentry);
504 @@ -658,15 +729,28 @@ out_dput:
509 + intent_release(it);
515 +int link_path_walk(const char * name, struct nameidata *nd)
517 + return link_path_walk_it(name, nd, NULL);
520 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
522 + current->total_link_count = 0;
523 + return link_path_walk_it(name, nd, it);
526 int path_walk(const char * name, struct nameidata *nd)
528 current->total_link_count = 0;
529 - return link_path_walk(name, nd);
530 + return link_path_walk_it(name, nd, NULL);
534 @@ -751,6 +835,17 @@ walk_init_root(const char *name, struct
538 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
539 + struct lookup_intent *it)
542 + if (path_init(path, flags, nd))
543 + error = path_walk_it(path, nd, it);
549 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
552 @@ -765,6 +860,7 @@ int path_init(const char *name, unsigned
554 nd->last_type = LAST_ROOT; /* if there are only slashes... */
558 return walk_init_root(name,nd);
559 read_lock(¤t->fs->lock);
560 @@ -779,7 +875,8 @@ int path_init(const char *name, unsigned
561 * needs parent already locked. Doesn't follow mounts.
564 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
565 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
566 + struct lookup_intent *it)
568 struct dentry * dentry;
570 @@ -802,13 +899,16 @@ struct dentry * lookup_hash(struct qstr
574 - dentry = cached_lookup(base, name, 0);
575 + dentry = cached_lookup(base, name, 0, it);
577 struct dentry *new = d_alloc(base, name);
578 dentry = ERR_PTR(-ENOMEM);
582 + if (inode->i_op->lookup_it)
583 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
585 dentry = inode->i_op->lookup(inode, new);
588 @@ -820,6 +920,12 @@ out:
592 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
594 + return lookup_hash_it(name, base, NULL);
599 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
601 @@ -841,7 +947,7 @@ struct dentry * lookup_one_len(const cha
603 this.hash = end_name_hash(hash);
605 - return lookup_hash(&this, base);
606 + return lookup_hash_it(&this, base, NULL);
608 return ERR_PTR(-EACCES);
610 @@ -872,6 +978,23 @@ int __user_walk(const char *name, unsign
614 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
615 + struct lookup_intent *it)
620 + tmp = getname(name);
621 + err = PTR_ERR(tmp);
622 + if (!IS_ERR(tmp)) {
624 + if (path_init(tmp, flags, nd))
625 + err = path_walk_it(tmp, nd, it);
632 * It's inline, so penalty for filesystems that don't use sticky bit is
634 @@ -969,6 +1092,37 @@ static inline int lookup_flags(unsigned
638 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
639 + struct lookup_intent *it)
646 + down(&dir->i_zombie);
647 + error = may_create(dir, dentry);
651 + error = -EACCES; /* shouldn't it be ENOSYS? */
652 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
657 + if (dir->i_op->create_it)
658 + error = dir->i_op->create_it(dir, dentry, mode, it);
660 + error = dir->i_op->create(dir, dentry, mode);
663 + up(&dir->i_zombie);
665 + inode_dir_notify(dir, DN_CREATE);
669 int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
672 @@ -987,7 +1141,7 @@ int vfs_create(struct inode *dir, struct
676 - error = dir->i_op->create(dir, dentry, mode);
677 + error = dir->i_op->create(dir, dentry, mode);
681 @@ -1045,14 +1199,17 @@ int may_open(struct nameidata *nd, int a
682 return get_lease(inode, flag);
685 -struct file *filp_open(const char * pathname, int open_flags, int mode)
686 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
687 + int flags, struct lookup_intent *it);
689 +struct file *filp_open(const char * pathname, int open_flags, int mode)
691 int acc_mode, error = 0;
692 - struct inode *inode;
693 struct dentry *dentry;
695 int flag = open_flags;
697 + struct lookup_intent it = { .it_op = IT_OPEN, .it_flags = open_flags };
700 if (!capable(CAP_SYS_ADMIN))
701 @@ -1069,7 +1226,7 @@ struct file *filp_open(const char * path
702 * The simplest case - just a plain lookup.
704 if (!(flag & O_CREAT)) {
705 - error = path_lookup(pathname, lookup_flags(flag), &nd);
706 + error = path_lookup_it(pathname, lookup_flags(flag), &nd, &it);
708 return ERR_PTR(error);
710 @@ -1079,6 +1236,8 @@ struct file *filp_open(const char * path
712 * Create - we need to know the parent.
715 + it.it_op |= IT_CREAT;
716 error = path_lookup(pathname, LOOKUP_PARENT, &nd);
718 return ERR_PTR(error);
719 @@ -1094,7 +1253,7 @@ struct file *filp_open(const char * path
722 down(&dir->d_inode->i_sem);
723 - dentry = lookup_hash(&nd.last, nd.dentry);
724 + dentry = lookup_hash_it(&nd.last, nd.dentry, &it);
727 error = PTR_ERR(dentry);
728 @@ -1103,10 +1262,11 @@ do_last:
733 /* Negative dentry, just create the file */
734 if (!dentry->d_inode) {
735 - error = vfs_create(dir->d_inode, dentry,
736 - mode & ~current->fs->umask);
737 + error = vfs_create_it(dir->d_inode, dentry,
738 + mode & ~current->fs->umask, &it);
739 up(&dir->d_inode->i_sem);
742 @@ -1132,12 +1292,12 @@ do_last:
744 if (flag & O_NOFOLLOW)
746 - while (__follow_down(&nd.mnt,&dentry) && d_mountpoint(dentry));
747 + while (__follow_down(&nd.mnt,&dentry, &it) && d_mountpoint(dentry));
750 if (!dentry->d_inode)
752 - if (dentry->d_inode->i_op && dentry->d_inode->i_op->follow_link)
753 + if (dentry->d_inode->i_op && (dentry->d_inode->i_op->follow_link))
757 @@ -1152,11 +1312,13 @@ ok:
758 if (!S_ISREG(nd.dentry->d_inode->i_mode))
759 open_flags &= ~O_TRUNC;
761 - return dentry_open(nd.dentry, nd.mnt, open_flags);
762 + return dentry_open_it(nd.dentry, nd.mnt, open_flags, &it);
765 + intent_release(&it);
768 + intent_release(&it);
770 return ERR_PTR(error);
772 @@ -1175,10 +1337,19 @@ do_link:
773 * are done. Procfs-like symlinks just set LAST_BIND.
775 UPDATE_ATIME(dentry->d_inode);
776 - error = dentry->d_inode->i_op->follow_link(dentry, &nd);
778 + error = dentry->d_inode->i_op->follow_link(dentry, &nd);
780 + intent_release(&it);
781 + } else if (!(it.it_int_flags & IT_FL_FOLLOWED)) {
782 + /* vfs_follow_link was never called */
783 + intent_release(&it);
790 + return ERR_PTR(error);
791 if (nd.last_type == LAST_BIND) {
794 @@ -1197,13 +1368,15 @@ do_link:
797 down(&dir->d_inode->i_sem);
798 - dentry = lookup_hash(&nd.last, nd.dentry);
799 + dentry = lookup_hash_it(&nd.last, nd.dentry, &it);
800 putname(nd.last.name);
806 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
807 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
808 + struct lookup_intent *it)
810 struct dentry *dentry;
812 @@ -1211,7 +1384,7 @@ static struct dentry *lookup_create(stru
813 dentry = ERR_PTR(-EEXIST);
814 if (nd->last_type != LAST_NORM)
816 - dentry = lookup_hash(&nd->last, nd->dentry);
817 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
820 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
821 @@ -1267,7 +1440,16 @@ asmlinkage long sys_mknod(const char * f
822 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
825 - dentry = lookup_create(&nd, 0);
827 + if (nd.dentry->d_inode->i_op->mknod_raw) {
828 + struct inode_operations *op = nd.dentry->d_inode->i_op;
829 + error = op->mknod_raw(&nd, mode, dev);
830 + /* the file system wants to use normal vfs path now */
831 + if (error != -EOPNOTSUPP)
835 + dentry = lookup_create(&nd, 0, NULL);
836 error = PTR_ERR(dentry);
838 mode &= ~current->fs->umask;
839 @@ -1288,6 +1470,7 @@ asmlinkage long sys_mknod(const char * f
842 up(&nd.dentry->d_inode->i_sem);
847 @@ -1335,7 +1518,14 @@ asmlinkage long sys_mkdir(const char * p
848 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
851 - dentry = lookup_create(&nd, 1);
852 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
853 + struct inode_operations *op = nd.dentry->d_inode->i_op;
854 + error = op->mkdir_raw(&nd, mode);
855 + /* the file system wants to use normal vfs path now */
856 + if (error != -EOPNOTSUPP)
859 + dentry = lookup_create(&nd, 1, NULL);
860 error = PTR_ERR(dentry);
861 if (!IS_ERR(dentry)) {
862 error = vfs_mkdir(nd.dentry->d_inode, dentry,
863 @@ -1343,6 +1533,7 @@ asmlinkage long sys_mkdir(const char * p
866 up(&nd.dentry->d_inode->i_sem);
871 @@ -1443,8 +1634,16 @@ asmlinkage long sys_rmdir(const char * p
875 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
876 + struct inode_operations *op = nd.dentry->d_inode->i_op;
878 + error = op->rmdir_raw(&nd);
879 + /* the file system wants to use normal vfs path now */
880 + if (error != -EOPNOTSUPP)
883 down(&nd.dentry->d_inode->i_sem);
884 - dentry = lookup_hash(&nd.last, nd.dentry);
885 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
886 error = PTR_ERR(dentry);
887 if (!IS_ERR(dentry)) {
888 error = vfs_rmdir(nd.dentry->d_inode, dentry);
889 @@ -1502,8 +1701,15 @@ asmlinkage long sys_unlink(const char *
891 if (nd.last_type != LAST_NORM)
893 + if (nd.dentry->d_inode->i_op->unlink_raw) {
894 + struct inode_operations *op = nd.dentry->d_inode->i_op;
895 + error = op->unlink_raw(&nd);
896 + /* the file system wants to use normal vfs path now */
897 + if (error != -EOPNOTSUPP)
900 down(&nd.dentry->d_inode->i_sem);
901 - dentry = lookup_hash(&nd.last, nd.dentry);
902 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
903 error = PTR_ERR(dentry);
904 if (!IS_ERR(dentry)) {
905 /* Why not before? Because we want correct error value */
906 @@ -1570,15 +1776,23 @@ asmlinkage long sys_symlink(const char *
907 error = path_lookup(to, LOOKUP_PARENT, &nd);
910 - dentry = lookup_create(&nd, 0);
911 + if (nd.dentry->d_inode->i_op->symlink_raw) {
912 + struct inode_operations *op = nd.dentry->d_inode->i_op;
913 + error = op->symlink_raw(&nd, from);
914 + /* the file system wants to use normal vfs path now */
915 + if (error != -EOPNOTSUPP)
918 + dentry = lookup_create(&nd, 0, NULL);
919 error = PTR_ERR(dentry);
920 if (!IS_ERR(dentry)) {
921 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
924 up(&nd.dentry->d_inode->i_sem);
932 @@ -1654,7 +1868,14 @@ asmlinkage long sys_link(const char * ol
934 if (old_nd.mnt != nd.mnt)
936 - new_dentry = lookup_create(&nd, 0);
937 + if (nd.dentry->d_inode->i_op->link_raw) {
938 + struct inode_operations *op = nd.dentry->d_inode->i_op;
939 + error = op->link_raw(&old_nd, &nd);
940 + /* the file system wants to use normal vfs path now */
941 + if (error != -EOPNOTSUPP)
944 + new_dentry = lookup_create(&nd, 0, NULL);
945 error = PTR_ERR(new_dentry);
946 if (!IS_ERR(new_dentry)) {
947 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
948 @@ -1698,7 +1919,7 @@ exit:
951 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
952 - struct inode *new_dir, struct dentry *new_dentry)
953 + struct inode *new_dir, struct dentry *new_dentry)
956 struct inode *target;
957 @@ -1777,7 +1998,7 @@ out_unlock:
960 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
961 - struct inode *new_dir, struct dentry *new_dentry)
962 + struct inode *new_dir, struct dentry *new_dentry)
966 @@ -1865,9 +2086,18 @@ static inline int do_rename(const char *
967 if (newnd.last_type != LAST_NORM)
970 + if (old_dir->d_inode->i_op->rename_raw) {
972 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
974 + /* the file system wants to use normal vfs path now */
975 + if (error != -EOPNOTSUPP)
979 double_lock(new_dir, old_dir);
981 - old_dentry = lookup_hash(&oldnd.last, old_dir);
982 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
983 error = PTR_ERR(old_dentry);
984 if (IS_ERR(old_dentry))
986 @@ -1883,16 +2113,16 @@ static inline int do_rename(const char *
987 if (newnd.last.name[newnd.last.len])
990 - new_dentry = lookup_hash(&newnd.last, new_dir);
991 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
992 error = PTR_ERR(new_dentry);
993 if (IS_ERR(new_dentry))
998 error = vfs_rename(old_dir->d_inode, old_dentry,
999 new_dir->d_inode, new_dentry);
1005 @@ -1943,12 +2173,19 @@ out:
1009 -__vfs_follow_link(struct nameidata *nd, const char *link)
1010 +__vfs_follow_link(struct nameidata *nd, const char *link,
1011 + struct lookup_intent *it)
1019 + else if (it != nd->it)
1020 + printk("it != nd->it: tell phil@clusterfs.com\n");
1022 + it->it_int_flags |= IT_FL_FOLLOWED;
1026 @@ -1956,7 +2193,7 @@ __vfs_follow_link(struct nameidata *nd,
1027 /* weird __emul_prefix() stuff did it */
1030 - res = link_path_walk(link, nd);
1031 + res = link_path_walk_it(link, nd, it);
1033 if (current->link_count || res || nd->last_type!=LAST_NORM)
1035 @@ -1978,7 +2215,13 @@ fail:
1037 int vfs_follow_link(struct nameidata *nd, const char *link)
1039 - return __vfs_follow_link(nd, link);
1040 + return __vfs_follow_link(nd, link, NULL);
1043 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
1044 + struct lookup_intent *it)
1046 + return __vfs_follow_link(nd, link, it);
1049 /* get the link contents into pagecache */
1050 @@ -2020,7 +2263,7 @@ int page_follow_link(struct dentry *dent
1052 struct page *page = NULL;
1053 char *s = page_getlink(dentry, &page);
1054 - int res = __vfs_follow_link(nd, s);
1055 + int res = __vfs_follow_link(nd, s, NULL);
1058 page_cache_release(page);
1059 --- linux-2.4.18-p4smp/fs/open.c~vfs_intent-2.4.18-18-chaos65 2003-07-09 12:17:30.000000000 -0600
1060 +++ linux-2.4.18-p4smp-braam/fs/open.c 2003-07-09 13:20:37.000000000 -0600
1062 #include <asm/uaccess.h>
1064 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1065 +extern int path_walk_it(const char *name, struct nameidata *nd,
1066 + struct lookup_intent *it);
1068 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1070 @@ -95,9 +97,10 @@ void fd_install(unsigned int fd, struct
1071 write_unlock(&files->file_lock);
1074 -int do_truncate(struct dentry *dentry, loff_t length)
1075 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1077 struct inode *inode = dentry->d_inode;
1078 + struct inode_operations *op = dentry->d_inode->i_op;
1080 struct iattr newattrs;
1082 @@ -108,7 +111,13 @@ int do_truncate(struct dentry *dentry, l
1083 down(&inode->i_sem);
1084 newattrs.ia_size = length;
1085 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1086 - error = notify_change(dentry, &newattrs);
1087 + if (called_from_open)
1088 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1089 + if (op->setattr_raw) {
1090 + newattrs.ia_valid |= ATTR_RAW;
1091 + error = op->setattr_raw(inode, &newattrs);
1093 + error = notify_change(dentry, &newattrs);
1097 @@ -118,12 +128,13 @@ static inline long do_sys_truncate(const
1098 struct nameidata nd;
1099 struct inode * inode;
1101 + struct lookup_intent it = { .it_op = IT_GETATTR };
1104 if (length < 0) /* sorry, but loff_t says... */
1107 - error = user_path_walk(path, &nd);
1108 + error = user_path_walk_it(path, &nd, &it);
1111 inode = nd.dentry->d_inode;
1112 @@ -163,11 +174,13 @@ static inline long do_sys_truncate(const
1113 error = locks_verify_truncate(inode, NULL, length);
1116 - error = do_truncate(nd.dentry, length);
1117 + intent_release(&it);
1118 + error = do_truncate(nd.dentry, length, 0);
1120 put_write_access(inode);
1123 + intent_release(&it);
1127 @@ -215,7 +228,7 @@ static inline long do_sys_ftruncate(unsi
1129 error = locks_verify_truncate(inode, file, length);
1131 - error = do_truncate(dentry, length);
1132 + error = do_truncate(dentry, length, 0);
1136 @@ -260,11 +273,13 @@ asmlinkage long sys_utime(char * filenam
1137 struct inode * inode;
1138 struct iattr newattrs;
1140 - error = user_path_walk(filename, &nd);
1141 + error = user_path_walk_it(filename, &nd, NULL);
1144 inode = nd.dentry->d_inode;
1146 + /* this is safe without a Lustre lock because it only depends
1147 + on the super block */
1149 if (IS_RDONLY(inode))
1151 @@ -279,11 +294,25 @@ asmlinkage long sys_utime(char * filenam
1154 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1158 + if (inode->i_op->setattr_raw) {
1159 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1161 + newattrs.ia_valid |= ATTR_RAW;
1162 + error = op->setattr_raw(inode, &newattrs);
1163 + /* the file system wants to use normal vfs path now */
1164 + if (error != -EOPNOTSUPP)
1165 + goto dput_and_out;
1170 if (current->fsuid != inode->i_uid &&
1171 (error = permission(inode,MAY_WRITE)) != 0)
1175 error = notify_change(nd.dentry, &newattrs);
1178 @@ -304,12 +337,14 @@ asmlinkage long sys_utimes(char * filena
1179 struct inode * inode;
1180 struct iattr newattrs;
1182 - error = user_path_walk(filename, &nd);
1183 + error = user_path_walk_it(filename, &nd, NULL);
1187 inode = nd.dentry->d_inode;
1189 + /* this is safe without a Lustre lock because it only depends
1190 + on the super block */
1192 if (IS_RDONLY(inode))
1194 @@ -324,7 +359,20 @@ asmlinkage long sys_utimes(char * filena
1195 newattrs.ia_atime = times[0].tv_sec;
1196 newattrs.ia_mtime = times[1].tv_sec;
1197 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1201 + if (inode->i_op->setattr_raw) {
1202 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1204 + newattrs.ia_valid |= ATTR_RAW;
1205 + error = op->setattr_raw(inode, &newattrs);
1206 + /* the file system wants to use normal vfs path now */
1207 + if (error != -EOPNOTSUPP)
1208 + goto dput_and_out;
1213 if (current->fsuid != inode->i_uid &&
1214 (error = permission(inode,MAY_WRITE)) != 0)
1216 @@ -347,6 +395,7 @@ asmlinkage long sys_access(const char *
1217 int old_fsuid, old_fsgid;
1218 kernel_cap_t old_cap;
1220 + struct lookup_intent it = { .it_op = IT_GETATTR };
1222 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1224 @@ -364,13 +413,14 @@ asmlinkage long sys_access(const char *
1226 current->cap_effective = current->cap_permitted;
1228 - res = user_path_walk(filename, &nd);
1229 + res = user_path_walk_it(filename, &nd, &it);
1231 res = permission(nd.dentry->d_inode, mode);
1232 /* SuS v2 requires we report a read only fs too */
1233 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1234 && !special_file(nd.dentry->d_inode->i_mode))
1236 + intent_release(&it);
1240 @@ -385,8 +435,11 @@ asmlinkage long sys_chdir(const char * f
1243 struct nameidata nd;
1244 + struct lookup_intent it = { .it_op = IT_GETATTR };
1246 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1247 + error = __user_walk_it(filename,
1248 + LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,
1253 @@ -397,6 +450,7 @@ asmlinkage long sys_chdir(const char * f
1254 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1257 + intent_release(&it);
1261 @@ -436,9 +490,10 @@ asmlinkage long sys_chroot(const char *
1264 struct nameidata nd;
1265 + struct lookup_intent it = { .it_op = IT_GETATTR };
1267 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1268 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1269 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1270 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1274 @@ -454,6 +509,7 @@ asmlinkage long sys_chroot(const char *
1278 + intent_release(&it);
1282 @@ -508,6 +564,18 @@ asmlinkage long sys_chmod(const char * f
1283 if (IS_RDONLY(inode))
1286 + if (inode->i_op->setattr_raw) {
1287 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1289 + newattrs.ia_mode = mode;
1290 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1291 + newattrs.ia_valid |= ATTR_RAW;
1292 + error = op->setattr_raw(inode, &newattrs);
1293 + /* the file system wants to use normal vfs path now */
1294 + if (error != -EOPNOTSUPP)
1295 + goto dput_and_out;
1299 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1301 @@ -538,6 +606,20 @@ static int chown_common(struct dentry *
1303 if (IS_RDONLY(inode))
1306 + if (inode->i_op->setattr_raw) {
1307 + struct inode_operations *op = dentry->d_inode->i_op;
1309 + newattrs.ia_uid = user;
1310 + newattrs.ia_gid = group;
1311 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1312 + newattrs.ia_valid |= ATTR_RAW;
1313 + error = op->setattr_raw(inode, &newattrs);
1314 + /* the file system wants to use normal vfs path now */
1315 + if (error != -EOPNOTSUPP)
1320 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1322 @@ -628,7 +710,8 @@ extern ssize_t do_readahead(struct file
1323 /* for files over a certains size it doesn't pay to do readahead on open */
1324 #define READAHEAD_CUTOFF 48000
1326 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1327 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1328 + int flags, struct lookup_intent *it)
1331 struct inode *inode;
1332 @@ -649,7 +732,7 @@ struct file *dentry_open(struct dentry *
1333 error = locks_verify_locked(inode);
1336 - error = do_truncate(dentry, 0);
1337 + error = do_truncate(dentry, 0, 1);
1339 if (error || !(f->f_mode & FMODE_WRITE))
1340 put_write_access(inode);
1341 @@ -679,7 +762,9 @@ struct file *dentry_open(struct dentry *
1344 if (f->f_op && f->f_op->open) {
1346 error = f->f_op->open(inode,f);
1351 @@ -693,6 +778,7 @@ struct file *dentry_open(struct dentry *
1352 do_readahead(f, 0, (48 * 1024) >> PAGE_SHIFT);
1355 + intent_release(it);
1359 @@ -707,11 +793,17 @@ cleanup_all:
1363 + intent_release(it);
1366 return ERR_PTR(error);
1369 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1371 + return dentry_open_it(dentry, mnt, flags, NULL);
1375 * Find an empty file descriptor entry, and mark it busy.
1377 --- linux-2.4.18-p4smp/fs/stat.c~vfs_intent-2.4.18-18-chaos65 2003-07-09 12:17:30.000000000 -0600
1378 +++ linux-2.4.18-p4smp-braam/fs/stat.c 2003-07-09 13:20:37.000000000 -0600
1380 * Revalidate the inode. This is required for proper NFS attribute caching.
1382 static __inline__ int
1383 -do_revalidate(struct dentry *dentry)
1384 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1386 struct inode * inode = dentry->d_inode;
1387 - if (inode->i_op && inode->i_op->revalidate)
1388 + if (inode->i_op && inode->i_op->revalidate_it)
1389 + return inode->i_op->revalidate_it(dentry, it);
1390 + else if (inode->i_op && inode->i_op->revalidate)
1391 return inode->i_op->revalidate(dentry);
1395 -static int do_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
1396 +static int do_getattr(struct vfsmount *mnt, struct dentry *dentry,
1397 + struct kstat *stat, struct lookup_intent *it)
1400 unsigned int blocks, indirect;
1401 struct inode *inode = dentry->d_inode;
1403 - res = do_revalidate(dentry);
1404 + res = do_revalidate(dentry, it);
1408 @@ -104,10 +107,12 @@ int vfs_stat(char *name, struct kstat *s
1410 struct nameidata nd;
1412 + struct lookup_intent it = { .it_op = IT_GETATTR };
1414 - error = user_path_walk(name, &nd);
1415 + error = user_path_walk_it(name, &nd, &it);
1417 - error = do_getattr(nd.mnt, nd.dentry, stat);
1418 + error = do_getattr(nd.mnt, nd.dentry, stat, &it);
1419 + intent_release(&it);
1423 @@ -117,10 +122,12 @@ int vfs_lstat(char *name, struct kstat *
1425 struct nameidata nd;
1427 + struct lookup_intent it = { .it_op = IT_GETATTR };
1429 - error = user_path_walk_link(name, &nd);
1430 + error = user_path_walk_link_it(name, &nd, &it);
1432 - error = do_getattr(nd.mnt, nd.dentry, stat);
1433 + error = do_getattr(nd.mnt, nd.dentry, stat, &it);
1434 + intent_release(&it);
1438 @@ -132,7 +139,7 @@ int vfs_fstat(unsigned int fd, struct ks
1442 - error = do_getattr(f->f_vfsmnt, f->f_dentry, stat);
1443 + error = do_getattr(f->f_vfsmnt, f->f_dentry, stat, NULL);
1447 @@ -279,7 +286,7 @@ asmlinkage long sys_readlink(const char
1450 if (inode->i_op && inode->i_op->readlink &&
1451 - !(error = do_revalidate(nd.dentry))) {
1452 + !(error = do_revalidate(nd.dentry, NULL))) {
1453 UPDATE_ATIME(inode);
1454 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1456 --- linux-2.4.18-p4smp/fs/proc/base.c~vfs_intent-2.4.18-18-chaos65 2003-07-09 12:20:46.000000000 -0600
1457 +++ linux-2.4.18-p4smp-braam/fs/proc/base.c 2003-07-09 13:20:37.000000000 -0600
1458 @@ -465,6 +465,9 @@ static int proc_pid_follow_link(struct d
1460 error = inode->u.proc_i.op.proc_get_link(inode, &nd->dentry, &nd->mnt);
1461 nd->last_type = LAST_BIND;
1463 + if (nd->it != NULL)
1464 + nd->it->it_int_flags |= IT_FL_FOLLOWED;
1468 --- linux-2.4.18-p4smp/include/linux/dcache.h~vfs_intent-2.4.18-18-chaos65 2003-07-09 13:15:23.000000000 -0600
1469 +++ linux-2.4.18-p4smp-braam/include/linux/dcache.h 2003-07-09 13:32:08.000000000 -0600
1471 #include <asm/atomic.h>
1472 #include <linux/gdb.h>
1473 #include <linux/mount.h>
1474 +#include <linux/string.h>
1476 +#define IT_OPEN 0x0001
1477 +#define IT_CREAT 0x0002
1478 +#define IT_READDIR 0x0004
1479 +#define IT_GETATTR 0x0008
1480 +#define IT_LOOKUP 0x0010
1481 +#define IT_UNLINK 0x0020
1482 +#define IT_GETXATTR 0x0040
1483 +#define IT_EXEC 0x0080
1484 +#define IT_PIN 0x0100
1486 +#define IT_FL_LOCKED 0x0001
1487 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1489 +#define INTENT_MAGIC 0x19620323
1491 +struct lookup_intent {
1493 + void (*it_op_release)(struct lookup_intent *);
1497 + int it_disposition;
1500 + __u64 it_lock_handle[2];
1505 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1507 + memset(it, 0, sizeof(*it));
1508 + it->it_magic = INTENT_MAGIC;
1510 + it->it_flags = flags;
1515 * linux/include/linux/dcache.h
1516 @@ -92,8 +131,22 @@ struct dentry_operations {
1517 int (*d_delete)(struct dentry *);
1518 void (*d_release)(struct dentry *);
1519 void (*d_iput)(struct dentry *, struct inode *);
1520 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1521 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1522 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1525 +#define PIN(de,mnt,flag) if (de->d_op && de->d_op->d_pin) \
1526 + de->d_op->d_pin(de, mnt, flag);
1527 +#define UNPIN(de,mnt,flag) if (de->d_op && de->d_op->d_unpin) \
1528 + de->d_op->d_unpin(de, mnt, flag);
1531 +/* defined in fs/namei.c */
1532 +extern void intent_release(struct lookup_intent *it);
1533 +/* defined in fs/dcache.c */
1534 +extern void __d_rehash(struct dentry * entry, int lock);
1536 /* the dentry parameter passed to d_hash and d_compare is the parent
1537 * directory of the entries to be compared. It is used in case these
1538 * functions need any directory specific information for determining
1539 @@ -125,6 +178,7 @@ d_iput: no no yes
1540 * s_nfsd_free_path semaphore will be down
1542 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1543 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1545 extern spinlock_t dcache_lock;
1547 --- linux-2.4.18-p4smp/include/linux/fs.h~vfs_intent-2.4.18-18-chaos65 2003-07-08 14:41:47.000000000 -0600
1548 +++ linux-2.4.18-p4smp-braam/include/linux/fs.h 2003-07-08 14:45:17.000000000 -0600
1549 @@ -339,6 +339,9 @@ extern void set_bh_page(struct buffer_he
1550 #define ATTR_MTIME_SET 256
1551 #define ATTR_FORCE 512 /* Not a change, but a change it */
1552 #define ATTR_ATTR_FLAG 1024
1553 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1554 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1555 +#define ATTR_CTIME_SET 0x2000 /* called from open path, ie O_TRUNC */
1558 * This is the Inode Attributes structure, used for notify_change(). It
1559 @@ -578,6 +580,7 @@ struct file {
1561 /* needed for tty driver, and maybe others */
1563 + struct lookup_intent *f_it;
1565 /* preallocated helper kiobuf to speedup O_DIRECT */
1566 struct kiobuf *f_iobuf;
1567 @@ -707,6 +710,7 @@ struct nameidata {
1571 + struct lookup_intent *it;
1574 #define DQUOT_USR_ENABLED 0x01 /* User diskquotas enabled */
1575 @@ -840,7 +844,8 @@ extern int vfs_symlink(struct inode *, s
1576 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1577 extern int vfs_rmdir(struct inode *, struct dentry *);
1578 extern int vfs_unlink(struct inode *, struct dentry *);
1579 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1580 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1581 + struct inode *new_dir, struct dentry *new_dentry);
1585 @@ -900,21 +905,34 @@ struct file_operations {
1587 struct inode_operations {
1588 int (*create) (struct inode *,struct dentry *,int);
1589 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1590 struct dentry * (*lookup) (struct inode *,struct dentry *);
1591 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1592 int (*link) (struct dentry *,struct inode *,struct dentry *);
1593 + int (*link_raw) (struct nameidata *,struct nameidata *);
1594 int (*unlink) (struct inode *,struct dentry *);
1595 + int (*unlink_raw) (struct nameidata *);
1596 int (*symlink) (struct inode *,struct dentry *,const char *);
1597 + int (*symlink_raw) (struct nameidata *,const char *);
1598 int (*mkdir) (struct inode *,struct dentry *,int);
1599 + int (*mkdir_raw) (struct nameidata *,int);
1600 int (*rmdir) (struct inode *,struct dentry *);
1601 + int (*rmdir_raw) (struct nameidata *);
1602 int (*mknod) (struct inode *,struct dentry *,int,int);
1603 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1604 int (*rename) (struct inode *, struct dentry *,
1605 struct inode *, struct dentry *);
1606 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1607 int (*readlink) (struct dentry *, char *,int);
1608 int (*follow_link) (struct dentry *, struct nameidata *);
1609 + int (*follow_link2) (struct dentry *, struct nameidata *,
1610 + struct lookup_intent *it);
1611 void (*truncate) (struct inode *);
1612 int (*permission) (struct inode *, int);
1613 int (*revalidate) (struct dentry *);
1614 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1615 int (*setattr) (struct dentry *, struct iattr *);
1616 + int (*setattr_raw) (struct inode *, struct iattr *);
1617 int (*getattr) (struct dentry *, struct iattr *);
1620 @@ -1119,10 +1137,12 @@ static inline int get_lease(struct inode
1622 asmlinkage long sys_open(const char *, int, int);
1623 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1624 -extern int do_truncate(struct dentry *, loff_t start);
1625 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1627 extern struct file *filp_open(const char *, int, int);
1628 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1629 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1630 + int flags, struct lookup_intent *it);
1631 extern int filp_close(struct file *, fl_owner_t id);
1632 extern char * getname(const char *);
1634 @@ -1388,9 +1408,12 @@ typedef int (*read_actor_t)(read_descrip
1635 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1637 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1638 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1639 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1640 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1641 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1642 +extern int FASTCALL(path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
1643 + struct lookup_intent *it));
1644 extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
1645 extern void path_release(struct nameidata *);
1646 extern int follow_down(struct vfsmount **, struct dentry **);
1647 @@ -1399,6 +1422,8 @@ extern struct dentry * lookup_one_len(co
1648 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1649 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1650 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1651 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1652 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1654 extern void inode_init_once(struct inode *);
1655 extern void iput(struct inode *);
1656 @@ -1499,6 +1524,8 @@ extern struct file_operations generic_ro
1658 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1659 extern int vfs_follow_link(struct nameidata *, const char *);
1660 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1661 + struct lookup_intent *it);
1662 extern int page_readlink(struct dentry *, char *, int);
1663 extern int page_follow_link(struct dentry *, struct nameidata *);
1664 extern struct inode_operations page_symlink_inode_operations;
1665 --- linux-2.4.18-p4smp/kernel/fork.c~vfs_intent-2.4.18-18-chaos65 2003-03-24 11:22:37.000000000 -0700
1666 +++ linux-2.4.18-p4smp-braam/kernel/fork.c 2003-07-09 13:20:37.000000000 -0600
1667 @@ -399,10 +399,13 @@ static inline struct fs_struct *__copy_f
1668 fs->umask = old->umask;
1669 read_lock(&old->lock);
1670 fs->rootmnt = mntget(old->rootmnt);
1671 + PIN(old->pwd, old->pwdmnt, 0);
1672 + PIN(old->root, old->rootmnt, 1);
1673 fs->root = dget(old->root);
1674 fs->pwdmnt = mntget(old->pwdmnt);
1675 fs->pwd = dget(old->pwd);
1677 + PIN(old->altroot, old->altrootmnt, 1);
1678 fs->altrootmnt = mntget(old->altrootmnt);
1679 fs->altroot = dget(old->altroot);
1681 --- linux-2.4.18-p4smp/kernel/exit.c~vfs_intent-2.4.18-18-chaos65 2002-10-29 12:27:38.000000000 -0700
1682 +++ linux-2.4.18-p4smp-braam/kernel/exit.c 2003-07-09 13:20:37.000000000 -0600
1683 @@ -303,11 +303,14 @@ static inline void __put_fs_struct(struc
1685 /* No need to hold fs->lock if we are killing it */
1686 if (atomic_dec_and_test(&fs->count)) {
1687 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1688 + UNPIN(fs->root, fs->rootmnt, 1);
1690 mntput(fs->rootmnt);
1694 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1696 mntput(fs->altrootmnt);
1698 --- linux-2.4.18-p4smp/kernel/ksyms.c~vfs_intent-2.4.18-18-chaos65 2003-07-09 13:20:35.000000000 -0600
1699 +++ linux-2.4.18-p4smp-braam/kernel/ksyms.c 2003-07-09 13:20:37.000000000 -0600
1700 @@ -294,6 +294,7 @@ EXPORT_SYMBOL(read_cache_page);
1701 EXPORT_SYMBOL(set_page_dirty);
1702 EXPORT_SYMBOL(vfs_readlink);
1703 EXPORT_SYMBOL(vfs_follow_link);
1704 +EXPORT_SYMBOL(vfs_follow_link_it);
1705 EXPORT_SYMBOL(page_readlink);
1706 EXPORT_SYMBOL(page_follow_link);
1707 EXPORT_SYMBOL(page_symlink_inode_operations);