3 fs/namei.c | 328 +++++++++++++++++++++++++++++++++++++++++--------
4 fs/namespace.c | 28 +++-
5 fs/open.c | 167 ++++++++++++++++++------
7 include/linux/dcache.h | 60 ++++++++
8 include/linux/fs.h | 34 ++++-
12 11 files changed, 564 insertions(+), 126 deletions(-)
14 --- linux-2.4.18-chaos/fs/exec.c~vfs_intent-2.4.18-18-chaos65 2003-07-28 17:52:03.000000000 +0400
15 +++ linux-2.4.18-chaos-alexey/fs/exec.c 2003-09-14 17:25:41.000000000 +0400
16 @@ -117,8 +117,10 @@ asmlinkage long sys_uselib(const char *
20 + struct lookup_intent it = { .it_op = IT_OPEN,
21 + .it_flags = FMODE_READ|FMODE_EXEC };
23 - error = user_path_walk(library, &nd);
24 + error = user_path_walk_it(library, &nd, &it);
28 @@ -130,7 +132,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 +362,9 @@ struct file *open_exec(const char *name)
43 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
44 + struct lookup_intent it = { .it_op = IT_OPEN,
45 + .it_flags = FMODE_READ|FMODE_EXEC };
46 + err = path_lookup_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
49 inode = nd.dentry->d_inode;
50 @@ -372,7 +376,8 @@ struct file *open_exec(const char *name)
54 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
55 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
56 + intent_release(&it);
58 err = deny_write_access(file);
60 @@ -384,6 +389,7 @@ out:
64 + intent_release(&it);
68 @@ -1104,7 +1110,7 @@ int do_coredump(long signr, struct pt_re
70 if (!file->f_op->write)
72 - if (do_truncate(file->f_dentry, 0) != 0)
73 + if (do_truncate(file->f_dentry, 0, 0) != 0)
76 retval = binfmt->core_dump(signr, regs, file);
77 --- linux-2.4.18-chaos/fs/dcache.c~vfs_intent-2.4.18-18-chaos65 2003-07-28 17:52:03.000000000 +0400
78 +++ linux-2.4.18-chaos-alexey/fs/dcache.c 2003-09-14 17:25:41.000000000 +0400
79 @@ -186,6 +186,13 @@ int d_invalidate(struct dentry * dentry)
80 spin_unlock(&dcache_lock);
84 + /* network invalidation by Lustre */
85 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
86 + spin_unlock(&dcache_lock);
91 * Check whether to do a partial shrink_dcache
92 * to get rid of unused child entries.
93 @@ -859,13 +866,19 @@ void d_delete(struct dentry * dentry)
94 * Adds a dentry to the hash according to its name.
97 -void d_rehash(struct dentry * entry)
98 +void __d_rehash(struct dentry * entry, int lock)
100 struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
101 if (!list_empty(&entry->d_hash)) BUG();
102 - spin_lock(&dcache_lock);
103 + if (lock) spin_lock(&dcache_lock);
104 list_add(&entry->d_hash, list);
105 - spin_unlock(&dcache_lock);
106 + if (lock) spin_unlock(&dcache_lock);
108 +EXPORT_SYMBOL(__d_rehash);
110 +void d_rehash(struct dentry * entry)
112 + __d_rehash(entry, 1);
115 #define do_switch(x,y) do { \
116 --- linux-2.4.18-chaos/fs/namespace.c~vfs_intent-2.4.18-18-chaos65 2003-07-28 17:52:05.000000000 +0400
117 +++ linux-2.4.18-chaos-alexey/fs/namespace.c 2003-09-14 17:25:41.000000000 +0400
118 @@ -99,6 +99,7 @@ static void detach_mnt(struct vfsmount *
120 old_nd->dentry = mnt->mnt_mountpoint;
121 old_nd->mnt = mnt->mnt_parent;
122 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
123 mnt->mnt_parent = mnt;
124 mnt->mnt_mountpoint = mnt->mnt_root;
125 list_del_init(&mnt->mnt_child);
126 @@ -110,6 +111,7 @@ static void attach_mnt(struct vfsmount *
128 mnt->mnt_parent = mntget(nd->mnt);
129 mnt->mnt_mountpoint = dget(nd->dentry);
130 + PIN(nd->dentry, nd->mnt, 1);
131 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
132 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
133 nd->dentry->d_mounted++;
134 @@ -485,14 +487,17 @@ static int do_loopback(struct nameidata
136 struct nameidata old_nd;
137 struct vfsmount *mnt = NULL;
138 + struct lookup_intent it = { .it_op = IT_GETATTR };
139 int err = mount_is_safe(nd);
142 if (!old_name || !*old_name)
144 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
146 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
148 + intent_release(&it);
152 down_write(¤t->namespace->sem);
154 @@ -515,6 +520,7 @@ static int do_loopback(struct nameidata
157 up_write(¤t->namespace->sem);
158 + intent_release(&it);
159 path_release(&old_nd);
162 @@ -698,6 +704,7 @@ long do_mount(char * dev_name, char * di
163 unsigned long flags, void *data_page)
166 + struct lookup_intent it = { .it_op = IT_GETATTR };
170 @@ -722,10 +729,11 @@ long do_mount(char * dev_name, char * di
171 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
173 /* ... and get the mountpoint */
174 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
176 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
178 + intent_release(&it);
182 if (flags & MS_REMOUNT)
183 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
185 @@ -736,6 +744,8 @@ long do_mount(char * dev_name, char * di
187 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
188 dev_name, data_page);
190 + intent_release(&it);
194 @@ -901,6 +911,8 @@ asmlinkage long sys_pivot_root(const cha
196 struct vfsmount *tmp;
197 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
198 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
199 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
202 if (!capable(CAP_SYS_ADMIN))
203 @@ -908,14 +920,14 @@ asmlinkage long sys_pivot_root(const cha
207 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
208 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
212 if (!check_mnt(new_nd.mnt))
215 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
216 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
220 @@ -970,8 +982,10 @@ out2:
221 up(&old_nd.dentry->d_inode->i_zombie);
222 up_write(¤t->namespace->sem);
223 path_release(&user_nd);
224 + intent_release(&old_it);
225 path_release(&old_nd);
227 + intent_release(&new_it);
228 path_release(&new_nd);
231 --- linux-2.4.18-chaos/fs/namei.c~vfs_intent-2.4.18-18-chaos65 2003-07-28 17:52:05.000000000 +0400
232 +++ linux-2.4.18-chaos-alexey/fs/namei.c 2003-09-14 17:25:41.000000000 +0400
234 * XEmacs seems to be relying on it...
237 +void intent_release(struct lookup_intent *it)
239 + if (it && it->it_op_release)
240 + it->it_op_release(it);
244 /* In order to reduce some races, while at the same time doing additional
245 * checking and hopefully speeding things up, we copy filenames to the
246 * kernel data space before using them..
247 @@ -260,10 +267,19 @@ void path_release(struct nameidata *nd)
248 * Internal lookup() using the new generic dcache.
251 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
252 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
253 + int flags, struct lookup_intent *it)
255 struct dentry * dentry = d_lookup(parent, name);
257 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
258 + if (!dentry->d_op->d_revalidate_it(dentry, flags, it) &&
259 + !d_invalidate(dentry)) {
265 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
266 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
268 @@ -281,11 +297,15 @@ static struct dentry * cached_lookup(str
269 * make sure that nobody added the entry to the dcache in the meantime..
272 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
273 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
274 + int flags, struct lookup_intent *it)
276 struct dentry * result;
277 struct inode *dir = parent->d_inode;
284 * First re-do the cached lookup just in case it was created
285 @@ -300,6 +320,9 @@ static struct dentry * real_lookup(struc
286 result = ERR_PTR(-ENOMEM);
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 +344,15 @@ 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)) {
304 + result = ERR_PTR(-ESTALE);
305 + if (!IS_ERR(result))
311 @@ -334,7 +366,8 @@ int max_recursive_link = 5;
312 * Without that kind of total limit, nasty chains of consecutive
313 * symlinks can cause almost arbitrarily long lookups.
315 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
316 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
317 + struct lookup_intent *it)
320 if (current->link_count >= max_recursive_link)
321 @@ -348,10 +381,12 @@ static inline int do_follow_link(struct
322 current->link_count++;
323 current->total_link_count++;
324 UPDATE_ATIME(dentry->d_inode);
326 err = dentry->d_inode->i_op->follow_link(dentry, nd);
327 current->link_count--;
330 + intent_release(it);
334 @@ -381,7 +416,8 @@ int follow_up(struct vfsmount **mnt, str
335 return __follow_up(mnt, dentry);
338 -static inline int __follow_down(struct vfsmount **mnt, struct dentry **dentry)
339 +static inline int __follow_down(struct vfsmount **mnt, struct dentry **dentry,
340 + struct lookup_intent *it)
342 struct vfsmount *mounted;
344 @@ -401,7 +437,7 @@ static inline int __follow_down(struct v
346 int follow_down(struct vfsmount **mnt, struct dentry **dentry)
348 - return __follow_down(mnt,dentry);
349 + return __follow_down(mnt,dentry,NULL);
352 static inline void follow_dotdot(struct nameidata *nd)
353 @@ -437,7 +473,7 @@ static inline void follow_dotdot(struct
357 - while (d_mountpoint(nd->dentry) && __follow_down(&nd->mnt, &nd->dentry))
358 + while (d_mountpoint(nd->dentry) && __follow_down(&nd->mnt, &nd->dentry, NULL))
362 @@ -449,7 +485,8 @@ static inline void follow_dotdot(struct
364 * We expect 'base' to be positive and a directory.
366 -int link_path_walk(const char * name, struct nameidata *nd)
367 +int link_path_walk_it(const char *name, struct nameidata *nd,
368 + struct lookup_intent *it)
370 struct dentry *dentry;
372 @@ -526,18 +563,18 @@ int link_path_walk(const char * name, st
375 /* This does the actual lookups.. */
376 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
377 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
379 err = -EWOULDBLOCKIO;
382 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
383 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
384 err = PTR_ERR(dentry);
388 /* Check mountpoints.. */
389 - while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry))
390 + while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry, NULL))
394 @@ -548,8 +585,8 @@ int link_path_walk(const char * name, st
398 - if (inode->i_op->follow_link) {
399 - err = do_follow_link(dentry, nd);
400 + if (inode->i_op->follow_link || inode->i_op->follow_link2) {
401 + err = do_follow_link(dentry, nd, NULL);
405 @@ -565,7 +602,7 @@ int link_path_walk(const char * name, st
409 - if (!inode->i_op->lookup)
410 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
413 /* here ends the main loop */
414 @@ -592,22 +629,23 @@ last_component:
418 - dentry = cached_lookup(nd->dentry, &this, 0);
419 + dentry = cached_lookup(nd->dentry, &this, 0, it);
421 err = -EWOULDBLOCKIO;
424 - dentry = real_lookup(nd->dentry, &this, 0);
425 + dentry = real_lookup(nd->dentry, &this, 0, it);
426 err = PTR_ERR(dentry);
430 - while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry))
431 + while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry, it))
433 inode = dentry->d_inode;
434 if ((lookup_flags & LOOKUP_FOLLOW)
435 - && inode && inode->i_op && inode->i_op->follow_link) {
436 - err = do_follow_link(dentry, nd);
437 + && inode && inode->i_op &&
438 + (inode->i_op->follow_link || inode->i_op->follow_link2)) {
439 + err = do_follow_link(dentry, nd, it);
443 @@ -621,7 +659,8 @@ last_component:
445 if (lookup_flags & LOOKUP_DIRECTORY) {
447 - if (!inode->i_op || !inode->i_op->lookup)
448 + if (!inode->i_op ||
449 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
453 @@ -645,7 +684,26 @@ return_reval:
454 * Check the cached dentry for staleness.
457 - if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
458 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
460 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
461 + struct dentry *new;
462 + err = permission(dentry->d_parent->d_inode,
466 + new = real_lookup(dentry->d_parent,
467 + &dentry->d_name, 0, NULL);
468 + d_invalidate(dentry);
471 + err = PTR_ERR(new);
477 + else if (dentry && dentry->d_op && dentry->d_op->d_revalidate){
479 if (!dentry->d_op->d_revalidate(dentry, 0)) {
480 d_invalidate(dentry);
481 @@ -658,15 +716,28 @@ out_dput:
486 + intent_release(it);
492 +int link_path_walk(const char * name, struct nameidata *nd)
494 + return link_path_walk_it(name, nd, NULL);
497 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
499 + current->total_link_count = 0;
500 + return link_path_walk_it(name, nd, it);
503 int path_walk(const char * name, struct nameidata *nd)
505 current->total_link_count = 0;
506 - return link_path_walk(name, nd);
507 + return link_path_walk_it(name, nd, NULL);
511 @@ -751,6 +822,17 @@ walk_init_root(const char *name, struct
515 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
516 + struct lookup_intent *it)
519 + if (path_init(path, flags, nd))
520 + error = path_walk_it(path, nd, it);
526 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
529 @@ -765,6 +847,7 @@ int path_init(const char *name, unsigned
531 nd->last_type = LAST_ROOT; /* if there are only slashes... */
535 return walk_init_root(name,nd);
536 read_lock(¤t->fs->lock);
537 @@ -779,7 +862,8 @@ int path_init(const char *name, unsigned
538 * needs parent already locked. Doesn't follow mounts.
541 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
542 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
543 + struct lookup_intent *it)
545 struct dentry * dentry;
547 @@ -802,13 +886,16 @@ struct dentry * lookup_hash(struct qstr
551 - dentry = cached_lookup(base, name, 0);
552 + dentry = cached_lookup(base, name, 0, it);
554 struct dentry *new = d_alloc(base, name);
555 dentry = ERR_PTR(-ENOMEM);
559 + if (inode->i_op->lookup_it)
560 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
562 dentry = inode->i_op->lookup(inode, new);
565 @@ -820,6 +907,12 @@ out:
569 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
571 + return lookup_hash_it(name, base, NULL);
576 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
578 @@ -841,7 +934,7 @@ struct dentry * lookup_one_len(const cha
580 this.hash = end_name_hash(hash);
582 - return lookup_hash(&this, base);
583 + return lookup_hash_it(&this, base, NULL);
585 return ERR_PTR(-EACCES);
587 @@ -872,6 +965,23 @@ int __user_walk(const char *name, unsign
591 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
592 + struct lookup_intent *it)
597 + tmp = getname(name);
598 + err = PTR_ERR(tmp);
599 + if (!IS_ERR(tmp)) {
601 + if (path_init(tmp, flags, nd))
602 + err = path_walk_it(tmp, nd, it);
609 * It's inline, so penalty for filesystems that don't use sticky bit is
611 @@ -969,6 +1079,37 @@ static inline int lookup_flags(unsigned
615 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
616 + struct lookup_intent *it)
623 + down(&dir->i_zombie);
624 + error = may_create(dir, dentry);
628 + error = -EACCES; /* shouldn't it be ENOSYS? */
629 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
634 + if (dir->i_op->create_it)
635 + error = dir->i_op->create_it(dir, dentry, mode, it);
637 + error = dir->i_op->create(dir, dentry, mode);
640 + up(&dir->i_zombie);
642 + inode_dir_notify(dir, DN_CREATE);
646 int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
649 @@ -1045,14 +1186,17 @@ int may_open(struct nameidata *nd, int a
650 return get_lease(inode, flag);
653 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
654 + int flags, struct lookup_intent *it);
656 struct file *filp_open(const char * pathname, int open_flags, int mode)
658 int acc_mode, error = 0;
659 - struct inode *inode;
660 struct dentry *dentry;
662 int flag = open_flags;
664 + struct lookup_intent it = { .it_op = IT_OPEN};
667 if (!capable(CAP_SYS_ADMIN))
668 @@ -1063,13 +1207,14 @@ struct file *filp_open(const char * path
672 + it.it_flags = flag;
673 acc_mode = ACC_MODE(flag);
676 * The simplest case - just a plain lookup.
678 if (!(flag & O_CREAT)) {
679 - error = path_lookup(pathname, lookup_flags(flag), &nd);
680 + error = path_lookup_it(pathname, lookup_flags(flag), &nd, &it);
682 return ERR_PTR(error);
684 @@ -1079,6 +1224,8 @@ struct file *filp_open(const char * path
686 * Create - we need to know the parent.
688 + it.it_create_mode = mode;
689 + it.it_op |= IT_CREAT;
690 error = path_lookup(pathname, LOOKUP_PARENT, &nd);
692 return ERR_PTR(error);
693 @@ -1094,7 +1241,7 @@ struct file *filp_open(const char * path
696 down(&dir->d_inode->i_sem);
697 - dentry = lookup_hash(&nd.last, nd.dentry);
698 + dentry = lookup_hash_it(&nd.last, nd.dentry, &it);
701 error = PTR_ERR(dentry);
702 @@ -1103,10 +1250,11 @@ do_last:
706 + it.it_create_mode = mode;
707 /* Negative dentry, just create the file */
708 if (!dentry->d_inode) {
709 - error = vfs_create(dir->d_inode, dentry,
710 - mode & ~current->fs->umask);
711 + error = vfs_create_it(dir->d_inode, dentry,
712 + mode & ~current->fs->umask, &it);
713 up(&dir->d_inode->i_sem);
716 @@ -1132,12 +1280,12 @@ do_last:
718 if (flag & O_NOFOLLOW)
720 - while (__follow_down(&nd.mnt,&dentry) && d_mountpoint(dentry));
721 + while (__follow_down(&nd.mnt,&dentry, &it) && d_mountpoint(dentry));
724 if (!dentry->d_inode)
726 - if (dentry->d_inode->i_op && dentry->d_inode->i_op->follow_link)
727 + if (dentry->d_inode->i_op && (dentry->d_inode->i_op->follow_link))
731 @@ -1152,11 +1300,13 @@ ok:
732 if (!S_ISREG(nd.dentry->d_inode->i_mode))
733 open_flags &= ~O_TRUNC;
735 - return dentry_open(nd.dentry, nd.mnt, open_flags);
736 + return dentry_open_it(nd.dentry, nd.mnt, open_flags, &it);
739 + intent_release(&it);
742 + intent_release(&it);
744 return ERR_PTR(error);
746 @@ -1175,10 +1325,14 @@ do_link:
747 * are done. Procfs-like symlinks just set LAST_BIND.
749 UPDATE_ATIME(dentry->d_inode);
751 error = dentry->d_inode->i_op->follow_link(dentry, &nd);
753 + intent_release(&it);
758 + return ERR_PTR(error);
759 if (nd.last_type == LAST_BIND) {
762 @@ -1197,13 +1351,15 @@ do_link:
765 down(&dir->d_inode->i_sem);
766 - dentry = lookup_hash(&nd.last, nd.dentry);
767 + dentry = lookup_hash_it(&nd.last, nd.dentry, &it);
768 putname(nd.last.name);
774 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
775 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
776 + struct lookup_intent *it)
778 struct dentry *dentry;
780 @@ -1211,7 +1367,7 @@ static struct dentry *lookup_create(stru
781 dentry = ERR_PTR(-EEXIST);
782 if (nd->last_type != LAST_NORM)
784 - dentry = lookup_hash(&nd->last, nd->dentry);
785 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
788 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
789 @@ -1267,7 +1423,16 @@ asmlinkage long sys_mknod(const char * f
790 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
793 - dentry = lookup_create(&nd, 0);
795 + if (nd.dentry->d_inode->i_op->mknod_raw) {
796 + struct inode_operations *op = nd.dentry->d_inode->i_op;
797 + error = op->mknod_raw(&nd, mode, dev);
798 + /* the file system wants to use normal vfs path now */
799 + if (error != -EOPNOTSUPP)
803 + dentry = lookup_create(&nd, 0, NULL);
804 error = PTR_ERR(dentry);
806 mode &= ~current->fs->umask;
807 @@ -1288,6 +1453,7 @@ asmlinkage long sys_mknod(const char * f
810 up(&nd.dentry->d_inode->i_sem);
815 @@ -1335,7 +1501,14 @@ asmlinkage long sys_mkdir(const char * p
816 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
819 - dentry = lookup_create(&nd, 1);
820 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
821 + struct inode_operations *op = nd.dentry->d_inode->i_op;
822 + error = op->mkdir_raw(&nd, mode);
823 + /* the file system wants to use normal vfs path now */
824 + if (error != -EOPNOTSUPP)
827 + dentry = lookup_create(&nd, 1, NULL);
828 error = PTR_ERR(dentry);
829 if (!IS_ERR(dentry)) {
830 error = vfs_mkdir(nd.dentry->d_inode, dentry,
831 @@ -1343,6 +1516,7 @@ asmlinkage long sys_mkdir(const char * p
834 up(&nd.dentry->d_inode->i_sem);
839 @@ -1443,8 +1617,16 @@ asmlinkage long sys_rmdir(const char * p
843 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
844 + struct inode_operations *op = nd.dentry->d_inode->i_op;
846 + error = op->rmdir_raw(&nd);
847 + /* the file system wants to use normal vfs path now */
848 + if (error != -EOPNOTSUPP)
851 down(&nd.dentry->d_inode->i_sem);
852 - dentry = lookup_hash(&nd.last, nd.dentry);
853 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
854 error = PTR_ERR(dentry);
855 if (!IS_ERR(dentry)) {
856 error = vfs_rmdir(nd.dentry->d_inode, dentry);
857 @@ -1502,8 +1684,15 @@ asmlinkage long sys_unlink(const char *
859 if (nd.last_type != LAST_NORM)
861 + if (nd.dentry->d_inode->i_op->unlink_raw) {
862 + struct inode_operations *op = nd.dentry->d_inode->i_op;
863 + error = op->unlink_raw(&nd);
864 + /* the file system wants to use normal vfs path now */
865 + if (error != -EOPNOTSUPP)
868 down(&nd.dentry->d_inode->i_sem);
869 - dentry = lookup_hash(&nd.last, nd.dentry);
870 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
871 error = PTR_ERR(dentry);
872 if (!IS_ERR(dentry)) {
873 /* Why not before? Because we want correct error value */
874 @@ -1570,15 +1759,23 @@ asmlinkage long sys_symlink(const char *
875 error = path_lookup(to, LOOKUP_PARENT, &nd);
878 - dentry = lookup_create(&nd, 0);
879 + if (nd.dentry->d_inode->i_op->symlink_raw) {
880 + struct inode_operations *op = nd.dentry->d_inode->i_op;
881 + error = op->symlink_raw(&nd, from);
882 + /* the file system wants to use normal vfs path now */
883 + if (error != -EOPNOTSUPP)
886 + dentry = lookup_create(&nd, 0, NULL);
887 error = PTR_ERR(dentry);
888 if (!IS_ERR(dentry)) {
889 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
892 up(&nd.dentry->d_inode->i_sem);
900 @@ -1654,7 +1851,14 @@ asmlinkage long sys_link(const char * ol
902 if (old_nd.mnt != nd.mnt)
904 - new_dentry = lookup_create(&nd, 0);
905 + if (nd.dentry->d_inode->i_op->link_raw) {
906 + struct inode_operations *op = nd.dentry->d_inode->i_op;
907 + error = op->link_raw(&old_nd, &nd);
908 + /* the file system wants to use normal vfs path now */
909 + if (error != -EOPNOTSUPP)
912 + new_dentry = lookup_create(&nd, 0, NULL);
913 error = PTR_ERR(new_dentry);
914 if (!IS_ERR(new_dentry)) {
915 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
916 @@ -1698,7 +1902,7 @@ exit:
919 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
920 - struct inode *new_dir, struct dentry *new_dentry)
921 + struct inode *new_dir, struct dentry *new_dentry)
924 struct inode *target;
925 @@ -1777,7 +1981,7 @@ out_unlock:
928 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
929 - struct inode *new_dir, struct dentry *new_dentry)
930 + struct inode *new_dir, struct dentry *new_dentry)
934 @@ -1865,9 +2069,18 @@ static inline int do_rename(const char *
935 if (newnd.last_type != LAST_NORM)
938 + if (old_dir->d_inode->i_op->rename_raw) {
940 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
942 + /* the file system wants to use normal vfs path now */
943 + if (error != -EOPNOTSUPP)
947 double_lock(new_dir, old_dir);
949 - old_dentry = lookup_hash(&oldnd.last, old_dir);
950 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
951 error = PTR_ERR(old_dentry);
952 if (IS_ERR(old_dentry))
954 @@ -1883,16 +2096,16 @@ static inline int do_rename(const char *
955 if (newnd.last.name[newnd.last.len])
958 - new_dentry = lookup_hash(&newnd.last, new_dir);
959 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
960 error = PTR_ERR(new_dentry);
961 if (IS_ERR(new_dentry))
966 error = vfs_rename(old_dir->d_inode, old_dentry,
967 new_dir->d_inode, new_dentry);
973 @@ -1943,12 +2156,17 @@ out:
977 -__vfs_follow_link(struct nameidata *nd, const char *link)
978 +__vfs_follow_link(struct nameidata *nd, const char *link,
979 + struct lookup_intent *it)
987 + else if (it != nd->intent)
988 + printk("it != nd->intent: tell phil@clusterfs.com\n");
992 @@ -1956,7 +2174,7 @@ __vfs_follow_link(struct nameidata *nd,
993 /* weird __emul_prefix() stuff did it */
996 - res = link_path_walk(link, nd);
997 + res = link_path_walk_it(link, nd, it);
999 if (current->link_count || res || nd->last_type!=LAST_NORM)
1001 @@ -1978,7 +2196,13 @@ fail:
1003 int vfs_follow_link(struct nameidata *nd, const char *link)
1005 - return __vfs_follow_link(nd, link);
1006 + return __vfs_follow_link(nd, link, NULL);
1009 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
1010 + struct lookup_intent *it)
1012 + return __vfs_follow_link(nd, link, it);
1015 /* get the link contents into pagecache */
1016 @@ -2020,7 +2244,7 @@ int page_follow_link(struct dentry *dent
1018 struct page *page = NULL;
1019 char *s = page_getlink(dentry, &page);
1020 - int res = __vfs_follow_link(nd, s);
1021 + int res = __vfs_follow_link(nd, s, NULL);
1024 page_cache_release(page);
1025 --- linux-2.4.18-chaos/fs/open.c~vfs_intent-2.4.18-18-chaos65 2003-07-28 17:52:06.000000000 +0400
1026 +++ linux-2.4.18-chaos-alexey/fs/open.c 2003-09-14 17:25:41.000000000 +0400
1028 #include <asm/uaccess.h>
1030 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1031 +extern int path_walk_it(const char *name, struct nameidata *nd,
1032 + struct lookup_intent *it);
1034 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1036 @@ -95,9 +97,10 @@ void fd_install(unsigned int fd, struct
1037 write_unlock(&files->file_lock);
1040 -int do_truncate(struct dentry *dentry, loff_t length)
1041 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1043 struct inode *inode = dentry->d_inode;
1044 + struct inode_operations *op = dentry->d_inode->i_op;
1046 struct iattr newattrs;
1048 @@ -108,7 +111,13 @@ int do_truncate(struct dentry *dentry, l
1049 down(&inode->i_sem);
1050 newattrs.ia_size = length;
1051 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1052 - error = notify_change(dentry, &newattrs);
1053 + if (called_from_open)
1054 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1055 + if (op->setattr_raw) {
1056 + newattrs.ia_valid |= ATTR_RAW;
1057 + error = op->setattr_raw(inode, &newattrs);
1059 + error = notify_change(dentry, &newattrs);
1063 @@ -118,12 +127,13 @@ static inline long do_sys_truncate(const
1064 struct nameidata nd;
1065 struct inode * inode;
1067 + struct lookup_intent it = { .it_op = IT_GETATTR };
1070 if (length < 0) /* sorry, but loff_t says... */
1073 - error = user_path_walk(path, &nd);
1074 + error = user_path_walk_it(path, &nd, &it);
1077 inode = nd.dentry->d_inode;
1078 @@ -163,11 +173,13 @@ static inline long do_sys_truncate(const
1079 error = locks_verify_truncate(inode, NULL, length);
1082 - error = do_truncate(nd.dentry, length);
1083 + intent_release(&it);
1084 + error = do_truncate(nd.dentry, length, 0);
1086 put_write_access(inode);
1089 + intent_release(&it);
1093 @@ -215,7 +227,7 @@ static inline long do_sys_ftruncate(unsi
1095 error = locks_verify_truncate(inode, file, length);
1097 - error = do_truncate(dentry, length);
1098 + error = do_truncate(dentry, length, 0);
1102 @@ -260,11 +272,13 @@ asmlinkage long sys_utime(char * filenam
1103 struct inode * inode;
1104 struct iattr newattrs;
1106 - error = user_path_walk(filename, &nd);
1107 + error = user_path_walk_it(filename, &nd, NULL);
1110 inode = nd.dentry->d_inode;
1112 + /* this is safe without a Lustre lock because it only depends
1113 + on the super block */
1115 if (IS_RDONLY(inode))
1117 @@ -279,11 +293,25 @@ asmlinkage long sys_utime(char * filenam
1120 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1124 + if (inode->i_op->setattr_raw) {
1125 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1127 + newattrs.ia_valid |= ATTR_RAW;
1128 + error = op->setattr_raw(inode, &newattrs);
1129 + /* the file system wants to use normal vfs path now */
1130 + if (error != -EOPNOTSUPP)
1131 + goto dput_and_out;
1136 if (current->fsuid != inode->i_uid &&
1137 (error = permission(inode,MAY_WRITE)) != 0)
1141 error = notify_change(nd.dentry, &newattrs);
1144 @@ -304,12 +332,14 @@ asmlinkage long sys_utimes(char * filena
1145 struct inode * inode;
1146 struct iattr newattrs;
1148 - error = user_path_walk(filename, &nd);
1149 + error = user_path_walk_it(filename, &nd, NULL);
1153 inode = nd.dentry->d_inode;
1155 + /* this is safe without a Lustre lock because it only depends
1156 + on the super block */
1158 if (IS_RDONLY(inode))
1160 @@ -324,7 +354,20 @@ asmlinkage long sys_utimes(char * filena
1161 newattrs.ia_atime = times[0].tv_sec;
1162 newattrs.ia_mtime = times[1].tv_sec;
1163 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1167 + if (inode->i_op->setattr_raw) {
1168 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1170 + newattrs.ia_valid |= ATTR_RAW;
1171 + error = op->setattr_raw(inode, &newattrs);
1172 + /* the file system wants to use normal vfs path now */
1173 + if (error != -EOPNOTSUPP)
1174 + goto dput_and_out;
1179 if (current->fsuid != inode->i_uid &&
1180 (error = permission(inode,MAY_WRITE)) != 0)
1182 @@ -347,6 +390,7 @@ asmlinkage long sys_access(const char *
1183 int old_fsuid, old_fsgid;
1184 kernel_cap_t old_cap;
1186 + struct lookup_intent it = { .it_op = IT_GETATTR };
1188 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1190 @@ -364,13 +408,14 @@ asmlinkage long sys_access(const char *
1192 current->cap_effective = current->cap_permitted;
1194 - res = user_path_walk(filename, &nd);
1195 + res = user_path_walk_it(filename, &nd, &it);
1197 res = permission(nd.dentry->d_inode, mode);
1198 /* SuS v2 requires we report a read only fs too */
1199 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1200 && !special_file(nd.dentry->d_inode->i_mode))
1202 + intent_release(&it);
1206 @@ -385,8 +430,11 @@ asmlinkage long sys_chdir(const char * f
1209 struct nameidata nd;
1210 + struct lookup_intent it = { .it_op = IT_GETATTR };
1212 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1213 + error = __user_walk_it(filename,
1214 + LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,
1219 @@ -397,6 +445,7 @@ asmlinkage long sys_chdir(const char * f
1220 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1223 + intent_release(&it);
1227 @@ -436,9 +485,10 @@ asmlinkage long sys_chroot(const char *
1230 struct nameidata nd;
1231 + struct lookup_intent it = { .it_op = IT_GETATTR };
1233 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1234 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1235 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1236 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1240 @@ -454,39 +504,56 @@ asmlinkage long sys_chroot(const char *
1244 + intent_release(&it);
1250 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1251 +int chmod_common(struct dentry *dentry, mode_t mode)
1253 - struct inode * inode;
1254 - struct dentry * dentry;
1255 - struct file * file;
1257 + struct inode *inode = dentry->d_inode;
1258 struct iattr newattrs;
1263 + if (IS_RDONLY(inode))
1266 - dentry = file->f_dentry;
1267 - inode = dentry->d_inode;
1268 + if (inode->i_op->setattr_raw) {
1269 + newattrs.ia_mode = mode;
1270 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1271 + newattrs.ia_valid |= ATTR_RAW;
1272 + err = inode->i_op->setattr_raw(inode, &newattrs);
1273 + /* the file system wants to use normal vfs path now */
1274 + if (err != -EOPNOTSUPP)
1279 - if (IS_RDONLY(inode))
1282 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1286 if (mode == (mode_t) -1)
1287 mode = inode->i_mode;
1288 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1289 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1290 err = notify_change(dentry, &newattrs);
1297 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1299 + struct file * file;
1306 + err = chmod_common(file->f_dentry, mode);
1311 @@ -495,30 +562,14 @@ out:
1312 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1314 struct nameidata nd;
1315 - struct inode * inode;
1317 - struct iattr newattrs;
1319 error = user_path_walk(filename, &nd);
1322 - inode = nd.dentry->d_inode;
1325 - if (IS_RDONLY(inode))
1326 - goto dput_and_out;
1329 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1330 - goto dput_and_out;
1332 - if (mode == (mode_t) -1)
1333 - mode = inode->i_mode;
1334 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1335 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1336 - error = notify_change(nd.dentry, &newattrs);
1337 + error = chmod_common(nd.dentry, mode);
1343 @@ -538,6 +589,20 @@ static int chown_common(struct dentry *
1345 if (IS_RDONLY(inode))
1348 + if (inode->i_op->setattr_raw) {
1349 + struct inode_operations *op = dentry->d_inode->i_op;
1351 + newattrs.ia_uid = user;
1352 + newattrs.ia_gid = group;
1353 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1354 + newattrs.ia_valid |= ATTR_RAW;
1355 + error = op->setattr_raw(inode, &newattrs);
1356 + /* the file system wants to use normal vfs path now */
1357 + if (error != -EOPNOTSUPP)
1362 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1364 @@ -628,7 +693,8 @@ extern ssize_t do_readahead(struct file
1365 /* for files over a certains size it doesn't pay to do readahead on open */
1366 #define READAHEAD_CUTOFF 48000
1368 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1369 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1370 + int flags, struct lookup_intent *it)
1373 struct inode *inode;
1374 @@ -649,7 +715,7 @@ struct file *dentry_open(struct dentry *
1375 error = locks_verify_locked(inode);
1378 - error = do_truncate(dentry, 0);
1379 + error = do_truncate(dentry, 0, 1);
1381 if (error || !(f->f_mode & FMODE_WRITE))
1382 put_write_access(inode);
1383 @@ -679,7 +745,9 @@ struct file *dentry_open(struct dentry *
1386 if (f->f_op && f->f_op->open) {
1388 error = f->f_op->open(inode,f);
1393 @@ -693,6 +761,7 @@ struct file *dentry_open(struct dentry *
1394 do_readahead(f, 0, (48 * 1024) >> PAGE_SHIFT);
1397 + intent_release(it);
1401 @@ -707,11 +776,17 @@ cleanup_all:
1405 + intent_release(it);
1408 return ERR_PTR(error);
1411 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1413 + return dentry_open_it(dentry, mnt, flags, NULL);
1417 * Find an empty file descriptor entry, and mark it busy.
1419 --- linux-2.4.18-chaos/fs/stat.c~vfs_intent-2.4.18-18-chaos65 2003-07-28 17:52:06.000000000 +0400
1420 +++ linux-2.4.18-chaos-alexey/fs/stat.c 2003-09-14 17:30:21.000000000 +0400
1422 * Revalidate the inode. This is required for proper NFS attribute caching.
1424 static __inline__ int
1425 -do_revalidate(struct dentry *dentry)
1426 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1428 struct inode * inode = dentry->d_inode;
1429 - if (inode->i_op && inode->i_op->revalidate)
1432 + if (inode->i_op && inode->i_op->revalidate_it)
1433 + return inode->i_op->revalidate_it(dentry, it);
1434 + else if (inode->i_op && inode->i_op->revalidate)
1435 return inode->i_op->revalidate(dentry);
1439 -static int do_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
1440 +static int do_getattr(struct vfsmount *mnt, struct dentry *dentry,
1441 + struct kstat *stat, struct lookup_intent *it)
1444 unsigned int blocks, indirect;
1445 struct inode *inode = dentry->d_inode;
1447 - res = do_revalidate(dentry);
1448 + res = do_revalidate(dentry, it);
1452 @@ -104,10 +109,12 @@ int vfs_stat(char *name, struct kstat *s
1454 struct nameidata nd;
1456 + struct lookup_intent it = { .it_op = IT_GETATTR };
1458 - error = user_path_walk(name, &nd);
1459 + error = user_path_walk_it(name, &nd, &it);
1461 - error = do_getattr(nd.mnt, nd.dentry, stat);
1462 + error = do_getattr(nd.mnt, nd.dentry, stat, &it);
1463 + intent_release(&it);
1467 @@ -117,10 +124,12 @@ int vfs_lstat(char *name, struct kstat *
1469 struct nameidata nd;
1471 + struct lookup_intent it = { .it_op = IT_GETATTR };
1473 - error = user_path_walk_link(name, &nd);
1474 + error = user_path_walk_link_it(name, &nd, &it);
1476 - error = do_getattr(nd.mnt, nd.dentry, stat);
1477 + error = do_getattr(nd.mnt, nd.dentry, stat, &it);
1478 + intent_release(&it);
1482 @@ -132,7 +141,7 @@ int vfs_fstat(unsigned int fd, struct ks
1486 - error = do_getattr(f->f_vfsmnt, f->f_dentry, stat);
1487 + error = do_getattr(f->f_vfsmnt, f->f_dentry, stat, NULL);
1491 @@ -279,7 +288,7 @@ asmlinkage long sys_readlink(const char
1494 if (inode->i_op && inode->i_op->readlink &&
1495 - !(error = do_revalidate(nd.dentry))) {
1496 + !(error = do_revalidate(nd.dentry, NULL))) {
1497 UPDATE_ATIME(inode);
1498 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1500 --- linux-2.4.18-chaos/include/linux/dcache.h~vfs_intent-2.4.18-18-chaos65 2003-07-28 17:52:16.000000000 +0400
1501 +++ linux-2.4.18-chaos-alexey/include/linux/dcache.h 2003-09-14 17:25:41.000000000 +0400
1504 #include <asm/atomic.h>
1505 #include <linux/mount.h>
1506 +#include <linux/string.h>
1508 +#define IT_OPEN 0x0001
1509 +#define IT_CREAT 0x0002
1510 +#define IT_READDIR 0x0004
1511 +#define IT_GETATTR 0x0008
1512 +#define IT_LOOKUP 0x0010
1513 +#define IT_UNLINK 0x0020
1514 +#define IT_GETXATTR 0x0040
1515 +#define IT_EXEC 0x0080
1516 +#define IT_PIN 0x0100
1518 +#define IT_FL_LOCKED 0x0001
1519 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1521 +#define INTENT_MAGIC 0x19620323
1524 +struct lustre_intent_data {
1525 + int it_disposition;
1527 + __u64 it_lock_handle;
1532 +struct lookup_intent {
1534 + void (*it_op_release)(struct lookup_intent *);
1537 + int it_create_mode;
1539 + struct lustre_intent_data lustre;
1543 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1545 + memset(it, 0, sizeof(*it));
1546 + it->it_magic = INTENT_MAGIC;
1548 + it->it_flags = flags;
1553 * linux/include/linux/dcache.h
1554 @@ -91,8 +136,22 @@ struct dentry_operations {
1555 int (*d_delete)(struct dentry *);
1556 void (*d_release)(struct dentry *);
1557 void (*d_iput)(struct dentry *, struct inode *);
1558 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1559 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1560 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1563 +#define PIN(de,mnt,flag) if (de->d_op && de->d_op->d_pin) \
1564 + de->d_op->d_pin(de, mnt, flag);
1565 +#define UNPIN(de,mnt,flag) if (de->d_op && de->d_op->d_unpin) \
1566 + de->d_op->d_unpin(de, mnt, flag);
1569 +/* defined in fs/namei.c */
1570 +extern void intent_release(struct lookup_intent *it);
1571 +/* defined in fs/dcache.c */
1572 +extern void __d_rehash(struct dentry * entry, int lock);
1574 /* the dentry parameter passed to d_hash and d_compare is the parent
1575 * directory of the entries to be compared. It is used in case these
1576 * functions need any directory specific information for determining
1577 @@ -124,6 +183,7 @@ d_iput: no no yes
1578 * s_nfsd_free_path semaphore will be down
1580 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1581 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1583 extern spinlock_t dcache_lock;
1585 --- linux-2.4.18-chaos/include/linux/fs.h~vfs_intent-2.4.18-18-chaos65 2003-09-14 17:24:21.000000000 +0400
1586 +++ linux-2.4.18-chaos-alexey/include/linux/fs.h 2003-09-14 17:25:41.000000000 +0400
1587 @@ -73,6 +73,7 @@ extern int leases_enable, dir_notify_ena
1589 #define FMODE_READ 1
1590 #define FMODE_WRITE 2
1591 +#define FMODE_EXEC 4
1595 @@ -339,6 +340,9 @@ extern void set_bh_page(struct buffer_he
1596 #define ATTR_MTIME_SET 256
1597 #define ATTR_FORCE 512 /* Not a change, but a change it */
1598 #define ATTR_ATTR_FLAG 1024
1599 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1600 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1601 +#define ATTR_CTIME_SET 0x2000 /* called from open path, ie O_TRUNC */
1604 * This is the Inode Attributes structure, used for notify_change(). It
1605 @@ -474,6 +478,7 @@ struct inode {
1606 struct pipe_inode_info *i_pipe;
1607 struct block_device *i_bdev;
1608 struct char_device *i_cdev;
1609 + void *i_filterdata;
1611 unsigned long i_dnotify_mask; /* Directory notify events */
1612 struct dnotify_struct *i_dnotify; /* for directory notifications */
1613 @@ -578,6 +583,7 @@ struct file {
1615 /* needed for tty driver, and maybe others */
1617 + struct lookup_intent *f_it;
1619 /* preallocated helper kiobuf to speedup O_DIRECT */
1620 struct kiobuf *f_iobuf;
1621 @@ -707,6 +713,7 @@ struct nameidata {
1625 + struct lookup_intent *intent;
1628 #define DQUOT_USR_ENABLED 0x01 /* User diskquotas enabled */
1629 @@ -840,7 +847,8 @@ extern int vfs_symlink(struct inode *, s
1630 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1631 extern int vfs_rmdir(struct inode *, struct dentry *);
1632 extern int vfs_unlink(struct inode *, struct dentry *);
1633 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1634 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1635 + struct inode *new_dir, struct dentry *new_dentry);
1639 @@ -900,21 +908,34 @@ struct file_operations {
1641 struct inode_operations {
1642 int (*create) (struct inode *,struct dentry *,int);
1643 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1644 struct dentry * (*lookup) (struct inode *,struct dentry *);
1645 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1646 int (*link) (struct dentry *,struct inode *,struct dentry *);
1647 + int (*link_raw) (struct nameidata *,struct nameidata *);
1648 int (*unlink) (struct inode *,struct dentry *);
1649 + int (*unlink_raw) (struct nameidata *);
1650 int (*symlink) (struct inode *,struct dentry *,const char *);
1651 + int (*symlink_raw) (struct nameidata *,const char *);
1652 int (*mkdir) (struct inode *,struct dentry *,int);
1653 + int (*mkdir_raw) (struct nameidata *,int);
1654 int (*rmdir) (struct inode *,struct dentry *);
1655 + int (*rmdir_raw) (struct nameidata *);
1656 int (*mknod) (struct inode *,struct dentry *,int,int);
1657 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1658 int (*rename) (struct inode *, struct dentry *,
1659 struct inode *, struct dentry *);
1660 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1661 int (*readlink) (struct dentry *, char *,int);
1662 int (*follow_link) (struct dentry *, struct nameidata *);
1663 + int (*follow_link2) (struct dentry *, struct nameidata *,
1664 + struct lookup_intent *it);
1665 void (*truncate) (struct inode *);
1666 int (*permission) (struct inode *, int);
1667 int (*revalidate) (struct dentry *);
1668 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1669 int (*setattr) (struct dentry *, struct iattr *);
1670 + int (*setattr_raw) (struct inode *, struct iattr *);
1671 int (*getattr) (struct dentry *, struct iattr *);
1674 @@ -1119,10 +1140,12 @@ static inline int get_lease(struct inode
1676 asmlinkage long sys_open(const char *, int, int);
1677 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1678 -extern int do_truncate(struct dentry *, loff_t start);
1679 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1681 extern struct file *filp_open(const char *, int, int);
1682 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1683 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1684 + int flags, struct lookup_intent *it);
1685 extern int filp_close(struct file *, fl_owner_t id);
1686 extern char * getname(const char *);
1688 @@ -1388,9 +1411,12 @@ typedef int (*read_actor_t)(read_descrip
1689 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1691 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1692 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1693 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1694 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1695 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1696 +extern int FASTCALL(path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
1697 + struct lookup_intent *it));
1698 extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
1699 extern void path_release(struct nameidata *);
1700 extern int follow_down(struct vfsmount **, struct dentry **);
1701 @@ -1399,6 +1425,8 @@ extern struct dentry * lookup_one_len(co
1702 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1703 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1704 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1705 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1706 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1708 extern void inode_init_once(struct inode *);
1709 extern void iput(struct inode *);
1710 @@ -1499,6 +1527,8 @@ extern struct file_operations generic_ro
1712 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1713 extern int vfs_follow_link(struct nameidata *, const char *);
1714 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1715 + struct lookup_intent *it);
1716 extern int page_readlink(struct dentry *, char *, int);
1717 extern int page_follow_link(struct dentry *, struct nameidata *);
1718 extern struct inode_operations page_symlink_inode_operations;
1719 --- linux-2.4.18-chaos/kernel/fork.c~vfs_intent-2.4.18-18-chaos65 2003-07-28 17:52:20.000000000 +0400
1720 +++ linux-2.4.18-chaos-alexey/kernel/fork.c 2003-09-14 17:25:41.000000000 +0400
1721 @@ -399,10 +399,13 @@ static inline struct fs_struct *__copy_f
1722 fs->umask = old->umask;
1723 read_lock(&old->lock);
1724 fs->rootmnt = mntget(old->rootmnt);
1725 + PIN(old->pwd, old->pwdmnt, 0);
1726 + PIN(old->root, old->rootmnt, 1);
1727 fs->root = dget(old->root);
1728 fs->pwdmnt = mntget(old->pwdmnt);
1729 fs->pwd = dget(old->pwd);
1731 + PIN(old->altroot, old->altrootmnt, 1);
1732 fs->altrootmnt = mntget(old->altrootmnt);
1733 fs->altroot = dget(old->altroot);
1735 --- linux-2.4.18-chaos/kernel/exit.c~vfs_intent-2.4.18-18-chaos65 2003-07-28 17:52:20.000000000 +0400
1736 +++ linux-2.4.18-chaos-alexey/kernel/exit.c 2003-09-14 17:25:41.000000000 +0400
1737 @@ -303,11 +303,14 @@ static inline void __put_fs_struct(struc
1739 /* No need to hold fs->lock if we are killing it */
1740 if (atomic_dec_and_test(&fs->count)) {
1741 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1742 + UNPIN(fs->root, fs->rootmnt, 1);
1744 mntput(fs->rootmnt);
1748 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1750 mntput(fs->altrootmnt);
1752 --- linux-2.4.18-chaos/kernel/ksyms.c~vfs_intent-2.4.18-18-chaos65 2003-09-14 17:24:22.000000000 +0400
1753 +++ linux-2.4.18-chaos-alexey/kernel/ksyms.c 2003-09-14 17:25:41.000000000 +0400
1754 @@ -294,6 +294,7 @@ EXPORT_SYMBOL(read_cache_page);
1755 EXPORT_SYMBOL(set_page_dirty);
1756 EXPORT_SYMBOL(vfs_readlink);
1757 EXPORT_SYMBOL(vfs_follow_link);
1758 +EXPORT_SYMBOL(vfs_follow_link_it);
1759 EXPORT_SYMBOL(page_readlink);
1760 EXPORT_SYMBOL(page_follow_link);
1761 EXPORT_SYMBOL(page_symlink_inode_operations);