3 fs/namei.c | 295 +++++++++++++++++++++++++++++++++++++++-------
4 fs/namespace.c | 28 +++-
5 fs/open.c | 172 +++++++++++++++++++-------
6 fs/stat.c | 52 +++++---
7 include/linux/dcache.h | 60 +++++++++
8 include/linux/fs.h | 32 ++++
9 include/linux/fs_struct.h | 4
13 12 files changed, 558 insertions(+), 128 deletions(-)
15 Index: linux-2.4.21-chaos/fs/dcache.c
16 ===================================================================
17 --- linux-2.4.21-chaos.orig/fs/dcache.c 2003-09-19 03:49:54.000000000 +0400
18 +++ linux-2.4.21-chaos/fs/dcache.c 2003-12-12 17:02:47.000000000 +0300
20 spin_unlock(&dcache_lock);
24 + /* network invalidation by Lustre */
25 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
26 + spin_unlock(&dcache_lock);
31 * Check whether to do a partial shrink_dcache
32 * to get rid of unused child entries.
34 * Adds a dentry to the hash according to its name.
37 -void d_rehash(struct dentry * entry)
38 +void __d_rehash(struct dentry * entry, int lock)
40 struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
41 if (!list_empty(&entry->d_hash)) BUG();
42 - spin_lock(&dcache_lock);
43 + if (lock) spin_lock(&dcache_lock);
44 list_add(&entry->d_hash, list);
45 - spin_unlock(&dcache_lock);
46 + if (lock) spin_unlock(&dcache_lock);
48 +EXPORT_SYMBOL(__d_rehash);
50 +void d_rehash(struct dentry * entry)
52 + __d_rehash(entry, 1);
55 #define do_switch(x,y) do { \
56 Index: linux-2.4.21-chaos/fs/exec.c
57 ===================================================================
58 --- linux-2.4.21-chaos.orig/fs/exec.c 2003-12-05 07:55:47.000000000 +0300
59 +++ linux-2.4.21-chaos/fs/exec.c 2003-12-12 17:02:47.000000000 +0300
64 + struct lookup_intent it = { .it_op = IT_OPEN,
65 + .it_flags = FMODE_READ|FMODE_EXEC };
67 - error = user_path_walk(library, &nd);
68 + error = user_path_walk_it(library, &nd, &it);
76 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
77 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
78 + intent_release(&it);
79 error = PTR_ERR(file);
86 + struct lookup_intent it = { .it_op = IT_OPEN,
87 + .it_flags = FMODE_READ|FMODE_EXEC };
89 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
90 + err = path_lookup_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
93 inode = nd.dentry->d_inode;
98 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
99 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
100 + intent_release(&it);
102 err = deny_write_access(file);
108 + intent_release(&it);
112 @@ -1348,7 +1355,7 @@
114 if (!file->f_op->write)
116 - if (do_truncate(file->f_dentry, 0) != 0)
117 + if (do_truncate(file->f_dentry, 0, 0) != 0)
120 retval = binfmt->core_dump(signr, regs, file);
121 Index: linux-2.4.21-chaos/fs/namei.c
122 ===================================================================
123 --- linux-2.4.21-chaos.orig/fs/namei.c 2003-07-15 04:41:01.000000000 +0400
124 +++ linux-2.4.21-chaos/fs/namei.c 2003-12-12 17:03:37.000000000 +0300
126 * XEmacs seems to be relying on it...
129 +void intent_release(struct lookup_intent *it)
131 + if (it && it->it_op_release)
132 + it->it_op_release(it);
136 /* In order to reduce some races, while at the same time doing additional
137 * checking and hopefully speeding things up, we copy filenames to the
138 * kernel data space before using them..
139 @@ -260,10 +267,19 @@
140 * Internal lookup() using the new generic dcache.
143 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
144 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
145 + int flags, struct lookup_intent *it)
147 struct dentry * dentry = d_lookup(parent, name);
149 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
150 + if (!dentry->d_op->d_revalidate_it(dentry, flags, it) &&
151 + !d_invalidate(dentry)) {
157 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
158 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
160 @@ -281,11 +297,15 @@
161 * make sure that nobody added the entry to the dcache in the meantime..
164 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
165 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
166 + int flags, struct lookup_intent *it)
168 struct dentry * result;
169 struct inode *dir = parent->d_inode;
176 * First re-do the cached lookup just in case it was created
178 result = ERR_PTR(-ENOMEM);
181 + if (dir->i_op->lookup_it)
182 + result = dir->i_op->lookup_it(dir, dentry, it, flags);
184 result = dir->i_op->lookup(dir, dentry);
189 result = ERR_PTR(-ENOENT);
191 + } else if (result->d_op && result->d_op->d_revalidate_it) {
192 + if (!result->d_op->d_revalidate_it(result, flags, it) &&
193 + !d_invalidate(result)) {
196 + result = ERR_PTR(-ESTALE);
197 + if (!IS_ERR(result))
204 * Without that kind of total limit, nasty chains of consecutive
205 * symlinks can cause almost arbitrarily long lookups.
207 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
208 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
209 + struct lookup_intent *it)
212 if (current->link_count >= 8)
213 @@ -346,10 +379,12 @@
214 current->link_count++;
215 current->total_link_count++;
216 UPDATE_ATIME(dentry->d_inode);
218 err = dentry->d_inode->i_op->follow_link(dentry, nd);
219 current->link_count--;
222 + intent_release(it);
228 * We expect 'base' to be positive and a directory.
230 -int link_path_walk(const char * name, struct nameidata *nd)
231 +int link_path_walk_it(const char *name, struct nameidata *nd,
232 + struct lookup_intent *it)
234 struct dentry *dentry;
236 @@ -524,12 +560,12 @@
239 /* This does the actual lookups.. */
240 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
241 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
243 err = -EWOULDBLOCKIO;
246 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
247 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
248 err = PTR_ERR(dentry);
254 if (inode->i_op->follow_link) {
255 - err = do_follow_link(dentry, nd);
256 + err = do_follow_link(dentry, nd, NULL);
264 - if (!inode->i_op->lookup)
265 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
268 /* here ends the main loop */
269 @@ -590,12 +626,12 @@
273 - dentry = cached_lookup(nd->dentry, &this, 0);
274 + dentry = cached_lookup(nd->dentry, &this, 0, it);
276 err = -EWOULDBLOCKIO;
279 - dentry = real_lookup(nd->dentry, &this, 0);
280 + dentry = real_lookup(nd->dentry, &this, 0, it);
281 err = PTR_ERR(dentry);
285 inode = dentry->d_inode;
286 if ((lookup_flags & LOOKUP_FOLLOW)
287 && inode && inode->i_op && inode->i_op->follow_link) {
288 - err = do_follow_link(dentry, nd);
289 + err = do_follow_link(dentry, nd, it);
295 if (lookup_flags & LOOKUP_DIRECTORY) {
297 - if (!inode->i_op || !inode->i_op->lookup)
298 + if (!inode->i_op ||
299 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
304 * Check the cached dentry for staleness.
307 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
309 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
310 + struct dentry *new;
311 + err = permission(dentry->d_parent->d_inode,
315 + new = real_lookup(dentry->d_parent,
316 + &dentry->d_name, 0, NULL);
317 + d_invalidate(dentry);
320 + err = PTR_ERR(new);
326 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
328 if (!dentry->d_op->d_revalidate(dentry, 0)) {
329 @@ -656,15 +712,28 @@
334 + intent_release(it);
340 +int link_path_walk(const char * name, struct nameidata *nd)
342 + return link_path_walk_it(name, nd, NULL);
345 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
347 + current->total_link_count = 0;
348 + return link_path_walk_it(name, nd, it);
351 int path_walk(const char * name, struct nameidata *nd)
353 current->total_link_count = 0;
354 - return link_path_walk(name, nd);
355 + return link_path_walk_it(name, nd, NULL);
363 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
364 + struct lookup_intent *it)
367 + if (path_init(path, flags, nd))
368 + error = path_walk_it(path, nd, it);
374 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
379 nd->last_type = LAST_ROOT; /* if there are only slashes... */
383 return walk_init_root(name,nd);
384 read_lock(¤t->fs->lock);
386 * needs parent already locked. Doesn't follow mounts.
389 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
390 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
391 + struct lookup_intent *it)
393 struct dentry * dentry;
395 @@ -800,13 +882,16 @@
399 - dentry = cached_lookup(base, name, 0);
400 + dentry = cached_lookup(base, name, 0, it);
402 struct dentry *new = d_alloc(base, name);
403 dentry = ERR_PTR(-ENOMEM);
407 + if (inode->i_op->lookup_it)
408 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
410 dentry = inode->i_op->lookup(inode, new);
417 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
419 + return lookup_hash_it(name, base, NULL);
424 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
428 this.hash = end_name_hash(hash);
430 - return lookup_hash(&this, base);
431 + return lookup_hash_it(&this, base, NULL);
433 return ERR_PTR(-EACCES);
439 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
440 + struct lookup_intent *it)
445 + tmp = getname(name);
446 + err = PTR_ERR(tmp);
447 + if (!IS_ERR(tmp)) {
449 + if (path_init(tmp, flags, nd))
450 + err = path_walk_it(tmp, nd, it);
457 * It's inline, so penalty for filesystems that don't use sticky bit is
463 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
464 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
465 + struct lookup_intent *it)
469 @@ -980,12 +1089,15 @@
472 error = -EACCES; /* shouldn't it be ENOSYS? */
473 - if (!dir->i_op || !dir->i_op->create)
474 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
479 - error = dir->i_op->create(dir, dentry, mode);
480 + if (dir->i_op->create_it)
481 + error = dir->i_op->create_it(dir, dentry, mode, it);
483 + error = dir->i_op->create(dir, dentry, mode);
487 @@ -994,6 +1106,11 @@
491 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
493 + return vfs_create_it(dir, dentry, mode, NULL);
499 @@ -1008,7 +1125,8 @@
500 * for symlinks (where the permissions are checked later).
503 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
504 +int open_namei_it(const char *pathname, int flag, int mode,
505 + struct nameidata *nd, struct lookup_intent *it)
507 int acc_mode, error = 0;
509 @@ -1018,11 +1136,14 @@
511 acc_mode = ACC_MODE(flag);
514 + it->it_flags = flag;
517 * The simplest case - just a plain lookup.
519 if (!(flag & O_CREAT)) {
520 - error = path_lookup(pathname, lookup_flags(flag), nd);
521 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
525 @@ -1032,6 +1153,10 @@
527 * Create - we need to know the parent.
530 + it->it_create_mode = mode;
531 + it->it_op |= IT_CREAT;
533 error = path_lookup(pathname, LOOKUP_PARENT, nd);
536 @@ -1047,7 +1172,7 @@
539 down(&dir->d_inode->i_sem);
540 - dentry = lookup_hash(&nd->last, nd->dentry);
541 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
544 error = PTR_ERR(dentry);
545 @@ -1056,11 +1181,12 @@
549 + it->it_create_mode = mode;
550 /* Negative dentry, just create the file */
551 if (!dentry->d_inode) {
552 if (!IS_POSIXACL(dir->d_inode))
553 mode &= ~current->fs->umask;
554 - error = vfs_create(dir->d_inode, dentry, mode);
555 + error = vfs_create_it(dir->d_inode, dentry, mode, it);
556 up(&dir->d_inode->i_sem);
559 @@ -1164,7 +1290,7 @@
563 - error = do_truncate(dentry, 0);
564 + error = do_truncate(dentry, 0, 1);
566 put_write_access(inode);
568 @@ -1176,8 +1302,10 @@
572 + intent_release(it);
575 + intent_release(it);
579 @@ -1196,7 +1324,10 @@
580 * are done. Procfs-like symlinks just set LAST_BIND.
582 UPDATE_ATIME(dentry->d_inode);
584 error = dentry->d_inode->i_op->follow_link(dentry, nd);
586 + intent_release(it);
590 @@ -1218,13 +1349,20 @@
593 down(&dir->d_inode->i_sem);
594 - dentry = lookup_hash(&nd->last, nd->dentry);
595 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
596 putname(nd->last.name);
600 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
602 + return open_namei_it(pathname, flag, mode, nd, NULL);
607 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
608 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
609 + struct lookup_intent *it)
611 struct dentry *dentry;
613 @@ -1232,7 +1370,7 @@
614 dentry = ERR_PTR(-EEXIST);
615 if (nd->last_type != LAST_NORM)
617 - dentry = lookup_hash(&nd->last, nd->dentry);
618 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
621 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
622 @@ -1288,7 +1426,16 @@
623 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
626 - dentry = lookup_create(&nd, 0);
628 + if (nd.dentry->d_inode->i_op->mknod_raw) {
629 + struct inode_operations *op = nd.dentry->d_inode->i_op;
630 + error = op->mknod_raw(&nd, mode, dev);
631 + /* the file system wants to use normal vfs path now */
632 + if (error != -EOPNOTSUPP)
636 + dentry = lookup_create(&nd, 0, NULL);
637 error = PTR_ERR(dentry);
639 if (!IS_POSIXACL(nd.dentry->d_inode))
640 @@ -1310,6 +1457,7 @@
643 up(&nd.dentry->d_inode->i_sem);
648 @@ -1357,7 +1505,14 @@
649 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
652 - dentry = lookup_create(&nd, 1);
653 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
654 + struct inode_operations *op = nd.dentry->d_inode->i_op;
655 + error = op->mkdir_raw(&nd, mode);
656 + /* the file system wants to use normal vfs path now */
657 + if (error != -EOPNOTSUPP)
660 + dentry = lookup_create(&nd, 1, NULL);
661 error = PTR_ERR(dentry);
662 if (!IS_ERR(dentry)) {
663 if (!IS_POSIXACL(nd.dentry->d_inode))
664 @@ -1366,6 +1521,7 @@
667 up(&nd.dentry->d_inode->i_sem);
672 @@ -1466,8 +1622,16 @@
676 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
677 + struct inode_operations *op = nd.dentry->d_inode->i_op;
679 + error = op->rmdir_raw(&nd);
680 + /* the file system wants to use normal vfs path now */
681 + if (error != -EOPNOTSUPP)
684 down(&nd.dentry->d_inode->i_sem);
685 - dentry = lookup_hash(&nd.last, nd.dentry);
686 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
687 error = PTR_ERR(dentry);
688 if (!IS_ERR(dentry)) {
689 error = vfs_rmdir(nd.dentry->d_inode, dentry);
690 @@ -1525,8 +1689,15 @@
692 if (nd.last_type != LAST_NORM)
694 + if (nd.dentry->d_inode->i_op->unlink_raw) {
695 + struct inode_operations *op = nd.dentry->d_inode->i_op;
696 + error = op->unlink_raw(&nd);
697 + /* the file system wants to use normal vfs path now */
698 + if (error != -EOPNOTSUPP)
701 down(&nd.dentry->d_inode->i_sem);
702 - dentry = lookup_hash(&nd.last, nd.dentry);
703 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
704 error = PTR_ERR(dentry);
705 if (!IS_ERR(dentry)) {
706 /* Why not before? Because we want correct error value */
707 @@ -1593,15 +1764,23 @@
708 error = path_lookup(to, LOOKUP_PARENT, &nd);
711 - dentry = lookup_create(&nd, 0);
712 + if (nd.dentry->d_inode->i_op->symlink_raw) {
713 + struct inode_operations *op = nd.dentry->d_inode->i_op;
714 + error = op->symlink_raw(&nd, from);
715 + /* the file system wants to use normal vfs path now */
716 + if (error != -EOPNOTSUPP)
719 + dentry = lookup_create(&nd, 0, NULL);
720 error = PTR_ERR(dentry);
721 if (!IS_ERR(dentry)) {
722 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
725 up(&nd.dentry->d_inode->i_sem);
733 @@ -1677,7 +1856,14 @@
735 if (old_nd.mnt != nd.mnt)
737 - new_dentry = lookup_create(&nd, 0);
738 + if (nd.dentry->d_inode->i_op->link_raw) {
739 + struct inode_operations *op = nd.dentry->d_inode->i_op;
740 + error = op->link_raw(&old_nd, &nd);
741 + /* the file system wants to use normal vfs path now */
742 + if (error != -EOPNOTSUPP)
745 + new_dentry = lookup_create(&nd, 0, NULL);
746 error = PTR_ERR(new_dentry);
747 if (!IS_ERR(new_dentry)) {
748 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
749 @@ -1721,7 +1907,7 @@
752 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
753 - struct inode *new_dir, struct dentry *new_dentry)
754 + struct inode *new_dir, struct dentry *new_dentry)
757 struct inode *target;
758 @@ -1800,7 +1986,7 @@
761 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
762 - struct inode *new_dir, struct dentry *new_dentry)
763 + struct inode *new_dir, struct dentry *new_dentry)
767 @@ -1888,9 +2074,18 @@
768 if (newnd.last_type != LAST_NORM)
771 + if (old_dir->d_inode->i_op->rename_raw) {
773 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
775 + /* the file system wants to use normal vfs path now */
776 + if (error != -EOPNOTSUPP)
780 double_lock(new_dir, old_dir);
782 - old_dentry = lookup_hash(&oldnd.last, old_dir);
783 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
784 error = PTR_ERR(old_dentry);
785 if (IS_ERR(old_dentry))
787 @@ -1906,16 +2101,16 @@
788 if (newnd.last.name[newnd.last.len])
791 - new_dentry = lookup_hash(&newnd.last, new_dir);
792 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
793 error = PTR_ERR(new_dentry);
794 if (IS_ERR(new_dentry))
799 error = vfs_rename(old_dir->d_inode, old_dentry,
800 new_dir->d_inode, new_dentry);
806 @@ -1966,20 +2161,26 @@
810 -__vfs_follow_link(struct nameidata *nd, const char *link)
811 +__vfs_follow_link(struct nameidata *nd, const char *link,
812 + struct lookup_intent *it)
821 + else if (it != nd->intent)
822 + printk("it != nd->intent: tell phil@clusterfs.com\n");
826 if (!walk_init_root(link, nd))
827 /* weird __emul_prefix() stuff did it */
830 - res = link_path_walk(link, nd);
831 + res = link_path_walk_it(link, nd, it);
833 if (current->link_count || res || nd->last_type!=LAST_NORM)
835 @@ -2003,7 +2204,13 @@
837 int vfs_follow_link(struct nameidata *nd, const char *link)
839 - return __vfs_follow_link(nd, link);
840 + return __vfs_follow_link(nd, link, NULL);
843 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
844 + struct lookup_intent *it)
846 + return __vfs_follow_link(nd, link, it);
849 /* get the link contents into pagecache */
850 @@ -2045,7 +2252,7 @@
852 struct page *page = NULL;
853 char *s = page_getlink(dentry, &page);
854 - int res = __vfs_follow_link(nd, s);
855 + int res = __vfs_follow_link(nd, s, NULL);
858 page_cache_release(page);
859 Index: linux-2.4.21-chaos/fs/namespace.c
860 ===================================================================
861 --- linux-2.4.21-chaos.orig/fs/namespace.c 2003-07-15 04:41:01.000000000 +0400
862 +++ linux-2.4.21-chaos/fs/namespace.c 2003-12-12 17:02:47.000000000 +0300
865 old_nd->dentry = mnt->mnt_mountpoint;
866 old_nd->mnt = mnt->mnt_parent;
867 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
868 mnt->mnt_parent = mnt;
869 mnt->mnt_mountpoint = mnt->mnt_root;
870 list_del_init(&mnt->mnt_child);
873 mnt->mnt_parent = mntget(nd->mnt);
874 mnt->mnt_mountpoint = dget(nd->dentry);
875 + PIN(nd->dentry, nd->mnt, 1);
876 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
877 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
878 nd->dentry->d_mounted++;
879 @@ -488,14 +490,17 @@
881 struct nameidata old_nd;
882 struct vfsmount *mnt = NULL;
883 + struct lookup_intent it = { .it_op = IT_GETATTR };
884 int err = mount_is_safe(nd);
887 if (!old_name || !*old_name)
889 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
891 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
893 + intent_release(&it);
897 down_write(¤t->namespace->sem);
902 up_write(¤t->namespace->sem);
903 + intent_release(&it);
904 path_release(&old_nd);
908 unsigned long flags, void *data_page)
911 + struct lookup_intent it = { .it_op = IT_GETATTR };
915 @@ -725,10 +732,11 @@
916 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
918 /* ... and get the mountpoint */
919 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
921 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
923 + intent_release(&it);
927 if (flags & MS_REMOUNT)
928 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
932 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
933 dev_name, data_page);
935 + intent_release(&it);
941 struct vfsmount *tmp;
942 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
943 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
944 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
947 if (!capable(CAP_SYS_ADMIN))
948 @@ -911,14 +923,14 @@
952 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
953 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
957 if (!check_mnt(new_nd.mnt))
960 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
961 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
966 up(&old_nd.dentry->d_inode->i_zombie);
967 up_write(¤t->namespace->sem);
968 path_release(&user_nd);
969 + intent_release(&old_it);
970 path_release(&old_nd);
972 + intent_release(&new_it);
973 path_release(&new_nd);
976 Index: linux-2.4.21-chaos/fs/open.c
977 ===================================================================
978 --- linux-2.4.21-chaos.orig/fs/open.c 2003-07-15 04:41:01.000000000 +0400
979 +++ linux-2.4.21-chaos/fs/open.c 2003-12-12 17:02:47.000000000 +0300
981 #include <asm/uaccess.h>
983 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
984 +extern int path_walk_it(const char *name, struct nameidata *nd,
985 + struct lookup_intent *it);
987 int vfs_statfs(struct super_block *sb, struct statfs *buf)
990 write_unlock(&files->file_lock);
993 -int do_truncate(struct dentry *dentry, loff_t length)
994 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
996 struct inode *inode = dentry->d_inode;
997 + struct inode_operations *op = dentry->d_inode->i_op;
999 struct iattr newattrs;
1001 @@ -109,7 +112,13 @@
1002 down(&inode->i_sem);
1003 newattrs.ia_size = length;
1004 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1005 - error = notify_change(dentry, &newattrs);
1006 + if (called_from_open)
1007 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1008 + if (op->setattr_raw) {
1009 + newattrs.ia_valid |= ATTR_RAW;
1010 + error = op->setattr_raw(inode, &newattrs);
1012 + error = notify_change(dentry, &newattrs);
1014 up_write(&inode->i_alloc_sem);
1016 @@ -120,12 +129,13 @@
1017 struct nameidata nd;
1018 struct inode * inode;
1020 + struct lookup_intent it = { .it_op = IT_GETATTR };
1023 if (length < 0) /* sorry, but loff_t says... */
1026 - error = user_path_walk(path, &nd);
1027 + error = user_path_walk_it(path, &nd, &it);
1030 inode = nd.dentry->d_inode;
1031 @@ -165,11 +175,13 @@
1032 error = locks_verify_truncate(inode, NULL, length);
1035 - error = do_truncate(nd.dentry, length);
1036 + intent_release(&it);
1037 + error = do_truncate(nd.dentry, length, 0);
1039 put_write_access(inode);
1042 + intent_release(&it);
1048 error = locks_verify_truncate(inode, file, length);
1050 - error = do_truncate(dentry, length);
1051 + error = do_truncate(dentry, length, 0);
1055 @@ -262,11 +274,13 @@
1056 struct inode * inode;
1057 struct iattr newattrs;
1059 - error = user_path_walk(filename, &nd);
1060 + error = user_path_walk_it(filename, &nd, NULL);
1063 inode = nd.dentry->d_inode;
1065 + /* this is safe without a Lustre lock because it only depends
1066 + on the super block */
1068 if (IS_RDONLY(inode))
1070 @@ -281,11 +295,25 @@
1073 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1077 + if (inode->i_op->setattr_raw) {
1078 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1080 + newattrs.ia_valid |= ATTR_RAW;
1081 + error = op->setattr_raw(inode, &newattrs);
1082 + /* the file system wants to use normal vfs path now */
1083 + if (error != -EOPNOTSUPP)
1084 + goto dput_and_out;
1089 if (current->fsuid != inode->i_uid &&
1090 (error = permission(inode,MAY_WRITE)) != 0)
1094 error = notify_change(nd.dentry, &newattrs);
1097 @@ -306,12 +334,14 @@
1098 struct inode * inode;
1099 struct iattr newattrs;
1101 - error = user_path_walk(filename, &nd);
1102 + error = user_path_walk_it(filename, &nd, NULL);
1106 inode = nd.dentry->d_inode;
1108 + /* this is safe without a Lustre lock because it only depends
1109 + on the super block */
1111 if (IS_RDONLY(inode))
1113 @@ -326,7 +356,20 @@
1114 newattrs.ia_atime = times[0].tv_sec;
1115 newattrs.ia_mtime = times[1].tv_sec;
1116 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1120 + if (inode->i_op->setattr_raw) {
1121 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1123 + newattrs.ia_valid |= ATTR_RAW;
1124 + error = op->setattr_raw(inode, &newattrs);
1125 + /* the file system wants to use normal vfs path now */
1126 + if (error != -EOPNOTSUPP)
1127 + goto dput_and_out;
1132 if (current->fsuid != inode->i_uid &&
1133 (error = permission(inode,MAY_WRITE)) != 0)
1136 int old_fsuid, old_fsgid;
1137 kernel_cap_t old_cap;
1139 + struct lookup_intent it = { .it_op = IT_GETATTR };
1141 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1143 @@ -366,13 +410,14 @@
1145 current->cap_effective = current->cap_permitted;
1147 - res = user_path_walk(filename, &nd);
1148 + res = user_path_walk_it(filename, &nd, &it);
1150 res = permission(nd.dentry->d_inode, mode);
1151 /* SuS v2 requires we report a read only fs too */
1152 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1153 && !special_file(nd.dentry->d_inode->i_mode))
1155 + intent_release(&it);
1162 struct nameidata nd;
1163 + struct lookup_intent it = { .it_op = IT_GETATTR };
1165 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1166 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1171 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1174 + intent_release(&it);
1178 @@ -438,9 +485,10 @@
1181 struct nameidata nd;
1182 + struct lookup_intent it = { .it_op = IT_GETATTR };
1184 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1185 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1186 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1187 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1191 @@ -456,39 +504,56 @@
1195 + intent_release(&it);
1201 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1202 +int chmod_common(struct dentry *dentry, mode_t mode)
1204 - struct inode * inode;
1205 - struct dentry * dentry;
1206 - struct file * file;
1208 + struct inode *inode = dentry->d_inode;
1209 struct iattr newattrs;
1214 + if (IS_RDONLY(inode))
1217 - dentry = file->f_dentry;
1218 - inode = dentry->d_inode;
1219 + if (inode->i_op->setattr_raw) {
1220 + newattrs.ia_mode = mode;
1221 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1222 + newattrs.ia_valid |= ATTR_RAW;
1223 + err = inode->i_op->setattr_raw(inode, &newattrs);
1224 + /* the file system wants to use normal vfs path now */
1225 + if (err != -EOPNOTSUPP)
1230 - if (IS_RDONLY(inode))
1233 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1237 if (mode == (mode_t) -1)
1238 mode = inode->i_mode;
1239 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1240 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1241 err = notify_change(dentry, &newattrs);
1248 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1250 + struct file * file;
1257 + err = chmod_common(file->f_dentry, mode);
1262 @@ -497,30 +562,14 @@
1263 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1265 struct nameidata nd;
1266 - struct inode * inode;
1268 - struct iattr newattrs;
1270 error = user_path_walk(filename, &nd);
1273 - inode = nd.dentry->d_inode;
1276 - if (IS_RDONLY(inode))
1277 - goto dput_and_out;
1280 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1281 - goto dput_and_out;
1282 + error = chmod_common(nd.dentry, mode);
1284 - if (mode == (mode_t) -1)
1285 - mode = inode->i_mode;
1286 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1287 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1288 - error = notify_change(nd.dentry, &newattrs);
1294 @@ -540,6 +589,20 @@
1296 if (IS_RDONLY(inode))
1299 + if (inode->i_op->setattr_raw) {
1300 + struct inode_operations *op = dentry->d_inode->i_op;
1302 + newattrs.ia_uid = user;
1303 + newattrs.ia_gid = group;
1304 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1305 + newattrs.ia_valid |= ATTR_RAW;
1306 + error = op->setattr_raw(inode, &newattrs);
1307 + /* the file system wants to use normal vfs path now */
1308 + if (error != -EOPNOTSUPP)
1313 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1317 int namei_flags, error;
1318 struct nameidata nd;
1319 + struct lookup_intent it = { .it_op = IT_OPEN };
1321 namei_flags = flags;
1322 if ((namei_flags+1) & O_ACCMODE)
1323 @@ -651,14 +715,15 @@
1324 if (namei_flags & O_TRUNC)
1327 - error = open_namei(filename, namei_flags, mode, &nd);
1329 - return dentry_open(nd.dentry, nd.mnt, flags);
1330 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1332 + return ERR_PTR(error);
1334 - return ERR_PTR(error);
1335 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1338 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1339 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1340 + int flags, struct lookup_intent *it)
1343 struct inode *inode;
1347 if (f->f_op && f->f_op->open) {
1349 error = f->f_op->open(inode,f);
1355 inode->i_mapping->a_ops->direct_sector_IO)))
1358 + intent_release(it);
1362 @@ -722,11 +790,17 @@
1366 + intent_release(it);
1369 return ERR_PTR(error);
1372 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1374 + return dentry_open_it(dentry, mnt, flags, NULL);
1378 * Find an empty file descriptor entry, and mark it busy.
1380 Index: linux-2.4.21-chaos/fs/stat.c
1381 ===================================================================
1382 --- linux-2.4.21-chaos.orig/fs/stat.c 2003-09-19 03:49:54.000000000 +0400
1383 +++ linux-2.4.21-chaos/fs/stat.c 2003-12-12 17:02:47.000000000 +0300
1385 * Revalidate the inode. This is required for proper NFS attribute caching.
1387 static __inline__ int
1388 -do_revalidate(struct dentry *dentry)
1389 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1391 struct inode * inode = dentry->d_inode;
1392 - if (inode->i_op && inode->i_op->revalidate)
1395 + if (inode->i_op && inode->i_op->revalidate_it)
1396 + return inode->i_op->revalidate_it(dentry, it);
1397 + else if (inode->i_op && inode->i_op->revalidate)
1398 return inode->i_op->revalidate(dentry);
1401 @@ -143,13 +147,15 @@
1402 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1404 struct nameidata nd;
1405 + struct lookup_intent it = { .it_op = IT_GETATTR };
1408 - error = user_path_walk(filename, &nd);
1409 + error = user_path_walk_it(filename, &nd, &it);
1411 - error = do_revalidate(nd.dentry);
1412 + error = do_revalidate(nd.dentry, &it);
1414 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1415 + intent_release(&it);
1419 @@ -159,13 +165,15 @@
1420 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1422 struct nameidata nd;
1423 + struct lookup_intent it = { .it_op = IT_GETATTR };
1426 - error = user_path_walk(filename, &nd);
1427 + error = user_path_walk_it(filename, &nd, &it);
1429 - error = do_revalidate(nd.dentry);
1430 + error = do_revalidate(nd.dentry, &it);
1432 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1433 + intent_release(&it);
1437 @@ -180,13 +188,15 @@
1438 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1440 struct nameidata nd;
1441 + struct lookup_intent it = { .it_op = IT_GETATTR };
1444 - error = user_path_walk_link(filename, &nd);
1445 + error = user_path_walk_link_it(filename, &nd, &it);
1447 - error = do_revalidate(nd.dentry);
1448 + error = do_revalidate(nd.dentry, &it);
1450 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1451 + intent_release(&it);
1455 @@ -197,13 +207,15 @@
1456 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1458 struct nameidata nd;
1459 + struct lookup_intent it = { .it_op = IT_GETATTR };
1462 - error = user_path_walk_link(filename, &nd);
1463 + error = user_path_walk_link_it(filename, &nd, &it);
1465 - error = do_revalidate(nd.dentry);
1466 + error = do_revalidate(nd.dentry, &it);
1468 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1469 + intent_release(&it);
1475 struct dentry * dentry = f->f_dentry;
1477 - err = do_revalidate(dentry);
1478 + err = do_revalidate(dentry, NULL);
1480 err = cp_old_stat(dentry->d_inode, statbuf);
1484 struct dentry * dentry = f->f_dentry;
1486 - err = do_revalidate(dentry);
1487 + err = do_revalidate(dentry, NULL);
1489 err = cp_new_stat(dentry->d_inode, statbuf);
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 @@ -341,12 +353,14 @@
1502 struct nameidata nd;
1504 + struct lookup_intent it = { .it_op = IT_GETATTR };
1506 - error = user_path_walk(filename, &nd);
1507 + error = user_path_walk_it(filename, &nd, &it);
1509 - error = do_revalidate(nd.dentry);
1510 + error = do_revalidate(nd.dentry, &it);
1512 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1513 + intent_release(&it);
1517 @@ -356,12 +370,14 @@
1519 struct nameidata nd;
1521 + struct lookup_intent it = { .it_op = IT_GETATTR };
1523 - error = user_path_walk_link(filename, &nd);
1524 + error = user_path_walk_link_it(filename, &nd, &it);
1526 - error = do_revalidate(nd.dentry);
1527 + error = do_revalidate(nd.dentry, &it);
1529 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1530 + intent_release(&it);
1536 struct dentry * dentry = f->f_dentry;
1538 - err = do_revalidate(dentry);
1539 + err = do_revalidate(dentry, NULL);
1541 err = cp_new_stat64(dentry->d_inode, statbuf);
1543 Index: linux-2.4.21-chaos/include/linux/dcache.h
1544 ===================================================================
1545 --- linux-2.4.21-chaos.orig/include/linux/dcache.h 2003-12-05 16:54:33.000000000 +0300
1546 +++ linux-2.4.21-chaos/include/linux/dcache.h 2003-12-12 17:02:47.000000000 +0300
1548 #include <asm/atomic.h>
1549 #include <linux/mount.h>
1550 #include <linux/kernel.h>
1551 +#include <linux/string.h>
1553 +#define IT_OPEN 0x0001
1554 +#define IT_CREAT 0x0002
1555 +#define IT_READDIR 0x0004
1556 +#define IT_GETATTR 0x0008
1557 +#define IT_LOOKUP 0x0010
1558 +#define IT_UNLINK 0x0020
1559 +#define IT_GETXATTR 0x0040
1560 +#define IT_EXEC 0x0080
1561 +#define IT_PIN 0x0100
1563 +#define IT_FL_LOCKED 0x0001
1564 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1566 +#define INTENT_MAGIC 0x19620323
1569 +struct lustre_intent_data {
1570 + int it_disposition;
1572 + __u64 it_lock_handle;
1577 +struct lookup_intent {
1579 + void (*it_op_release)(struct lookup_intent *);
1582 + int it_create_mode;
1584 + struct lustre_intent_data lustre;
1588 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1590 + memset(it, 0, sizeof(*it));
1591 + it->it_magic = INTENT_MAGIC;
1593 + it->it_flags = flags;
1598 * linux/include/linux/dcache.h
1600 int (*d_delete)(struct dentry *);
1601 void (*d_release)(struct dentry *);
1602 void (*d_iput)(struct dentry *, struct inode *);
1603 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1604 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1605 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1608 +#define PIN(de,mnt,flag) if (de->d_op && de->d_op->d_pin) \
1609 + de->d_op->d_pin(de, mnt, flag);
1610 +#define UNPIN(de,mnt,flag) if (de->d_op && de->d_op->d_unpin) \
1611 + de->d_op->d_unpin(de, mnt, flag);
1614 +/* defined in fs/namei.c */
1615 +extern void intent_release(struct lookup_intent *it);
1616 +/* defined in fs/dcache.c */
1617 +extern void __d_rehash(struct dentry * entry, int lock);
1619 /* the dentry parameter passed to d_hash and d_compare is the parent
1620 * directory of the entries to be compared. It is used in case these
1621 * functions need any directory specific information for determining
1623 * s_nfsd_free_path semaphore will be down
1625 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1626 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1628 extern spinlock_t dcache_lock;
1630 Index: linux-2.4.21-chaos/include/linux/fs.h
1631 ===================================================================
1632 --- linux-2.4.21-chaos.orig/include/linux/fs.h 2003-12-12 17:02:46.000000000 +0300
1633 +++ linux-2.4.21-chaos/include/linux/fs.h 2003-12-12 17:02:47.000000000 +0300
1636 #define FMODE_READ 1
1637 #define FMODE_WRITE 2
1638 +#define FMODE_EXEC 4
1643 #define ATTR_MTIME_SET 256
1644 #define ATTR_FORCE 512 /* Not a change, but a change it */
1645 #define ATTR_ATTR_FLAG 1024
1646 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1647 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1648 +#define ATTR_CTIME_SET 0x2000
1651 * This is the Inode Attributes structure, used for notify_change(). It
1653 struct pipe_inode_info *i_pipe;
1654 struct block_device *i_bdev;
1655 struct char_device *i_cdev;
1656 + void *i_filterdata;
1658 unsigned long i_dnotify_mask; /* Directory notify events */
1659 struct dnotify_struct *i_dnotify; /* for directory notifications */
1662 /* needed for tty driver, and maybe others */
1664 + struct lookup_intent *f_it;
1666 /* preallocated helper kiobuf to speedup O_DIRECT */
1667 struct kiobuf *f_iobuf;
1672 + struct lookup_intent *intent;
1677 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1678 extern int vfs_rmdir(struct inode *, struct dentry *);
1679 extern int vfs_unlink(struct inode *, struct dentry *);
1680 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1681 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1682 + struct inode *new_dir, struct dentry *new_dentry);
1686 @@ -920,21 +928,32 @@
1688 struct inode_operations {
1689 int (*create) (struct inode *,struct dentry *,int);
1690 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1691 struct dentry * (*lookup) (struct inode *,struct dentry *);
1692 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1693 int (*link) (struct dentry *,struct inode *,struct dentry *);
1694 + int (*link_raw) (struct nameidata *,struct nameidata *);
1695 int (*unlink) (struct inode *,struct dentry *);
1696 + int (*unlink_raw) (struct nameidata *);
1697 int (*symlink) (struct inode *,struct dentry *,const char *);
1698 + int (*symlink_raw) (struct nameidata *,const char *);
1699 int (*mkdir) (struct inode *,struct dentry *,int);
1700 + int (*mkdir_raw) (struct nameidata *,int);
1701 int (*rmdir) (struct inode *,struct dentry *);
1702 + int (*rmdir_raw) (struct nameidata *);
1703 int (*mknod) (struct inode *,struct dentry *,int,int);
1704 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1705 int (*rename) (struct inode *, struct dentry *,
1706 struct inode *, struct dentry *);
1707 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1708 int (*readlink) (struct dentry *, char *,int);
1709 int (*follow_link) (struct dentry *, struct nameidata *);
1710 void (*truncate) (struct inode *);
1711 int (*permission) (struct inode *, int);
1712 int (*revalidate) (struct dentry *);
1713 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1714 int (*setattr) (struct dentry *, struct iattr *);
1715 + int (*setattr_raw) (struct inode *, struct iattr *);
1716 int (*getattr) (struct dentry *, struct iattr *);
1717 int (*setxattr) (struct dentry *, const char *, const void *, size_t, int);
1718 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1719 @@ -1131,10 +1150,14 @@
1721 asmlinkage long sys_open(const char *, int, int);
1722 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1723 -extern int do_truncate(struct dentry *, loff_t start);
1724 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1726 extern struct file *filp_open(const char *, int, int);
1727 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1728 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1729 + struct nameidata *nd, struct lookup_intent *it);
1730 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1731 + int flags, struct lookup_intent *it);
1732 extern int filp_close(struct file *, fl_owner_t id);
1733 extern char * getname(const char *);
1735 @@ -1425,6 +1448,7 @@
1736 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1738 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1739 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1740 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1741 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1742 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1743 @@ -1436,6 +1460,8 @@
1744 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1745 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1746 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1747 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1748 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1750 extern void inode_init_once(struct inode *);
1751 extern void iput(struct inode *);
1752 @@ -1599,6 +1625,8 @@
1754 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1755 extern int vfs_follow_link(struct nameidata *, const char *);
1756 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1757 + struct lookup_intent *it);
1758 extern int page_readlink(struct dentry *, char *, int);
1759 extern int page_follow_link(struct dentry *, struct nameidata *);
1760 extern struct inode_operations page_symlink_inode_operations;
1761 Index: linux-2.4.21-chaos/include/linux/fs_struct.h
1762 ===================================================================
1763 --- linux-2.4.21-chaos.orig/include/linux/fs_struct.h 2003-12-05 16:54:33.000000000 +0300
1764 +++ linux-2.4.21-chaos/include/linux/fs_struct.h 2003-12-12 17:02:47.000000000 +0300
1766 write_lock(&fs->lock);
1767 old_root = fs->root;
1768 old_rootmnt = fs->rootmnt;
1769 + PIN(dentry, mnt, 1);
1770 fs->rootmnt = mntget(mnt);
1771 fs->root = dget(dentry);
1772 write_unlock(&fs->lock);
1774 + UNPIN(old_root, old_rootmnt, 1);
1776 mntput(old_rootmnt);
1779 write_lock(&fs->lock);
1781 old_pwdmnt = fs->pwdmnt;
1782 + PIN(dentry, mnt, 0);
1783 fs->pwdmnt = mntget(mnt);
1784 fs->pwd = dget(dentry);
1785 write_unlock(&fs->lock);
1787 + UNPIN(old_pwd, old_pwdmnt, 0);
1791 Index: linux-2.4.21-chaos/kernel/exit.c
1792 ===================================================================
1793 --- linux-2.4.21-chaos.orig/kernel/exit.c 2003-09-19 03:50:00.000000000 +0400
1794 +++ linux-2.4.21-chaos/kernel/exit.c 2003-12-12 17:02:47.000000000 +0300
1795 @@ -347,11 +347,14 @@
1797 /* No need to hold fs->lock if we are killing it */
1798 if (atomic_dec_and_test(&fs->count)) {
1799 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1800 + UNPIN(fs->root, fs->rootmnt, 1);
1802 mntput(fs->rootmnt);
1806 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1808 mntput(fs->altrootmnt);
1810 Index: linux-2.4.21-chaos/kernel/fork.c
1811 ===================================================================
1812 --- linux-2.4.21-chaos.orig/kernel/fork.c 2003-12-05 07:55:51.000000000 +0300
1813 +++ linux-2.4.21-chaos/kernel/fork.c 2003-12-12 17:02:47.000000000 +0300
1814 @@ -463,10 +463,13 @@
1815 fs->umask = old->umask;
1816 read_lock(&old->lock);
1817 fs->rootmnt = mntget(old->rootmnt);
1818 + PIN(old->pwd, old->pwdmnt, 0);
1819 + PIN(old->root, old->rootmnt, 1);
1820 fs->root = dget(old->root);
1821 fs->pwdmnt = mntget(old->pwdmnt);
1822 fs->pwd = dget(old->pwd);
1824 + PIN(old->altroot, old->altrootmnt, 1);
1825 fs->altrootmnt = mntget(old->altrootmnt);
1826 fs->altroot = dget(old->altroot);
1828 Index: linux-2.4.21-chaos/kernel/ksyms.c
1829 ===================================================================
1830 --- linux-2.4.21-chaos.orig/kernel/ksyms.c 2003-12-12 17:02:46.000000000 +0300
1831 +++ linux-2.4.21-chaos/kernel/ksyms.c 2003-12-12 17:02:47.000000000 +0300
1833 EXPORT_SYMBOL(set_page_dirty);
1834 EXPORT_SYMBOL(vfs_readlink);
1835 EXPORT_SYMBOL(vfs_follow_link);
1836 +EXPORT_SYMBOL(vfs_follow_link_it);
1837 EXPORT_SYMBOL(page_readlink);
1838 EXPORT_SYMBOL(page_follow_link);
1839 EXPORT_SYMBOL(page_symlink_inode_operations);