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/fs/dcache.c
16 ===================================================================
17 --- linux-2.4.21.orig/fs/dcache.c 2004-04-24 02:38:00.000000000 -0400
18 +++ linux-2.4.21/fs/dcache.c 2004-04-26 19:06:31.000000000 -0400
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/fs/exec.c
57 ===================================================================
58 --- linux-2.4.21.orig/fs/exec.c 2004-04-24 02:39:01.000000000 -0400
59 +++ linux-2.4.21/fs/exec.c 2004-04-26 19:06:31.000000000 -0400
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 @@ -1147,7 +1154,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/fs/namei.c
122 ===================================================================
123 --- linux-2.4.21.orig/fs/namei.c 2004-04-24 02:39:02.000000000 -0400
124 +++ linux-2.4.21/fs/namei.c 2004-04-26 19:06:38.000000000 -0400
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 @@ -274,10 +281,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, NULL, 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 @@ -295,11 +311,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, NULL, 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, NULL, 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 @@ -360,10 +393,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);
227 * We expect 'base' to be positive and a directory.
229 static inline int __attribute__((always_inline))
230 -__link_path_walk(const char * name, struct nameidata *nd)
231 +__link_path_walk_it(const char * name, struct nameidata *nd,
232 + struct lookup_intent *it)
234 struct dentry *dentry;
236 @@ -539,12 +575,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 @@ -605,12 +641,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, NULL, 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)
328 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
330 if (!dentry->d_op->d_revalidate(dentry, lookup_flags & LOOKUP_PARENT)) {
336 + intent_release(it);
340 @@ -678,13 +738,13 @@
342 int link_path_walk(const char * name, struct nameidata *nd)
344 - return __link_path_walk(name,nd);
345 + return __link_path_walk_it(name, nd, NULL);
348 static inline int __path_walk(const char * name, struct nameidata *nd)
350 current->total_link_count = 0;
351 - return __link_path_walk(name, nd);
352 + return __link_path_walk_it(name, nd, NULL);
355 int path_walk(const char * name, struct nameidata *nd)
357 return __path_walk(name, nd);
360 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
362 + current->total_link_count = 0;
363 + return __link_path_walk_it(name, nd, it);
367 /* returns 1 if everything is done */
368 static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
373 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
374 + struct lookup_intent *it)
377 + if (path_init(path, flags, nd))
378 + error = path_walk_it(path, nd, it);
384 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
389 nd->last_type = LAST_ROOT; /* if there are only slashes... */
393 return walk_init_root(name,nd);
394 read_lock(¤t->fs->lock);
396 * needs parent already locked. Doesn't follow mounts.
399 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
400 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
401 + struct lookup_intent *it)
403 struct dentry * dentry;
405 @@ -825,13 +904,16 @@
409 - dentry = cached_lookup(base, name, 0);
410 + dentry = cached_lookup(base, name, 0, it);
412 struct dentry *new = d_alloc(base, name);
413 dentry = ERR_PTR(-ENOMEM);
417 + if (inode->i_op->lookup_it)
418 + dentry = inode->i_op->lookup_it(inode, new, NULL, it, 0);
420 dentry = inode->i_op->lookup(inode, new);
427 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
429 + return lookup_hash_it(name, base, NULL);
434 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
438 this.hash = end_name_hash(hash);
440 - return lookup_hash(&this, base);
441 + return lookup_hash_it(&this, base, NULL);
443 return ERR_PTR(-EACCES);
449 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
450 + struct lookup_intent *it)
455 + tmp = getname(name);
456 + err = PTR_ERR(tmp);
457 + if (!IS_ERR(tmp)) {
459 + if (path_init(tmp, flags, nd))
460 + err = path_walk_it(tmp, nd, it);
467 * It's inline, so penalty for filesystems that don't use sticky bit is
473 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
474 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
475 + struct lookup_intent *it)
479 @@ -1005,12 +1111,15 @@
482 error = -EACCES; /* shouldn't it be ENOSYS? */
483 - if (!dir->i_op || !dir->i_op->create)
484 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
489 - error = dir->i_op->create(dir, dentry, mode);
490 + if (dir->i_op->create_it)
491 + error = dir->i_op->create_it(dir, dentry, mode, it);
493 + error = dir->i_op->create(dir, dentry, mode);
497 @@ -1019,6 +1128,11 @@
501 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
503 + return vfs_create_it(dir, dentry, mode, NULL);
509 @@ -1033,7 +1147,8 @@
510 * for symlinks (where the permissions are checked later).
513 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
514 +int open_namei_it(const char *pathname, int flag, int mode,
515 + struct nameidata *nd, struct lookup_intent *it)
517 int acc_mode, error = 0;
519 @@ -1043,11 +1158,14 @@
521 acc_mode = ACC_MODE(flag);
524 + it->it_flags = flag;
527 * The simplest case - just a plain lookup.
529 if (!(flag & O_CREAT)) {
530 - error = path_lookup(pathname, lookup_flags(flag), nd);
531 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
535 @@ -1057,6 +1175,10 @@
537 * Create - we need to know the parent.
540 + it->it_create_mode = mode;
541 + it->it_op |= IT_CREAT;
543 error = path_lookup(pathname, LOOKUP_PARENT, nd);
546 @@ -1072,7 +1194,7 @@
549 down(&dir->d_inode->i_sem);
550 - dentry = lookup_hash(&nd->last, nd->dentry);
551 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
554 error = PTR_ERR(dentry);
555 @@ -1081,11 +1203,12 @@
559 + it->it_create_mode = mode;
560 /* Negative dentry, just create the file */
561 if (!dentry->d_inode) {
562 if (!IS_POSIXACL(dir->d_inode))
563 mode &= ~current->fs->umask;
564 - error = vfs_create(dir->d_inode, dentry, mode);
565 + error = vfs_create_it(dir->d_inode, dentry, mode, it);
566 up(&dir->d_inode->i_sem);
567 #ifndef DENTRY_WASTE_RAM
569 @@ -1193,7 +1316,7 @@
573 - error = do_truncate(dentry, 0);
574 + error = do_truncate(dentry, 0, 1);
576 put_write_access(inode);
578 @@ -1205,8 +1328,10 @@
582 + intent_release(it);
585 + intent_release(it);
589 @@ -1225,7 +1350,10 @@
590 * are done. Procfs-like symlinks just set LAST_BIND.
592 UPDATE_ATIME(dentry->d_inode);
594 error = dentry->d_inode->i_op->follow_link(dentry, nd);
596 + intent_release(it);
600 @@ -1247,13 +1375,20 @@
603 down(&dir->d_inode->i_sem);
604 - dentry = lookup_hash(&nd->last, nd->dentry);
605 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
606 putname(nd->last.name);
610 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
612 + return open_namei_it(pathname, flag, mode, nd, NULL);
617 -struct dentry *lookup_create(struct nameidata *nd, int is_dir)
618 +struct dentry *lookup_create(struct nameidata *nd, int is_dir,
619 + struct lookup_intent *it)
621 struct dentry *dentry;
623 @@ -1261,7 +1396,7 @@
624 dentry = ERR_PTR(-EEXIST);
625 if (nd->last_type != LAST_NORM)
627 - dentry = lookup_hash(&nd->last, nd->dentry);
628 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
631 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
632 @@ -1317,7 +1452,20 @@
633 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
636 - dentry = lookup_create(&nd, 0);
638 + if (nd.last_type != LAST_NORM) {
642 + if (nd.dentry->d_inode->i_op->mknod_raw) {
643 + struct inode_operations *op = nd.dentry->d_inode->i_op;
644 + error = op->mknod_raw(&nd, mode, dev);
645 + /* the file system wants to use normal vfs path now */
646 + if (error != -EOPNOTSUPP)
650 + dentry = lookup_create(&nd, 0, NULL);
651 error = PTR_ERR(dentry);
653 if (!IS_POSIXACL(nd.dentry->d_inode))
654 @@ -1339,6 +1487,7 @@
657 up(&nd.dentry->d_inode->i_sem);
662 @@ -1386,7 +1535,18 @@
663 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
666 - dentry = lookup_create(&nd, 1);
667 + if (nd.last_type != LAST_NORM) {
671 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
672 + struct inode_operations *op = nd.dentry->d_inode->i_op;
673 + error = op->mkdir_raw(&nd, mode);
674 + /* the file system wants to use normal vfs path now */
675 + if (error != -EOPNOTSUPP)
678 + dentry = lookup_create(&nd, 1, NULL);
679 error = PTR_ERR(dentry);
680 if (!IS_ERR(dentry)) {
681 if (!IS_POSIXACL(nd.dentry->d_inode))
682 @@ -1395,6 +1555,7 @@
685 up(&nd.dentry->d_inode->i_sem);
690 @@ -1495,8 +1656,16 @@
694 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
695 + struct inode_operations *op = nd.dentry->d_inode->i_op;
697 + error = op->rmdir_raw(&nd);
698 + /* the file system wants to use normal vfs path now */
699 + if (error != -EOPNOTSUPP)
702 down(&nd.dentry->d_inode->i_sem);
703 - dentry = lookup_hash(&nd.last, nd.dentry);
704 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
705 error = PTR_ERR(dentry);
706 if (!IS_ERR(dentry)) {
707 error = vfs_rmdir(nd.dentry->d_inode, dentry);
708 @@ -1554,8 +1723,15 @@
710 if (nd.last_type != LAST_NORM)
712 + if (nd.dentry->d_inode->i_op->unlink_raw) {
713 + struct inode_operations *op = nd.dentry->d_inode->i_op;
714 + error = op->unlink_raw(&nd);
715 + /* the file system wants to use normal vfs path now */
716 + if (error != -EOPNOTSUPP)
719 down(&nd.dentry->d_inode->i_sem);
720 - dentry = lookup_hash(&nd.last, nd.dentry);
721 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
722 error = PTR_ERR(dentry);
723 if (!IS_ERR(dentry)) {
724 /* Why not before? Because we want correct error value */
725 @@ -1622,15 +1798,27 @@
726 error = path_lookup(to, LOOKUP_PARENT, &nd);
729 - dentry = lookup_create(&nd, 0);
730 + if (nd.last_type != LAST_NORM) {
734 + if (nd.dentry->d_inode->i_op->symlink_raw) {
735 + struct inode_operations *op = nd.dentry->d_inode->i_op;
736 + error = op->symlink_raw(&nd, from);
737 + /* the file system wants to use normal vfs path now */
738 + if (error != -EOPNOTSUPP)
741 + dentry = lookup_create(&nd, 0, NULL);
742 error = PTR_ERR(dentry);
743 if (!IS_ERR(dentry)) {
744 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
747 up(&nd.dentry->d_inode->i_sem);
755 @@ -1706,7 +1894,18 @@
757 if (old_nd.mnt != nd.mnt)
759 - new_dentry = lookup_create(&nd, 0);
760 + if (nd.last_type != LAST_NORM) {
764 + if (nd.dentry->d_inode->i_op->link_raw) {
765 + struct inode_operations *op = nd.dentry->d_inode->i_op;
766 + error = op->link_raw(&old_nd, &nd);
767 + /* the file system wants to use normal vfs path now */
768 + if (error != -EOPNOTSUPP)
771 + new_dentry = lookup_create(&nd, 0, NULL);
772 error = PTR_ERR(new_dentry);
773 if (!IS_ERR(new_dentry)) {
774 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
775 @@ -1750,7 +1949,7 @@
778 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
779 - struct inode *new_dir, struct dentry *new_dentry)
780 + struct inode *new_dir, struct dentry *new_dentry)
783 struct inode *target;
784 @@ -1829,7 +2028,7 @@
787 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
788 - struct inode *new_dir, struct dentry *new_dentry)
789 + struct inode *new_dir, struct dentry *new_dentry)
793 @@ -1917,9 +2116,18 @@
794 if (newnd.last_type != LAST_NORM)
797 + if (old_dir->d_inode->i_op->rename_raw) {
799 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
801 + /* the file system wants to use normal vfs path now */
802 + if (error != -EOPNOTSUPP)
806 double_lock(new_dir, old_dir);
808 - old_dentry = lookup_hash(&oldnd.last, old_dir);
809 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
810 error = PTR_ERR(old_dentry);
811 if (IS_ERR(old_dentry))
813 @@ -1935,16 +2143,16 @@
814 if (newnd.last.name[newnd.last.len])
817 - new_dentry = lookup_hash(&newnd.last, new_dir);
818 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
819 error = PTR_ERR(new_dentry);
820 if (IS_ERR(new_dentry))
825 error = vfs_rename(old_dir->d_inode, old_dentry,
826 new_dir->d_inode, new_dentry);
832 @@ -1995,20 +2203,26 @@
835 static inline int __attribute__((always_inline))
836 -__vfs_follow_link(struct nameidata *nd, const char *link)
837 +__vfs_follow_link(struct nameidata *nd, const char *link,
838 + struct lookup_intent *it)
847 + else if (it != nd->intent)
848 + printk("it != nd->intent: tell phil@clusterfs.com\n");
852 if (!walk_init_root(link, nd))
853 /* weird __emul_prefix() stuff did it */
856 - res = __link_path_walk(link, nd);
857 + res = __link_path_walk_it(link, nd, it);
859 if (current->link_count || res || nd->last_type!=LAST_NORM)
861 @@ -2032,7 +2246,13 @@
863 int vfs_follow_link(struct nameidata *nd, const char *link)
865 - return __vfs_follow_link(nd, link);
866 + return __vfs_follow_link(nd, link, NULL);
869 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
870 + struct lookup_intent *it)
872 + return __vfs_follow_link(nd, link, it);
875 /* get the link contents into pagecache */
876 @@ -2074,7 +2294,7 @@
878 struct page *page = NULL;
879 char *s = page_getlink(dentry, &page);
880 - int res = __vfs_follow_link(nd, s);
881 + int res = __vfs_follow_link(nd, s, NULL);
884 page_cache_release(page);
885 Index: linux-2.4.21/fs/namespace.c
886 ===================================================================
887 --- linux-2.4.21.orig/fs/namespace.c 2004-04-24 02:38:41.000000000 -0400
888 +++ linux-2.4.21/fs/namespace.c 2004-04-26 19:06:32.000000000 -0400
891 old_nd->dentry = mnt->mnt_mountpoint;
892 old_nd->mnt = mnt->mnt_parent;
893 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
894 mnt->mnt_parent = mnt;
895 mnt->mnt_mountpoint = mnt->mnt_root;
896 list_del_init(&mnt->mnt_child);
899 mnt->mnt_parent = mntget(nd->mnt);
900 mnt->mnt_mountpoint = dget(nd->dentry);
901 + PIN(nd->dentry, nd->mnt, 1);
902 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
903 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
904 nd->dentry->d_mounted++;
909 -static int do_umount(struct vfsmount *mnt, int flags)
910 +int do_umount(struct vfsmount *mnt, int flags)
912 struct super_block * sb = mnt->mnt_sb;
914 @@ -488,14 +490,17 @@
916 struct nameidata old_nd;
917 struct vfsmount *mnt = NULL;
918 + struct lookup_intent it = { .it_op = IT_GETATTR };
919 int err = mount_is_safe(nd);
922 if (!old_name || !*old_name)
924 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
926 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
928 + intent_release(&it);
932 down_write(¤t->namespace->sem);
937 up_write(¤t->namespace->sem);
938 + intent_release(&it);
939 path_release(&old_nd);
943 unsigned long flags, void *data_page)
946 + struct lookup_intent it = { .it_op = IT_GETATTR };
951 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
953 /* ... and get the mountpoint */
954 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
956 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
958 + intent_release(&it);
962 if (flags & MS_REMOUNT)
963 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
966 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
967 dev_name, data_page);
969 + intent_release(&it);
975 struct vfsmount *tmp;
976 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
977 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
978 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
981 if (!capable(CAP_SYS_ADMIN))
982 @@ -911,14 +924,14 @@
986 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
987 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
991 if (!check_mnt(new_nd.mnt))
994 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
995 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
1000 up(&old_nd.dentry->d_inode->i_zombie);
1001 up_write(¤t->namespace->sem);
1002 path_release(&user_nd);
1003 + intent_release(&old_it);
1004 path_release(&old_nd);
1006 + intent_release(&new_it);
1007 path_release(&new_nd);
1010 Index: linux-2.4.21/fs/open.c
1011 ===================================================================
1012 --- linux-2.4.21.orig/fs/open.c 2004-04-24 02:39:01.000000000 -0400
1013 +++ linux-2.4.21/fs/open.c 2004-04-26 19:06:32.000000000 -0400
1015 #include <asm/uaccess.h>
1017 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1018 +extern int path_walk_it(const char *name, struct nameidata *nd,
1019 + struct lookup_intent *it);
1021 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1024 write_unlock(&files->file_lock);
1027 -int do_truncate(struct dentry *dentry, loff_t length)
1028 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1030 struct inode *inode = dentry->d_inode;
1031 + struct inode_operations *op = dentry->d_inode->i_op;
1033 struct iattr newattrs;
1035 @@ -110,7 +113,13 @@
1036 down(&inode->i_sem);
1037 newattrs.ia_size = length;
1038 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1039 - error = notify_change(dentry, &newattrs);
1040 + if (called_from_open)
1041 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1042 + if (op->setattr_raw) {
1043 + newattrs.ia_valid |= ATTR_RAW;
1044 + error = op->setattr_raw(inode, &newattrs);
1046 + error = notify_change(dentry, &newattrs);
1048 up_write(&inode->i_alloc_sem);
1050 @@ -121,12 +130,13 @@
1051 struct nameidata nd;
1052 struct inode * inode;
1054 + struct lookup_intent it = { .it_op = IT_GETATTR };
1057 if (length < 0) /* sorry, but loff_t says... */
1060 - error = user_path_walk(path, &nd);
1061 + error = user_path_walk_it(path, &nd, &it);
1064 inode = nd.dentry->d_inode;
1065 @@ -166,11 +176,13 @@
1066 error = locks_verify_truncate(inode, NULL, length);
1069 - error = do_truncate(nd.dentry, length);
1070 + intent_release(&it);
1071 + error = do_truncate(nd.dentry, length, 0);
1073 put_write_access(inode);
1076 + intent_release(&it);
1082 error = locks_verify_truncate(inode, file, length);
1084 - error = do_truncate(dentry, length);
1085 + error = do_truncate(dentry, length, 0);
1089 @@ -263,11 +275,13 @@
1090 struct inode * inode;
1091 struct iattr newattrs;
1093 - error = user_path_walk(filename, &nd);
1094 + error = user_path_walk_it(filename, &nd, NULL);
1097 inode = nd.dentry->d_inode;
1099 + /* this is safe without a Lustre lock because it only depends
1100 + on the super block */
1102 if (IS_RDONLY(inode))
1104 @@ -282,11 +296,25 @@
1107 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1111 + if (inode->i_op->setattr_raw) {
1112 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1114 + newattrs.ia_valid |= ATTR_RAW;
1115 + error = op->setattr_raw(inode, &newattrs);
1116 + /* the file system wants to use normal vfs path now */
1117 + if (error != -EOPNOTSUPP)
1118 + goto dput_and_out;
1123 if (current->fsuid != inode->i_uid &&
1124 (error = permission(inode,MAY_WRITE)) != 0)
1128 error = notify_change(nd.dentry, &newattrs);
1131 @@ -307,12 +335,14 @@
1132 struct inode * inode;
1133 struct iattr newattrs;
1135 - error = user_path_walk(filename, &nd);
1136 + error = user_path_walk_it(filename, &nd, NULL);
1140 inode = nd.dentry->d_inode;
1142 + /* this is safe without a Lustre lock because it only depends
1143 + on the super block */
1145 if (IS_RDONLY(inode))
1147 @@ -327,7 +357,20 @@
1148 newattrs.ia_atime = times[0].tv_sec;
1149 newattrs.ia_mtime = times[1].tv_sec;
1150 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1154 + if (inode->i_op->setattr_raw) {
1155 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1157 + newattrs.ia_valid |= ATTR_RAW;
1158 + error = op->setattr_raw(inode, &newattrs);
1159 + /* the file system wants to use normal vfs path now */
1160 + if (error != -EOPNOTSUPP)
1161 + goto dput_and_out;
1166 if (current->fsuid != inode->i_uid &&
1167 (error = permission(inode,MAY_WRITE)) != 0)
1170 int old_fsuid, old_fsgid;
1171 kernel_cap_t old_cap;
1173 + struct lookup_intent it = { .it_op = IT_GETATTR };
1175 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1177 @@ -367,13 +411,14 @@
1179 current->cap_effective = current->cap_permitted;
1181 - res = user_path_walk(filename, &nd);
1182 + res = user_path_walk_it(filename, &nd, &it);
1184 res = permission(nd.dentry->d_inode, mode);
1185 /* SuS v2 requires we report a read only fs too */
1186 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1187 && !special_file(nd.dentry->d_inode->i_mode))
1189 + intent_release(&it);
1196 struct nameidata nd;
1197 + struct lookup_intent it = { .it_op = IT_GETATTR };
1199 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1200 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1205 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1208 + intent_release(&it);
1212 @@ -439,9 +486,10 @@
1215 struct nameidata nd;
1216 + struct lookup_intent it = { .it_op = IT_GETATTR };
1218 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1219 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1220 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1221 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1225 @@ -457,39 +505,56 @@
1229 + intent_release(&it);
1235 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1236 +int chmod_common(struct dentry *dentry, mode_t mode)
1238 - struct inode * inode;
1239 - struct dentry * dentry;
1240 - struct file * file;
1242 + struct inode *inode = dentry->d_inode;
1243 struct iattr newattrs;
1248 + if (IS_RDONLY(inode))
1251 - dentry = file->f_dentry;
1252 - inode = dentry->d_inode;
1253 + if (inode->i_op->setattr_raw) {
1254 + newattrs.ia_mode = mode;
1255 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1256 + newattrs.ia_valid |= ATTR_RAW;
1257 + err = inode->i_op->setattr_raw(inode, &newattrs);
1258 + /* the file system wants to use normal vfs path now */
1259 + if (err != -EOPNOTSUPP)
1264 - if (IS_RDONLY(inode))
1267 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1271 if (mode == (mode_t) -1)
1272 mode = inode->i_mode;
1273 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1274 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1275 err = notify_change(dentry, &newattrs);
1282 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1284 + struct file * file;
1291 + err = chmod_common(file->f_dentry, mode);
1296 @@ -498,30 +563,14 @@
1297 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1299 struct nameidata nd;
1300 - struct inode * inode;
1302 - struct iattr newattrs;
1304 error = user_path_walk(filename, &nd);
1307 - inode = nd.dentry->d_inode;
1310 - if (IS_RDONLY(inode))
1311 - goto dput_and_out;
1314 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1315 - goto dput_and_out;
1316 + error = chmod_common(nd.dentry, mode);
1318 - if (mode == (mode_t) -1)
1319 - mode = inode->i_mode;
1320 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1321 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1322 - error = notify_change(nd.dentry, &newattrs);
1328 @@ -541,6 +590,20 @@
1330 if (IS_RDONLY(inode))
1333 + if (inode->i_op->setattr_raw) {
1334 + struct inode_operations *op = dentry->d_inode->i_op;
1336 + newattrs.ia_uid = user;
1337 + newattrs.ia_gid = group;
1338 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1339 + newattrs.ia_valid |= ATTR_RAW;
1340 + error = op->setattr_raw(inode, &newattrs);
1341 + /* the file system wants to use normal vfs path now */
1342 + if (error != -EOPNOTSUPP)
1347 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1351 int namei_flags, error;
1352 struct nameidata nd;
1353 + struct lookup_intent it = { .it_op = IT_OPEN };
1355 namei_flags = flags;
1356 if ((namei_flags+1) & O_ACCMODE)
1357 @@ -652,14 +716,15 @@
1358 if (namei_flags & O_TRUNC)
1361 - error = open_namei(filename, namei_flags, mode, &nd);
1363 - return dentry_open(nd.dentry, nd.mnt, flags);
1364 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1366 + return ERR_PTR(error);
1368 - return ERR_PTR(error);
1369 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1372 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1373 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1374 + int flags, struct lookup_intent *it)
1377 struct inode *inode;
1379 file_move(f, &inode->i_sb->s_files);
1381 if (f->f_op && f->f_op->open) {
1383 error = f->f_op->open(inode,f);
1389 !inode->i_mapping->a_ops->direct_IO))
1392 + intent_release(it);
1396 @@ -711,11 +779,17 @@
1400 + intent_release(it);
1403 return ERR_PTR(error);
1406 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1408 + return dentry_open_it(dentry, mnt, flags, NULL);
1412 * Find an empty file descriptor entry, and mark it busy.
1414 Index: linux-2.4.21/fs/stat.c
1415 ===================================================================
1416 --- linux-2.4.21.orig/fs/stat.c 2004-04-24 02:37:58.000000000 -0400
1417 +++ linux-2.4.21/fs/stat.c 2004-04-26 19:06:32.000000000 -0400
1419 * Revalidate the inode. This is required for proper NFS attribute caching.
1421 static __inline__ int
1422 -do_revalidate(struct dentry *dentry)
1423 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1425 struct inode * inode = dentry->d_inode;
1426 - if (inode->i_op && inode->i_op->revalidate)
1427 + if (inode->i_op && inode->i_op->revalidate_it)
1428 + return inode->i_op->revalidate_it(dentry, it);
1429 + else if (inode->i_op && inode->i_op->revalidate)
1430 return inode->i_op->revalidate(dentry);
1433 @@ -141,13 +143,15 @@
1434 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1436 struct nameidata nd;
1437 + struct lookup_intent it = { .it_op = IT_GETATTR };
1440 - error = user_path_walk(filename, &nd);
1441 + error = user_path_walk_it(filename, &nd, &it);
1443 - error = do_revalidate(nd.dentry);
1444 + error = do_revalidate(nd.dentry, &it);
1446 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1447 + intent_release(&it);
1451 @@ -157,13 +161,15 @@
1452 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1454 struct nameidata nd;
1455 + struct lookup_intent it = { .it_op = IT_GETATTR };
1458 - error = user_path_walk(filename, &nd);
1459 + error = user_path_walk_it(filename, &nd, &it);
1461 - error = do_revalidate(nd.dentry);
1462 + error = do_revalidate(nd.dentry, &it);
1464 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1465 + intent_release(&it);
1469 @@ -178,13 +184,15 @@
1470 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1472 struct nameidata nd;
1473 + struct lookup_intent it = { .it_op = IT_GETATTR };
1476 - error = user_path_walk_link(filename, &nd);
1477 + error = user_path_walk_link_it(filename, &nd, &it);
1479 - error = do_revalidate(nd.dentry);
1480 + error = do_revalidate(nd.dentry, &it);
1482 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1483 + intent_release(&it);
1487 @@ -195,13 +203,15 @@
1488 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1490 struct nameidata nd;
1491 + struct lookup_intent it = { .it_op = IT_GETATTR };
1494 - error = user_path_walk_link(filename, &nd);
1495 + error = user_path_walk_link_it(filename, &nd, &it);
1497 - error = do_revalidate(nd.dentry);
1498 + error = do_revalidate(nd.dentry, &it);
1500 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1501 + intent_release(&it);
1507 struct dentry * dentry = f->f_dentry;
1509 - err = do_revalidate(dentry);
1510 + err = do_revalidate(dentry, NULL);
1512 err = cp_old_stat(dentry->d_inode, statbuf);
1516 struct dentry * dentry = f->f_dentry;
1518 - err = do_revalidate(dentry);
1519 + err = do_revalidate(dentry, NULL);
1521 err = cp_new_stat(dentry->d_inode, statbuf);
1526 if (inode->i_op && inode->i_op->readlink &&
1527 - !(error = do_revalidate(nd.dentry))) {
1528 + !(error = do_revalidate(nd.dentry, NULL))) {
1529 UPDATE_ATIME(inode);
1530 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1532 @@ -339,12 +349,14 @@
1534 struct nameidata nd;
1536 + struct lookup_intent it = { .it_op = IT_GETATTR };
1538 - error = user_path_walk(filename, &nd);
1539 + error = user_path_walk_it(filename, &nd, &it);
1541 - error = do_revalidate(nd.dentry);
1542 + error = do_revalidate(nd.dentry, &it);
1544 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1545 + intent_release(&it);
1549 @@ -354,12 +366,14 @@
1551 struct nameidata nd;
1553 + struct lookup_intent it = { .it_op = IT_GETATTR };
1555 - error = user_path_walk_link(filename, &nd);
1556 + error = user_path_walk_link_it(filename, &nd, &it);
1558 - error = do_revalidate(nd.dentry);
1559 + error = do_revalidate(nd.dentry, &it);
1561 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1562 + intent_release(&it);
1568 struct dentry * dentry = f->f_dentry;
1570 - err = do_revalidate(dentry);
1571 + err = do_revalidate(dentry, NULL);
1573 err = cp_new_stat64(dentry->d_inode, statbuf);
1575 Index: linux-2.4.21/include/linux/dcache.h
1576 ===================================================================
1577 --- linux-2.4.21.orig/include/linux/dcache.h 2004-04-24 02:37:59.000000000 -0400
1578 +++ linux-2.4.21/include/linux/dcache.h 2004-04-26 19:06:32.000000000 -0400
1580 #include <linux/gdb.h>
1581 #include <linux/mount.h>
1582 #include <linux/kernel.h>
1583 +#include <linux/string.h>
1585 +#define IT_OPEN 0x0001
1586 +#define IT_CREAT 0x0002
1587 +#define IT_READDIR 0x0004
1588 +#define IT_GETATTR 0x0008
1589 +#define IT_LOOKUP 0x0010
1590 +#define IT_UNLINK 0x0020
1591 +#define IT_GETXATTR 0x0040
1592 +#define IT_EXEC 0x0080
1593 +#define IT_PIN 0x0100
1594 +#define IT_CHDIR 0x0200
1596 +#define IT_FL_LOCKED 0x0001
1597 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1599 +#define INTENT_MAGIC 0x19620323
1602 +struct lustre_intent_data {
1603 + int it_disposition;
1605 + __u64 it_lock_handle;
1610 +struct lookup_intent {
1612 + void (*it_op_release)(struct lookup_intent *);
1615 + int it_create_mode;
1617 + struct lustre_intent_data lustre;
1621 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1623 + memset(it, 0, sizeof(*it));
1624 + it->it_magic = INTENT_MAGIC;
1626 + it->it_flags = flags;
1631 * linux/include/linux/dcache.h
1633 int (*d_delete)(struct dentry *);
1634 void (*d_release)(struct dentry *);
1635 void (*d_iput)(struct dentry *, struct inode *);
1636 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1637 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1638 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1641 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1642 + de->d_op->d_pin(de, mnt, flag);
1643 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1644 + de->d_op->d_unpin(de, mnt, flag);
1647 +/* defined in fs/namei.c */
1648 +extern void intent_release(struct lookup_intent *it);
1649 +/* defined in fs/dcache.c */
1650 +extern void __d_rehash(struct dentry * entry, int lock);
1652 /* the dentry parameter passed to d_hash and d_compare is the parent
1653 * directory of the entries to be compared. It is used in case these
1654 * functions need any directory specific information for determining
1656 * s_nfsd_free_path semaphore will be down
1658 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1659 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1661 extern spinlock_t dcache_lock;
1663 Index: linux-2.4.21/include/linux/fs.h
1664 ===================================================================
1665 --- linux-2.4.21.orig/include/linux/fs.h 2004-04-26 18:56:44.000000000 -0400
1666 +++ linux-2.4.21/include/linux/fs.h 2004-04-26 19:06:32.000000000 -0400
1669 #define FMODE_READ 1
1670 #define FMODE_WRITE 2
1671 +#define FMODE_EXEC 4
1676 #define ATTR_MTIME_SET 256
1677 #define ATTR_FORCE 512 /* Not a change, but a change it */
1678 #define ATTR_ATTR_FLAG 1024
1679 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1680 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1681 +#define ATTR_CTIME_SET 0x2000
1684 * This is the Inode Attributes structure, used for notify_change(). It
1686 struct pipe_inode_info *i_pipe;
1687 struct block_device *i_bdev;
1688 struct char_device *i_cdev;
1689 + void *i_filterdata;
1691 unsigned long i_dnotify_mask; /* Directory notify events */
1692 struct dnotify_struct *i_dnotify; /* for directory notifications */
1695 /* needed for tty driver, and maybe others */
1697 + struct lookup_intent *f_it;
1698 struct list_head f_ep_links;
1699 spinlock_t f_ep_lock;
1705 + struct lookup_intent *intent;
1710 extern int __vfs_rmdir(struct inode *, struct dentry *);
1711 extern int vfs_rmdir(struct inode *, struct dentry *);
1712 extern int vfs_unlink(struct inode *, struct dentry *);
1713 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1714 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1715 + struct inode *new_dir, struct dentry *new_dentry);
1719 @@ -991,21 +999,32 @@
1721 struct inode_operations {
1722 int (*create) (struct inode *,struct dentry *,int);
1723 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1724 struct dentry * (*lookup) (struct inode *,struct dentry *);
1725 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1726 int (*link) (struct dentry *,struct inode *,struct dentry *);
1727 + int (*link_raw) (struct nameidata *,struct nameidata *);
1728 int (*unlink) (struct inode *,struct dentry *);
1729 + int (*unlink_raw) (struct nameidata *);
1730 int (*symlink) (struct inode *,struct dentry *,const char *);
1731 + int (*symlink_raw) (struct nameidata *,const char *);
1732 int (*mkdir) (struct inode *,struct dentry *,int);
1733 + int (*mkdir_raw) (struct nameidata *,int);
1734 int (*rmdir) (struct inode *,struct dentry *);
1735 + int (*rmdir_raw) (struct nameidata *);
1736 int (*mknod) (struct inode *,struct dentry *,int,int);
1737 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1738 int (*rename) (struct inode *, struct dentry *,
1739 struct inode *, struct dentry *);
1740 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1741 int (*readlink) (struct dentry *, char *,int);
1742 int (*follow_link) (struct dentry *, struct nameidata *);
1743 void (*truncate) (struct inode *);
1744 int (*permission) (struct inode *, int);
1745 int (*revalidate) (struct dentry *);
1746 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1747 int (*setattr) (struct dentry *, struct iattr *);
1748 + int (*setattr_raw) (struct inode *, struct iattr *);
1749 int (*getattr) (struct dentry *, struct iattr *);
1750 int (*setxattr) (struct dentry *, const char *, const void *, size_t, int);
1751 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1753 int (*remount_fs) (struct super_block *, int *, char *);
1754 void (*clear_inode) (struct inode *);
1755 void (*umount_begin) (struct super_block *);
1756 + void (*umount_lustre) (struct super_block *);
1758 /* Following are for knfsd to interact with "interesting" filesystems
1759 * Currently just reiserfs, but possibly FAT and others later
1760 @@ -1204,10 +1223,14 @@
1762 asmlinkage long sys_open(const char *, int, int);
1763 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1764 -extern int do_truncate(struct dentry *, loff_t start);
1765 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1767 extern struct file *filp_open(const char *, int, int);
1768 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1769 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1770 + struct nameidata *nd, struct lookup_intent *it);
1771 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1772 + int flags, struct lookup_intent *it);
1773 extern int filp_close(struct file *, fl_owner_t id);
1774 extern char * getname(const char *);
1776 @@ -1503,6 +1526,7 @@
1777 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1779 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1780 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1781 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1782 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1783 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1784 @@ -1515,6 +1539,8 @@
1785 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1786 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1787 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1788 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1789 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1791 extern void inode_init_once(struct inode *);
1792 extern void _inode_init_once(struct inode *);
1793 @@ -1666,6 +1692,8 @@
1795 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1796 extern int vfs_follow_link(struct nameidata *, const char *);
1797 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1798 + struct lookup_intent *it);
1799 extern int page_readlink(struct dentry *, char *, int);
1800 extern int page_follow_link(struct dentry *, struct nameidata *);
1801 extern struct inode_operations page_symlink_inode_operations;
1802 Index: linux-2.4.21/include/linux/fs_struct.h
1803 ===================================================================
1804 --- linux-2.4.21.orig/include/linux/fs_struct.h 2001-07-13 18:10:44.000000000 -0400
1805 +++ linux-2.4.21/include/linux/fs_struct.h 2004-04-26 19:06:32.000000000 -0400
1807 write_lock(&fs->lock);
1808 old_root = fs->root;
1809 old_rootmnt = fs->rootmnt;
1810 + PIN(dentry, mnt, 1);
1811 fs->rootmnt = mntget(mnt);
1812 fs->root = dget(dentry);
1813 write_unlock(&fs->lock);
1815 + UNPIN(old_root, old_rootmnt, 1);
1817 mntput(old_rootmnt);
1820 write_lock(&fs->lock);
1822 old_pwdmnt = fs->pwdmnt;
1823 + PIN(dentry, mnt, 0);
1824 fs->pwdmnt = mntget(mnt);
1825 fs->pwd = dget(dentry);
1826 write_unlock(&fs->lock);
1828 + UNPIN(old_pwd, old_pwdmnt, 0);
1832 Index: linux-2.4.21/kernel/exit.c
1833 ===================================================================
1834 --- linux-2.4.21.orig/kernel/exit.c 2004-04-24 02:39:01.000000000 -0400
1835 +++ linux-2.4.21/kernel/exit.c 2004-04-26 19:06:32.000000000 -0400
1836 @@ -292,11 +292,14 @@
1838 /* No need to hold fs->lock if we are killing it */
1839 if (atomic_dec_and_test(&fs->count)) {
1840 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1841 + UNPIN(fs->root, fs->rootmnt, 1);
1843 mntput(fs->rootmnt);
1847 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1849 mntput(fs->altrootmnt);
1851 Index: linux-2.4.21/kernel/fork.c
1852 ===================================================================
1853 --- linux-2.4.21.orig/kernel/fork.c 2004-04-24 02:39:01.000000000 -0400
1854 +++ linux-2.4.21/kernel/fork.c 2004-04-26 19:06:32.000000000 -0400
1855 @@ -466,10 +466,13 @@
1856 fs->umask = old->umask;
1857 read_lock(&old->lock);
1858 fs->rootmnt = mntget(old->rootmnt);
1859 + PIN(old->pwd, old->pwdmnt, 0);
1860 + PIN(old->root, old->rootmnt, 1);
1861 fs->root = dget(old->root);
1862 fs->pwdmnt = mntget(old->pwdmnt);
1863 fs->pwd = dget(old->pwd);
1865 + PIN(old->altroot, old->altrootmnt, 1);
1866 fs->altrootmnt = mntget(old->altrootmnt);
1867 fs->altroot = dget(old->altroot);
1869 Index: linux-2.4.21/kernel/ksyms.c
1870 ===================================================================
1871 --- linux-2.4.21.orig/kernel/ksyms.c 2004-04-26 18:56:44.000000000 -0400
1872 +++ linux-2.4.21/kernel/ksyms.c 2004-04-26 19:06:32.000000000 -0400
1874 EXPORT_SYMBOL(set_page_dirty);
1875 EXPORT_SYMBOL(vfs_readlink);
1876 EXPORT_SYMBOL(vfs_follow_link);
1877 +EXPORT_SYMBOL(vfs_follow_link_it);
1878 +EXPORT_SYMBOL(do_umount);
1879 EXPORT_SYMBOL(page_readlink);
1880 EXPORT_SYMBOL(page_follow_link);
1881 EXPORT_SYMBOL(page_symlink_inode_operations);
1882 ===== include/linux/mount.h 1.7 vs edited =====
1883 --- linux-2.4.21.orig/include/linux/mount.h Tue Feb 5 09:49:35 2002
1884 +++ linux-2.4.21/include/linux/mount.h Tue May 4 19:23:48 2004
1887 char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
1888 struct list_head mnt_list;
1889 + struct list_head mnt_lustre_list; /* GNS mount list */
1890 + unsigned long mnt_last_used; /* for GNS auto-umount (jiffies) */
1893 static inline struct vfsmount *mntget(struct vfsmount *mnt)
1897 extern void __mntput(struct vfsmount *mnt);
1898 +extern int do_umount(struct vfsmount *mnt, int flags);
1900 static inline void mntput(struct vfsmount *mnt)