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-x86_64/fs/dcache.c
16 ===================================================================
17 --- linux-2.4.21-x86_64.orig/fs/dcache.c 2003-10-28 10:33:59.000000000 -0800
18 +++ linux-2.4.21-x86_64/fs/dcache.c 2004-04-12 19:57:36.000000000 -0700
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-x86_64/fs/exec.c
57 ===================================================================
58 --- linux-2.4.21-x86_64.orig/fs/exec.c 2003-10-28 10:34:17.000000000 -0800
59 +++ linux-2.4.21-x86_64/fs/exec.c 2004-04-12 19:57:36.000000000 -0700
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 @@ -1150,7 +1157,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-x86_64/fs/namei.c
122 ===================================================================
123 --- linux-2.4.21-x86_64.orig/fs/namei.c 2003-10-28 10:34:18.000000000 -0800
124 +++ linux-2.4.21-x86_64/fs/namei.c 2004-04-12 19:58:44.000000000 -0700
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 -static inline int __link_path_walk(const char * name, struct nameidata *nd)
231 +static inline 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, it);
318 + err = PTR_ERR(new);
321 + d_invalidate(dentry);
325 + if (!nd->dentry->d_inode)
327 + if (lookup_flags & LOOKUP_DIRECTORY) {
329 + if (!nd->dentry->d_inode->i_op ||
330 + (!nd->dentry->d_inode->i_op->lookup &&
331 + !nd->dentry->d_inode->i_op->lookup_it))
335 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
337 if (!dentry->d_op->d_revalidate(dentry, lookup_flags & LOOKUP_PARENT)) {
343 + intent_release(it);
347 @@ -663,13 +723,13 @@
349 int link_path_walk(const char * name, struct nameidata *nd)
351 - return __link_path_walk(name,nd);
352 + return __link_path_walk_it(name, nd, NULL);
355 static inline int __path_walk(const char * name, struct nameidata *nd)
357 current->total_link_count = 0;
358 - return __link_path_walk(name, nd);
359 + return __link_path_walk_it(name, nd, NULL);
362 int path_walk(const char * name, struct nameidata *nd)
364 return __path_walk(name, nd);
367 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
369 + current->total_link_count = 0;
370 + return __link_path_walk_it(name, nd, it);
374 /* returns 1 if everything is done */
375 static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
380 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
381 + struct lookup_intent *it)
384 + if (path_init(path, flags, nd))
385 + error = path_walk_it(path, nd, it);
391 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
396 nd->last_type = LAST_ROOT; /* if there are only slashes... */
400 return walk_init_root(name,nd);
401 read_lock(¤t->fs->lock);
403 * needs parent already locked. Doesn't follow mounts.
406 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
407 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
408 + struct lookup_intent *it)
410 struct dentry * dentry;
412 @@ -810,13 +889,16 @@
416 - dentry = cached_lookup(base, name, 0);
417 + dentry = cached_lookup(base, name, 0, it);
419 struct dentry *new = d_alloc(base, name);
420 dentry = ERR_PTR(-ENOMEM);
424 + if (inode->i_op->lookup_it)
425 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
427 dentry = inode->i_op->lookup(inode, new);
434 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
436 + return lookup_hash_it(name, base, NULL);
441 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
445 this.hash = end_name_hash(hash);
447 - return lookup_hash(&this, base);
448 + return lookup_hash_it(&this, base, NULL);
450 return ERR_PTR(-EACCES);
456 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
457 + struct lookup_intent *it)
462 + tmp = getname(name);
463 + err = PTR_ERR(tmp);
464 + if (!IS_ERR(tmp)) {
466 + if (path_init(tmp, flags, nd))
467 + err = path_walk_it(tmp, nd, it);
474 * It's inline, so penalty for filesystems that don't use sticky bit is
480 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
481 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
482 + struct lookup_intent *it)
486 @@ -990,12 +1096,15 @@
489 error = -EACCES; /* shouldn't it be ENOSYS? */
490 - if (!dir->i_op || !dir->i_op->create)
491 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
496 - error = dir->i_op->create(dir, dentry, mode);
497 + if (dir->i_op->create_it)
498 + error = dir->i_op->create_it(dir, dentry, mode, it);
500 + error = dir->i_op->create(dir, dentry, mode);
504 @@ -1004,6 +1113,11 @@
508 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
510 + return vfs_create_it(dir, dentry, mode, NULL);
516 @@ -1018,7 +1132,8 @@
517 * for symlinks (where the permissions are checked later).
520 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
521 +int open_namei_it(const char *pathname, int flag, int mode,
522 + struct nameidata *nd, struct lookup_intent *it)
524 int acc_mode, error = 0;
526 @@ -1028,11 +1143,14 @@
528 acc_mode = ACC_MODE(flag);
531 + it->it_flags = flag;
534 * The simplest case - just a plain lookup.
536 if (!(flag & O_CREAT)) {
537 - error = path_lookup(pathname, lookup_flags(flag), nd);
538 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
542 @@ -1042,6 +1160,10 @@
544 * Create - we need to know the parent.
547 + it->it_create_mode = mode;
548 + it->it_op |= IT_CREAT;
550 error = path_lookup(pathname, LOOKUP_PARENT, nd);
553 @@ -1057,7 +1179,7 @@
556 down(&dir->d_inode->i_sem);
557 - dentry = lookup_hash(&nd->last, nd->dentry);
558 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
561 error = PTR_ERR(dentry);
562 @@ -1066,11 +1188,12 @@
566 + it->it_create_mode = mode;
567 /* Negative dentry, just create the file */
568 if (!dentry->d_inode) {
569 if (!IS_POSIXACL(dir->d_inode))
570 mode &= ~current->fs->umask;
571 - error = vfs_create(dir->d_inode, dentry, mode);
572 + error = vfs_create_it(dir->d_inode, dentry, mode, it);
573 up(&dir->d_inode->i_sem);
574 #ifndef DENTRY_WASTE_RAM
576 @@ -1178,7 +1301,7 @@
580 - error = do_truncate(dentry, 0);
581 + error = do_truncate(dentry, 0, 1);
583 put_write_access(inode);
585 @@ -1190,8 +1313,10 @@
589 + intent_release(it);
592 + intent_release(it);
596 @@ -1210,7 +1335,10 @@
597 * are done. Procfs-like symlinks just set LAST_BIND.
599 UPDATE_ATIME(dentry->d_inode);
601 error = dentry->d_inode->i_op->follow_link(dentry, nd);
603 + intent_release(it);
607 @@ -1232,13 +1360,20 @@
610 down(&dir->d_inode->i_sem);
611 - dentry = lookup_hash(&nd->last, nd->dentry);
612 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
613 putname(nd->last.name);
617 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
619 + return open_namei_it(pathname, flag, mode, nd, NULL);
624 -struct dentry *lookup_create(struct nameidata *nd, int is_dir)
625 +struct dentry *lookup_create(struct nameidata *nd, int is_dir,
626 + struct lookup_intent *it)
628 struct dentry *dentry;
630 @@ -1246,7 +1381,7 @@
631 dentry = ERR_PTR(-EEXIST);
632 if (nd->last_type != LAST_NORM)
634 - dentry = lookup_hash(&nd->last, nd->dentry);
635 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
638 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
639 @@ -1302,7 +1437,20 @@
640 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
643 - dentry = lookup_create(&nd, 0);
645 + if (nd.last_type != LAST_NORM) {
649 + if (nd.dentry->d_inode->i_op->mknod_raw) {
650 + struct inode_operations *op = nd.dentry->d_inode->i_op;
651 + error = op->mknod_raw(&nd, mode, dev);
652 + /* the file system wants to use normal vfs path now */
653 + if (error != -EOPNOTSUPP)
657 + dentry = lookup_create(&nd, 0, NULL);
658 error = PTR_ERR(dentry);
660 if (!IS_POSIXACL(nd.dentry->d_inode))
661 @@ -1324,6 +1472,7 @@
664 up(&nd.dentry->d_inode->i_sem);
669 @@ -1371,7 +1520,18 @@
670 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
673 - dentry = lookup_create(&nd, 1);
674 + if (nd.last_type != LAST_NORM) {
678 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
679 + struct inode_operations *op = nd.dentry->d_inode->i_op;
680 + error = op->mkdir_raw(&nd, mode);
681 + /* the file system wants to use normal vfs path now */
682 + if (error != -EOPNOTSUPP)
685 + dentry = lookup_create(&nd, 1, NULL);
686 error = PTR_ERR(dentry);
687 if (!IS_ERR(dentry)) {
688 if (!IS_POSIXACL(nd.dentry->d_inode))
689 @@ -1380,6 +1540,7 @@
692 up(&nd.dentry->d_inode->i_sem);
697 @@ -1480,8 +1641,16 @@
701 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
702 + struct inode_operations *op = nd.dentry->d_inode->i_op;
704 + error = op->rmdir_raw(&nd);
705 + /* the file system wants to use normal vfs path now */
706 + if (error != -EOPNOTSUPP)
709 down(&nd.dentry->d_inode->i_sem);
710 - dentry = lookup_hash(&nd.last, nd.dentry);
711 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
712 error = PTR_ERR(dentry);
713 if (!IS_ERR(dentry)) {
714 error = vfs_rmdir(nd.dentry->d_inode, dentry);
715 @@ -1539,8 +1708,15 @@
717 if (nd.last_type != LAST_NORM)
719 + if (nd.dentry->d_inode->i_op->unlink_raw) {
720 + struct inode_operations *op = nd.dentry->d_inode->i_op;
721 + error = op->unlink_raw(&nd);
722 + /* the file system wants to use normal vfs path now */
723 + if (error != -EOPNOTSUPP)
726 down(&nd.dentry->d_inode->i_sem);
727 - dentry = lookup_hash(&nd.last, nd.dentry);
728 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
729 error = PTR_ERR(dentry);
730 if (!IS_ERR(dentry)) {
731 /* Why not before? Because we want correct error value */
732 @@ -1607,15 +1783,27 @@
733 error = path_lookup(to, LOOKUP_PARENT, &nd);
736 - dentry = lookup_create(&nd, 0);
737 + if (nd.last_type != LAST_NORM) {
741 + if (nd.dentry->d_inode->i_op->symlink_raw) {
742 + struct inode_operations *op = nd.dentry->d_inode->i_op;
743 + error = op->symlink_raw(&nd, from);
744 + /* the file system wants to use normal vfs path now */
745 + if (error != -EOPNOTSUPP)
748 + dentry = lookup_create(&nd, 0, NULL);
749 error = PTR_ERR(dentry);
750 if (!IS_ERR(dentry)) {
751 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
754 up(&nd.dentry->d_inode->i_sem);
762 @@ -1691,7 +1879,18 @@
764 if (old_nd.mnt != nd.mnt)
766 - new_dentry = lookup_create(&nd, 0);
767 + if (nd.last_type != LAST_NORM) {
771 + if (nd.dentry->d_inode->i_op->link_raw) {
772 + struct inode_operations *op = nd.dentry->d_inode->i_op;
773 + error = op->link_raw(&old_nd, &nd);
774 + /* the file system wants to use normal vfs path now */
775 + if (error != -EOPNOTSUPP)
778 + new_dentry = lookup_create(&nd, 0, NULL);
779 error = PTR_ERR(new_dentry);
780 if (!IS_ERR(new_dentry)) {
781 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
782 @@ -1735,7 +1934,7 @@
785 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
786 - struct inode *new_dir, struct dentry *new_dentry)
787 + struct inode *new_dir, struct dentry *new_dentry)
790 struct inode *target;
791 @@ -1814,7 +2013,7 @@
794 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
795 - struct inode *new_dir, struct dentry *new_dentry)
796 + struct inode *new_dir, struct dentry *new_dentry)
800 @@ -1902,9 +2101,18 @@
801 if (newnd.last_type != LAST_NORM)
804 + if (old_dir->d_inode->i_op->rename_raw) {
806 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
808 + /* the file system wants to use normal vfs path now */
809 + if (error != -EOPNOTSUPP)
813 double_lock(new_dir, old_dir);
815 - old_dentry = lookup_hash(&oldnd.last, old_dir);
816 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
817 error = PTR_ERR(old_dentry);
818 if (IS_ERR(old_dentry))
820 @@ -1920,16 +2128,16 @@
821 if (newnd.last.name[newnd.last.len])
824 - new_dentry = lookup_hash(&newnd.last, new_dir);
825 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
826 error = PTR_ERR(new_dentry);
827 if (IS_ERR(new_dentry))
832 error = vfs_rename(old_dir->d_inode, old_dentry,
833 new_dir->d_inode, new_dentry);
839 @@ -1980,20 +2188,26 @@
843 -__vfs_follow_link(struct nameidata *nd, const char *link)
844 +__vfs_follow_link(struct nameidata *nd, const char *link,
845 + struct lookup_intent *it)
854 + else if (it != nd->intent)
855 + printk("it != nd->intent: tell phil@clusterfs.com\n");
859 if (!walk_init_root(link, nd))
860 /* weird __emul_prefix() stuff did it */
863 - res = __link_path_walk(link, nd);
864 + res = __link_path_walk_it(link, nd, it);
866 if (current->link_count || res || nd->last_type!=LAST_NORM)
868 @@ -2017,7 +2231,13 @@
870 int vfs_follow_link(struct nameidata *nd, const char *link)
872 - return __vfs_follow_link(nd, link);
873 + return __vfs_follow_link(nd, link, NULL);
876 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
877 + struct lookup_intent *it)
879 + return __vfs_follow_link(nd, link, it);
882 /* get the link contents into pagecache */
883 @@ -2059,7 +2279,7 @@
885 struct page *page = NULL;
886 char *s = page_getlink(dentry, &page);
887 - int res = __vfs_follow_link(nd, s);
888 + int res = __vfs_follow_link(nd, s, NULL);
891 page_cache_release(page);
892 Index: linux-2.4.21-x86_64/fs/namespace.c
893 ===================================================================
894 --- linux-2.4.21-x86_64.orig/fs/namespace.c 2003-10-28 10:34:12.000000000 -0800
895 +++ linux-2.4.21-x86_64/fs/namespace.c 2004-04-12 19:57:36.000000000 -0700
898 old_nd->dentry = mnt->mnt_mountpoint;
899 old_nd->mnt = mnt->mnt_parent;
900 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
901 mnt->mnt_parent = mnt;
902 mnt->mnt_mountpoint = mnt->mnt_root;
903 list_del_init(&mnt->mnt_child);
906 mnt->mnt_parent = mntget(nd->mnt);
907 mnt->mnt_mountpoint = dget(nd->dentry);
908 + PIN(nd->dentry, nd->mnt, 1);
909 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
910 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
911 nd->dentry->d_mounted++;
912 @@ -488,14 +490,17 @@
914 struct nameidata old_nd;
915 struct vfsmount *mnt = NULL;
916 + struct lookup_intent it = { .it_op = IT_GETATTR };
917 int err = mount_is_safe(nd);
920 if (!old_name || !*old_name)
922 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
924 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
926 + intent_release(&it);
930 down_write(¤t->namespace->sem);
935 up_write(¤t->namespace->sem);
936 + intent_release(&it);
937 path_release(&old_nd);
941 unsigned long flags, void *data_page)
944 + struct lookup_intent it = { .it_op = IT_GETATTR };
948 @@ -725,10 +732,11 @@
949 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
951 /* ... and get the mountpoint */
952 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
954 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
956 + intent_release(&it);
960 if (flags & MS_REMOUNT)
961 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
965 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
966 dev_name, data_page);
968 + intent_release(&it);
974 struct vfsmount *tmp;
975 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
976 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
977 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
980 if (!capable(CAP_SYS_ADMIN))
981 @@ -911,14 +923,14 @@
985 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
986 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
990 if (!check_mnt(new_nd.mnt))
993 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
994 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
999 up(&old_nd.dentry->d_inode->i_zombie);
1000 up_write(¤t->namespace->sem);
1001 path_release(&user_nd);
1002 + intent_release(&old_it);
1003 path_release(&old_nd);
1005 + intent_release(&new_it);
1006 path_release(&new_nd);
1009 Index: linux-2.4.21-x86_64/fs/open.c
1010 ===================================================================
1011 --- linux-2.4.21-x86_64.orig/fs/open.c 2003-10-28 10:33:59.000000000 -0800
1012 +++ linux-2.4.21-x86_64/fs/open.c 2004-04-12 19:57:36.000000000 -0700
1014 #include <asm/uaccess.h>
1016 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1017 +extern int path_walk_it(const char *name, struct nameidata *nd,
1018 + struct lookup_intent *it);
1020 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1023 write_unlock(&files->file_lock);
1026 -int do_truncate(struct dentry *dentry, loff_t length)
1027 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1029 struct inode *inode = dentry->d_inode;
1030 + struct inode_operations *op = dentry->d_inode->i_op;
1032 struct iattr newattrs;
1034 @@ -109,7 +112,13 @@
1035 down(&inode->i_sem);
1036 newattrs.ia_size = length;
1037 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1038 - error = notify_change(dentry, &newattrs);
1039 + if (called_from_open)
1040 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1041 + if (op->setattr_raw) {
1042 + newattrs.ia_valid |= ATTR_RAW;
1043 + error = op->setattr_raw(inode, &newattrs);
1045 + error = notify_change(dentry, &newattrs);
1047 up_write(&inode->i_alloc_sem);
1049 @@ -120,12 +129,13 @@
1050 struct nameidata nd;
1051 struct inode * inode;
1053 + struct lookup_intent it = { .it_op = IT_GETATTR };
1056 if (length < 0) /* sorry, but loff_t says... */
1059 - error = user_path_walk(path, &nd);
1060 + error = user_path_walk_it(path, &nd, &it);
1063 inode = nd.dentry->d_inode;
1064 @@ -165,11 +175,13 @@
1065 error = locks_verify_truncate(inode, NULL, length);
1068 - error = do_truncate(nd.dentry, length);
1069 + intent_release(&it);
1070 + error = do_truncate(nd.dentry, length, 0);
1072 put_write_access(inode);
1075 + intent_release(&it);
1081 error = locks_verify_truncate(inode, file, length);
1083 - error = do_truncate(dentry, length);
1084 + error = do_truncate(dentry, length, 0);
1088 @@ -262,11 +274,13 @@
1089 struct inode * inode;
1090 struct iattr newattrs;
1092 - error = user_path_walk(filename, &nd);
1093 + error = user_path_walk_it(filename, &nd, NULL);
1096 inode = nd.dentry->d_inode;
1098 + /* this is safe without a Lustre lock because it only depends
1099 + on the super block */
1101 if (IS_RDONLY(inode))
1103 @@ -281,11 +295,25 @@
1106 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1110 + if (inode->i_op->setattr_raw) {
1111 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1113 + newattrs.ia_valid |= ATTR_RAW;
1114 + error = op->setattr_raw(inode, &newattrs);
1115 + /* the file system wants to use normal vfs path now */
1116 + if (error != -EOPNOTSUPP)
1117 + goto dput_and_out;
1122 if (current->fsuid != inode->i_uid &&
1123 (error = permission(inode,MAY_WRITE)) != 0)
1127 error = notify_change(nd.dentry, &newattrs);
1130 @@ -306,12 +334,14 @@
1131 struct inode * inode;
1132 struct iattr newattrs;
1134 - error = user_path_walk(filename, &nd);
1135 + error = user_path_walk_it(filename, &nd, NULL);
1139 inode = nd.dentry->d_inode;
1141 + /* this is safe without a Lustre lock because it only depends
1142 + on the super block */
1144 if (IS_RDONLY(inode))
1146 @@ -326,7 +356,20 @@
1147 newattrs.ia_atime = times[0].tv_sec;
1148 newattrs.ia_mtime = times[1].tv_sec;
1149 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1153 + if (inode->i_op->setattr_raw) {
1154 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1156 + newattrs.ia_valid |= ATTR_RAW;
1157 + error = op->setattr_raw(inode, &newattrs);
1158 + /* the file system wants to use normal vfs path now */
1159 + if (error != -EOPNOTSUPP)
1160 + goto dput_and_out;
1165 if (current->fsuid != inode->i_uid &&
1166 (error = permission(inode,MAY_WRITE)) != 0)
1169 int old_fsuid, old_fsgid;
1170 kernel_cap_t old_cap;
1172 + struct lookup_intent it = { .it_op = IT_GETATTR };
1174 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1176 @@ -366,13 +410,14 @@
1178 current->cap_effective = current->cap_permitted;
1180 - res = user_path_walk(filename, &nd);
1181 + res = user_path_walk_it(filename, &nd, &it);
1183 res = permission(nd.dentry->d_inode, mode);
1184 /* SuS v2 requires we report a read only fs too */
1185 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1186 && !special_file(nd.dentry->d_inode->i_mode))
1188 + intent_release(&it);
1195 struct nameidata nd;
1196 + struct lookup_intent it = { .it_op = IT_GETATTR };
1198 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1199 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1204 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1207 + intent_release(&it);
1211 @@ -438,9 +485,10 @@
1214 struct nameidata nd;
1215 + struct lookup_intent it = { .it_op = IT_GETATTR };
1217 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1218 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1219 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1220 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1224 @@ -456,39 +504,56 @@
1228 + intent_release(&it);
1234 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1235 +int chmod_common(struct dentry *dentry, mode_t mode)
1237 - struct inode * inode;
1238 - struct dentry * dentry;
1239 - struct file * file;
1241 + struct inode *inode = dentry->d_inode;
1242 struct iattr newattrs;
1247 + if (IS_RDONLY(inode))
1250 - dentry = file->f_dentry;
1251 - inode = dentry->d_inode;
1252 + if (inode->i_op->setattr_raw) {
1253 + newattrs.ia_mode = mode;
1254 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1255 + newattrs.ia_valid |= ATTR_RAW;
1256 + err = inode->i_op->setattr_raw(inode, &newattrs);
1257 + /* the file system wants to use normal vfs path now */
1258 + if (err != -EOPNOTSUPP)
1263 - if (IS_RDONLY(inode))
1266 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1270 if (mode == (mode_t) -1)
1271 mode = inode->i_mode;
1272 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1273 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1274 err = notify_change(dentry, &newattrs);
1281 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1283 + struct file * file;
1290 + err = chmod_common(file->f_dentry, mode);
1295 @@ -497,30 +562,14 @@
1296 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1298 struct nameidata nd;
1299 - struct inode * inode;
1301 - struct iattr newattrs;
1303 error = user_path_walk(filename, &nd);
1306 - inode = nd.dentry->d_inode;
1309 - if (IS_RDONLY(inode))
1310 - goto dput_and_out;
1313 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1314 - goto dput_and_out;
1315 + error = chmod_common(nd.dentry, mode);
1317 - if (mode == (mode_t) -1)
1318 - mode = inode->i_mode;
1319 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1320 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1321 - error = notify_change(nd.dentry, &newattrs);
1327 @@ -540,6 +589,20 @@
1329 if (IS_RDONLY(inode))
1332 + if (inode->i_op->setattr_raw) {
1333 + struct inode_operations *op = dentry->d_inode->i_op;
1335 + newattrs.ia_uid = user;
1336 + newattrs.ia_gid = group;
1337 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1338 + newattrs.ia_valid |= ATTR_RAW;
1339 + error = op->setattr_raw(inode, &newattrs);
1340 + /* the file system wants to use normal vfs path now */
1341 + if (error != -EOPNOTSUPP)
1346 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1350 int namei_flags, error;
1351 struct nameidata nd;
1352 + struct lookup_intent it = { .it_op = IT_OPEN };
1354 namei_flags = flags;
1355 if ((namei_flags+1) & O_ACCMODE)
1356 @@ -651,14 +715,15 @@
1357 if (namei_flags & O_TRUNC)
1360 - error = open_namei(filename, namei_flags, mode, &nd);
1362 - return dentry_open(nd.dentry, nd.mnt, flags);
1363 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1365 + return ERR_PTR(error);
1367 - return ERR_PTR(error);
1368 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1371 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1372 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1373 + int flags, struct lookup_intent *it)
1376 struct inode *inode;
1378 file_move(f, &inode->i_sb->s_files);
1380 if (f->f_op && f->f_op->open) {
1382 error = f->f_op->open(inode,f);
1388 !inode->i_mapping->a_ops->direct_IO))
1391 + intent_release(it);
1395 @@ -710,11 +778,17 @@
1399 + intent_release(it);
1402 return ERR_PTR(error);
1405 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1407 + return dentry_open_it(dentry, mnt, flags, NULL);
1411 * Find an empty file descriptor entry, and mark it busy.
1413 Index: linux-2.4.21-x86_64/fs/stat.c
1414 ===================================================================
1415 --- linux-2.4.21-x86_64.orig/fs/stat.c 2003-10-28 10:33:58.000000000 -0800
1416 +++ linux-2.4.21-x86_64/fs/stat.c 2004-04-12 19:58:44.000000000 -0700
1418 * Revalidate the inode. This is required for proper NFS attribute caching.
1420 static __inline__ int
1421 -do_revalidate(struct dentry *dentry)
1422 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1424 struct inode * inode = dentry->d_inode;
1425 - if (inode->i_op && inode->i_op->revalidate)
1426 + if (inode->i_op && inode->i_op->revalidate_it)
1427 + return inode->i_op->revalidate_it(dentry, it);
1428 + else if (inode->i_op && inode->i_op->revalidate)
1429 return inode->i_op->revalidate(dentry);
1432 @@ -141,13 +143,15 @@
1433 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1435 struct nameidata nd;
1436 + struct lookup_intent it = { .it_op = IT_GETATTR };
1439 - error = user_path_walk(filename, &nd);
1440 + error = user_path_walk_it(filename, &nd, &it);
1442 - error = do_revalidate(nd.dentry);
1443 + error = do_revalidate(nd.dentry, &it);
1445 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1446 + intent_release(&it);
1450 @@ -157,13 +161,15 @@
1451 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1453 struct nameidata nd;
1454 + struct lookup_intent it = { .it_op = IT_GETATTR };
1457 - error = user_path_walk(filename, &nd);
1458 + error = user_path_walk_it(filename, &nd, &it);
1460 - error = do_revalidate(nd.dentry);
1461 + error = do_revalidate(nd.dentry, &it);
1463 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1464 + intent_release(&it);
1468 @@ -178,13 +184,15 @@
1469 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1471 struct nameidata nd;
1472 + struct lookup_intent it = { .it_op = IT_GETATTR };
1475 - error = user_path_walk_link(filename, &nd);
1476 + error = user_path_walk_link_it(filename, &nd, &it);
1478 - error = do_revalidate(nd.dentry);
1479 + error = do_revalidate(nd.dentry, &it);
1481 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1482 + intent_release(&it);
1486 @@ -195,13 +203,15 @@
1487 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1489 struct nameidata nd;
1490 + struct lookup_intent it = { .it_op = IT_GETATTR };
1493 - error = user_path_walk_link(filename, &nd);
1494 + error = user_path_walk_link_it(filename, &nd, &it);
1496 - error = do_revalidate(nd.dentry);
1497 + error = do_revalidate(nd.dentry, &it);
1499 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1500 + intent_release(&it);
1506 struct dentry * dentry = f->f_dentry;
1508 - err = do_revalidate(dentry);
1509 + err = do_revalidate(dentry, NULL);
1511 err = cp_old_stat(dentry->d_inode, statbuf);
1515 struct dentry * dentry = f->f_dentry;
1517 - err = do_revalidate(dentry);
1518 + err = do_revalidate(dentry, NULL);
1520 err = cp_new_stat(dentry->d_inode, statbuf);
1525 if (inode->i_op && inode->i_op->readlink &&
1526 - !(error = do_revalidate(nd.dentry))) {
1527 + !(error = do_revalidate(nd.dentry, NULL))) {
1528 UPDATE_ATIME(inode);
1529 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1531 @@ -339,12 +349,14 @@
1533 struct nameidata nd;
1535 + struct lookup_intent it = { .it_op = IT_GETATTR };
1537 - error = user_path_walk(filename, &nd);
1538 + error = user_path_walk_it(filename, &nd, &it);
1540 - error = do_revalidate(nd.dentry);
1541 + error = do_revalidate(nd.dentry, &it);
1543 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1544 + intent_release(&it);
1548 @@ -354,12 +366,14 @@
1550 struct nameidata nd;
1552 + struct lookup_intent it = { .it_op = IT_GETATTR };
1554 - error = user_path_walk_link(filename, &nd);
1555 + error = user_path_walk_link_it(filename, &nd, &it);
1557 - error = do_revalidate(nd.dentry);
1558 + error = do_revalidate(nd.dentry, &it);
1560 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1561 + intent_release(&it);
1567 struct dentry * dentry = f->f_dentry;
1569 - err = do_revalidate(dentry);
1570 + err = do_revalidate(dentry, NULL);
1572 err = cp_new_stat64(dentry->d_inode, statbuf);
1574 Index: linux-2.4.21-x86_64/include/linux/dcache.h
1575 ===================================================================
1576 --- linux-2.4.21-x86_64.orig/include/linux/dcache.h 2003-11-10 16:44:28.000000000 -0800
1577 +++ linux-2.4.21-x86_64/include/linux/dcache.h 2004-04-12 19:57:36.000000000 -0700
1579 #include <linux/gdb.h>
1580 #include <linux/mount.h>
1581 #include <linux/kernel.h>
1582 +#include <linux/string.h>
1584 +#define IT_OPEN 0x0001
1585 +#define IT_CREAT 0x0002
1586 +#define IT_READDIR 0x0004
1587 +#define IT_GETATTR 0x0008
1588 +#define IT_LOOKUP 0x0010
1589 +#define IT_UNLINK 0x0020
1590 +#define IT_GETXATTR 0x0040
1591 +#define IT_EXEC 0x0080
1592 +#define IT_PIN 0x0100
1594 +#define IT_FL_LOCKED 0x0001
1595 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1597 +#define INTENT_MAGIC 0x19620323
1600 +struct lustre_intent_data {
1601 + int it_disposition;
1603 + __u64 it_lock_handle;
1608 +struct lookup_intent {
1610 + void (*it_op_release)(struct lookup_intent *);
1613 + int it_create_mode;
1615 + struct lustre_intent_data lustre;
1619 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1621 + memset(it, 0, sizeof(*it));
1622 + it->it_magic = INTENT_MAGIC;
1624 + it->it_flags = flags;
1629 * linux/include/linux/dcache.h
1631 int (*d_delete)(struct dentry *);
1632 void (*d_release)(struct dentry *);
1633 void (*d_iput)(struct dentry *, struct inode *);
1634 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1635 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1636 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1639 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1640 + de->d_op->d_pin(de, mnt, flag);
1641 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1642 + de->d_op->d_unpin(de, mnt, flag);
1645 +/* defined in fs/namei.c */
1646 +extern void intent_release(struct lookup_intent *it);
1647 +/* defined in fs/dcache.c */
1648 +extern void __d_rehash(struct dentry * entry, int lock);
1650 /* the dentry parameter passed to d_hash and d_compare is the parent
1651 * directory of the entries to be compared. It is used in case these
1652 * functions need any directory specific information for determining
1654 * s_nfsd_free_path semaphore will be down
1656 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1657 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1659 extern spinlock_t dcache_lock;
1661 Index: linux-2.4.21-x86_64/include/linux/fs.h
1662 ===================================================================
1663 --- linux-2.4.21-x86_64.orig/include/linux/fs.h 2004-04-12 19:57:33.000000000 -0700
1664 +++ linux-2.4.21-x86_64/include/linux/fs.h 2004-04-12 19:57:36.000000000 -0700
1667 #define FMODE_READ 1
1668 #define FMODE_WRITE 2
1669 +#define FMODE_EXEC 4
1674 #define ATTR_MTIME_SET 256
1675 #define ATTR_FORCE 512 /* Not a change, but a change it */
1676 #define ATTR_ATTR_FLAG 1024
1677 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1678 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1679 +#define ATTR_CTIME_SET 0x2000
1682 * This is the Inode Attributes structure, used for notify_change(). It
1684 struct pipe_inode_info *i_pipe;
1685 struct block_device *i_bdev;
1686 struct char_device *i_cdev;
1687 + void *i_filterdata;
1689 unsigned long i_dnotify_mask; /* Directory notify events */
1690 struct dnotify_struct *i_dnotify; /* for directory notifications */
1693 /* needed for tty driver, and maybe others */
1695 + struct lookup_intent *f_it;
1696 struct list_head f_ep_links;
1697 spinlock_t f_ep_lock;
1703 + struct lookup_intent *intent;
1708 extern int __vfs_rmdir(struct inode *, struct dentry *);
1709 extern int vfs_rmdir(struct inode *, struct dentry *);
1710 extern int vfs_unlink(struct inode *, struct dentry *);
1711 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1712 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1713 + struct inode *new_dir, struct dentry *new_dentry);
1717 @@ -992,21 +1000,32 @@
1719 struct inode_operations {
1720 int (*create) (struct inode *,struct dentry *,int);
1721 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1722 struct dentry * (*lookup) (struct inode *,struct dentry *);
1723 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1724 int (*link) (struct dentry *,struct inode *,struct dentry *);
1725 + int (*link_raw) (struct nameidata *,struct nameidata *);
1726 int (*unlink) (struct inode *,struct dentry *);
1727 + int (*unlink_raw) (struct nameidata *);
1728 int (*symlink) (struct inode *,struct dentry *,const char *);
1729 + int (*symlink_raw) (struct nameidata *,const char *);
1730 int (*mkdir) (struct inode *,struct dentry *,int);
1731 + int (*mkdir_raw) (struct nameidata *,int);
1732 int (*rmdir) (struct inode *,struct dentry *);
1733 + int (*rmdir_raw) (struct nameidata *);
1734 int (*mknod) (struct inode *,struct dentry *,int,int);
1735 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1736 int (*rename) (struct inode *, struct dentry *,
1737 struct inode *, struct dentry *);
1738 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1739 int (*readlink) (struct dentry *, char *,int);
1740 int (*follow_link) (struct dentry *, struct nameidata *);
1741 void (*truncate) (struct inode *);
1742 int (*permission) (struct inode *, int);
1743 int (*revalidate) (struct dentry *);
1744 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1745 int (*setattr) (struct dentry *, struct iattr *);
1746 + int (*setattr_raw) (struct inode *, struct iattr *);
1747 int (*getattr) (struct dentry *, struct iattr *);
1748 int (*setxattr) (struct dentry *, const char *, const void *, size_t, int);
1749 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1750 @@ -1205,10 +1224,14 @@
1752 asmlinkage long sys_open(const char *, int, int);
1753 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1754 -extern int do_truncate(struct dentry *, loff_t start);
1755 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1757 extern struct file *filp_open(const char *, int, int);
1758 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1759 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1760 + struct nameidata *nd, struct lookup_intent *it);
1761 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1762 + int flags, struct lookup_intent *it);
1763 extern int filp_close(struct file *, fl_owner_t id);
1764 extern char * getname(const char *);
1766 @@ -1504,6 +1527,7 @@
1767 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1769 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1770 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1771 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1772 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1773 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1774 @@ -1516,6 +1540,8 @@
1775 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1776 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1777 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1778 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1779 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1781 extern void inode_init_once(struct inode *);
1782 extern void _inode_init_once(struct inode *);
1783 @@ -1667,6 +1693,8 @@
1785 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1786 extern int vfs_follow_link(struct nameidata *, const char *);
1787 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1788 + struct lookup_intent *it);
1789 extern int page_readlink(struct dentry *, char *, int);
1790 extern int page_follow_link(struct dentry *, struct nameidata *);
1791 extern struct inode_operations page_symlink_inode_operations;
1792 Index: linux-2.4.21-x86_64/include/linux/fs_struct.h
1793 ===================================================================
1794 --- linux-2.4.21-x86_64.orig/include/linux/fs_struct.h 2001-07-13 15:10:44.000000000 -0700
1795 +++ linux-2.4.21-x86_64/include/linux/fs_struct.h 2004-04-12 19:57:36.000000000 -0700
1797 write_lock(&fs->lock);
1798 old_root = fs->root;
1799 old_rootmnt = fs->rootmnt;
1800 + PIN(dentry, mnt, 1);
1801 fs->rootmnt = mntget(mnt);
1802 fs->root = dget(dentry);
1803 write_unlock(&fs->lock);
1805 + UNPIN(old_root, old_rootmnt, 1);
1807 mntput(old_rootmnt);
1810 write_lock(&fs->lock);
1812 old_pwdmnt = fs->pwdmnt;
1813 + PIN(dentry, mnt, 0);
1814 fs->pwdmnt = mntget(mnt);
1815 fs->pwd = dget(dentry);
1816 write_unlock(&fs->lock);
1818 + UNPIN(old_pwd, old_pwdmnt, 0);
1822 Index: linux-2.4.21-x86_64/kernel/exit.c
1823 ===================================================================
1824 --- linux-2.4.21-x86_64.orig/kernel/exit.c 2003-10-28 10:34:13.000000000 -0800
1825 +++ linux-2.4.21-x86_64/kernel/exit.c 2004-04-12 19:57:36.000000000 -0700
1826 @@ -288,11 +288,14 @@
1828 /* No need to hold fs->lock if we are killing it */
1829 if (atomic_dec_and_test(&fs->count)) {
1830 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1831 + UNPIN(fs->root, fs->rootmnt, 1);
1833 mntput(fs->rootmnt);
1837 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1839 mntput(fs->altrootmnt);
1841 Index: linux-2.4.21-x86_64/kernel/fork.c
1842 ===================================================================
1843 --- linux-2.4.21-x86_64.orig/kernel/fork.c 2003-10-28 10:34:17.000000000 -0800
1844 +++ linux-2.4.21-x86_64/kernel/fork.c 2004-04-12 19:57:36.000000000 -0700
1845 @@ -461,10 +461,13 @@
1846 fs->umask = old->umask;
1847 read_lock(&old->lock);
1848 fs->rootmnt = mntget(old->rootmnt);
1849 + PIN(old->pwd, old->pwdmnt, 0);
1850 + PIN(old->root, old->rootmnt, 1);
1851 fs->root = dget(old->root);
1852 fs->pwdmnt = mntget(old->pwdmnt);
1853 fs->pwd = dget(old->pwd);
1855 + PIN(old->altroot, old->altrootmnt, 1);
1856 fs->altrootmnt = mntget(old->altrootmnt);
1857 fs->altroot = dget(old->altroot);
1859 Index: linux-2.4.21-x86_64/kernel/ksyms.c
1860 ===================================================================
1861 --- linux-2.4.21-x86_64.orig/kernel/ksyms.c 2004-04-12 19:57:33.000000000 -0700
1862 +++ linux-2.4.21-x86_64/kernel/ksyms.c 2004-04-12 19:57:36.000000000 -0700
1864 EXPORT_SYMBOL(set_page_dirty);
1865 EXPORT_SYMBOL(vfs_readlink);
1866 EXPORT_SYMBOL(vfs_follow_link);
1867 +EXPORT_SYMBOL(vfs_follow_link_it);
1868 EXPORT_SYMBOL(page_readlink);
1869 EXPORT_SYMBOL(page_follow_link);
1870 EXPORT_SYMBOL(page_symlink_inode_operations);