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: lum/fs/dcache.c
16 ===================================================================
17 --- lum.orig/fs/dcache.c 2003-06-13 10:51:37.000000000 -0400
18 +++ lum/fs/dcache.c 2004-06-07 17:19:43.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 { \
57 ===================================================================
58 --- lum.orig/fs/exec.c 2003-11-28 13:26:21.000000000 -0500
59 +++ lum/fs/exec.c 2004-06-07 17:19:43.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 @@ -1132,7 +1139,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: lum/fs/namei.c
122 ===================================================================
123 --- lum.orig/fs/namei.c 2003-08-25 07:44:43.000000000 -0400
124 +++ lum/fs/namei.c 2004-06-07 17:24:47.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 @@ -260,10 +267,20 @@
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 nameidata *nd,
146 + struct lookup_intent *it)
148 struct dentry * dentry = d_lookup(parent, name);
150 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
151 + if (!dentry->d_op->d_revalidate_it(dentry, flags, nd, it) &&
152 + !d_invalidate(dentry)) {
158 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
159 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
161 @@ -281,11 +298,16 @@
162 * make sure that nobody added the entry to the dcache in the meantime..
165 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
166 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
167 + int flags, struct nameidata *nd,
168 + struct lookup_intent *it)
170 struct dentry * result;
171 struct inode *dir = parent->d_inode;
178 * First re-do the cached lookup just in case it was created
180 result = ERR_PTR(-ENOMEM);
183 + if (dir->i_op->lookup_it)
184 + result = dir->i_op->lookup_it(dir, dentry, nd, it, flags);
186 result = dir->i_op->lookup(dir, dentry);
191 result = ERR_PTR(-ENOENT);
193 + } else if (result->d_op && result->d_op->d_revalidate_it) {
194 + if (!result->d_op->d_revalidate_it(result, flags, nd, it) &&
195 + !d_invalidate(result)) {
198 + result = ERR_PTR(-ESTALE);
199 + if (!IS_ERR(result))
206 * Without that kind of total limit, nasty chains of consecutive
207 * symlinks can cause almost arbitrarily long lookups.
209 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
210 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
211 + struct lookup_intent *it)
214 if (current->link_count >= 5)
215 @@ -346,10 +381,12 @@
216 current->link_count++;
217 current->total_link_count++;
218 UPDATE_ATIME(dentry->d_inode);
220 err = dentry->d_inode->i_op->follow_link(dentry, nd);
221 current->link_count--;
224 + intent_release(it);
230 * We expect 'base' to be positive and a directory.
232 -int link_path_walk(const char * name, struct nameidata *nd)
233 +int link_path_walk_it(const char *name, struct nameidata *nd,
234 + struct lookup_intent *it)
236 struct dentry *dentry;
241 /* This does the actual lookups.. */
242 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
243 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, nd, NULL);
245 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
246 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, nd, NULL);
247 err = PTR_ERR(dentry);
253 if (inode->i_op->follow_link) {
254 - err = do_follow_link(dentry, nd);
255 + err = do_follow_link(dentry, nd, NULL);
263 - if (!inode->i_op->lookup)
264 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
267 /* here ends the main loop */
272 - dentry = cached_lookup(nd->dentry, &this, 0);
273 + dentry = cached_lookup(nd->dentry, &this, 0, nd, it);
275 - dentry = real_lookup(nd->dentry, &this, 0);
276 + dentry = real_lookup(nd->dentry, &this, 0, nd, it);
277 err = PTR_ERR(dentry);
281 inode = dentry->d_inode;
282 if ((lookup_flags & LOOKUP_FOLLOW)
283 && inode && inode->i_op && inode->i_op->follow_link) {
284 - err = do_follow_link(dentry, nd);
285 + err = do_follow_link(dentry, nd, it);
291 if (lookup_flags & LOOKUP_DIRECTORY) {
293 - if (!inode->i_op || !inode->i_op->lookup)
294 + if (!inode->i_op ||
295 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
300 * Check the cached dentry for staleness.
303 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
305 + if (!dentry->d_op->d_revalidate_it(dentry, 0, nd, it)) {
306 + struct dentry *new;
307 + err = permission(dentry->d_parent->d_inode,
311 + new = real_lookup(dentry->d_parent,
312 + &dentry->d_name, 0, nd, it);
314 + err = PTR_ERR(new);
317 + d_invalidate(dentry);
321 + if (!nd->dentry->d_inode)
324 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
326 if (!dentry->d_op->d_revalidate(dentry, 0)) {
327 @@ -648,15 +708,28 @@
332 + intent_release(it);
338 +int link_path_walk(const char * name, struct nameidata *nd)
340 + return link_path_walk_it(name, nd, NULL);
343 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
345 + current->total_link_count = 0;
346 + return link_path_walk_it(name, nd, it);
349 int path_walk(const char * name, struct nameidata *nd)
351 current->total_link_count = 0;
352 - return link_path_walk(name, nd);
353 + return link_path_walk_it(name, nd, NULL);
361 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
362 + struct lookup_intent *it)
365 + if (path_init(path, flags, nd))
366 + error = path_walk_it(path, nd, it);
372 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
377 nd->last_type = LAST_ROOT; /* if there are only slashes... */
381 return walk_init_root(name,nd);
382 read_lock(¤t->fs->lock);
384 * needs parent already locked. Doesn't follow mounts.
387 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
388 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
389 + struct nameidata *nd, struct lookup_intent *it)
391 struct dentry * dentry;
393 @@ -792,13 +878,16 @@
397 - dentry = cached_lookup(base, name, 0);
398 + dentry = cached_lookup(base, name, 0, nd, it);
400 struct dentry *new = d_alloc(base, name);
401 dentry = ERR_PTR(-ENOMEM);
405 + if (inode->i_op->lookup_it)
406 + dentry = inode->i_op->lookup_it(inode, new, nd, it, 0);
408 dentry = inode->i_op->lookup(inode, new);
415 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base,
416 + struct nameidata *nd)
418 + return lookup_hash_it(name, base, nd, NULL);
423 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
427 this.hash = end_name_hash(hash);
429 - return lookup_hash(&this, base);
430 + return lookup_hash_it(&this, base, NULL, NULL);
432 return ERR_PTR(-EACCES);
438 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
439 + struct lookup_intent *it)
444 + tmp = getname(name);
445 + err = PTR_ERR(tmp);
446 + if (!IS_ERR(tmp)) {
448 + if (path_init(tmp, flags, nd))
449 + err = path_walk_it(tmp, nd, it);
456 * It's inline, so penalty for filesystems that don't use sticky bit is
462 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
463 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
464 + struct lookup_intent *it)
468 @@ -970,12 +1084,15 @@
471 error = -EACCES; /* shouldn't it be ENOSYS? */
472 - if (!dir->i_op || !dir->i_op->create)
473 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
478 - error = dir->i_op->create(dir, dentry, mode);
479 + if (dir->i_op->create_it)
480 + error = dir->i_op->create_it(dir, dentry, mode, it);
482 + error = dir->i_op->create(dir, dentry, mode);
486 @@ -984,6 +1101,11 @@
490 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
492 + return vfs_create_it(dir, dentry, mode, NULL);
499 * for symlinks (where the permissions are checked later).
502 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
503 +int open_namei_it(const char *pathname, int flag, int mode,
504 + struct nameidata *nd, struct lookup_intent *it)
506 int acc_mode, error = 0;
508 @@ -1008,11 +1131,14 @@
510 acc_mode = ACC_MODE(flag);
513 + it->it_flags = flag;
516 * The simplest case - just a plain lookup.
518 if (!(flag & O_CREAT)) {
519 - error = path_lookup(pathname, lookup_flags(flag), nd);
520 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
524 @@ -1022,6 +1148,10 @@
526 * Create - we need to know the parent.
529 + it->it_create_mode = mode;
530 + it->it_op |= IT_CREAT;
532 error = path_lookup(pathname, LOOKUP_PARENT, nd);
535 @@ -1037,7 +1167,7 @@
538 down(&dir->d_inode->i_sem);
539 - dentry = lookup_hash(&nd->last, nd->dentry);
540 + dentry = lookup_hash_it(&nd->last, nd->dentry, nd, it);
543 error = PTR_ERR(dentry);
544 @@ -1046,10 +1176,11 @@
548 + it->it_create_mode = mode;
549 /* Negative dentry, just create the file */
550 if (!dentry->d_inode) {
551 - error = vfs_create(dir->d_inode, dentry,
552 - mode & ~current->fs->umask);
553 + error = vfs_create_it(dir->d_inode, dentry,
554 + mode & ~current->fs->umask, it);
555 up(&dir->d_inode->i_sem);
558 @@ -1153,7 +1284,7 @@
562 - error = do_truncate(dentry, 0);
563 + error = do_truncate(dentry, 0, 1);
565 put_write_access(inode);
567 @@ -1165,8 +1296,10 @@
571 + intent_release(it);
574 + intent_release(it);
578 @@ -1185,7 +1318,10 @@
579 * are done. Procfs-like symlinks just set LAST_BIND.
581 UPDATE_ATIME(dentry->d_inode);
583 error = dentry->d_inode->i_op->follow_link(dentry, nd);
585 + intent_release(it);
589 @@ -1207,13 +1343,20 @@
592 down(&dir->d_inode->i_sem);
593 - dentry = lookup_hash(&nd->last, nd->dentry);
594 + dentry = lookup_hash_it(&nd->last, nd->dentry, nd, it);
595 putname(nd->last.name);
599 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
601 + return open_namei_it(pathname, flag, mode, nd, NULL);
606 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
607 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
608 + struct lookup_intent *it)
610 struct dentry *dentry;
612 @@ -1221,7 +1364,7 @@
613 dentry = ERR_PTR(-EEXIST);
614 if (nd->last_type != LAST_NORM)
616 - dentry = lookup_hash(&nd->last, nd->dentry);
617 + dentry = lookup_hash_it(&nd->last, nd->dentry, nd, it);
620 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
621 @@ -1277,7 +1420,20 @@
622 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
625 - dentry = lookup_create(&nd, 0);
627 + if (nd.last_type != LAST_NORM) {
631 + if (nd.dentry->d_inode->i_op->mknod_raw) {
632 + struct inode_operations *op = nd.dentry->d_inode->i_op;
633 + error = op->mknod_raw(&nd, mode, dev);
634 + /* the file system wants to use normal vfs path now */
635 + if (error != -EOPNOTSUPP)
639 + dentry = lookup_create(&nd, 0, NULL);
640 error = PTR_ERR(dentry);
642 mode &= ~current->fs->umask;
643 @@ -1298,6 +1454,7 @@
646 up(&nd.dentry->d_inode->i_sem);
651 @@ -1345,7 +1502,18 @@
652 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
655 - dentry = lookup_create(&nd, 1);
656 + if (nd.last_type != LAST_NORM) {
660 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
661 + struct inode_operations *op = nd.dentry->d_inode->i_op;
662 + error = op->mkdir_raw(&nd, mode);
663 + /* the file system wants to use normal vfs path now */
664 + if (error != -EOPNOTSUPP)
667 + dentry = lookup_create(&nd, 1, NULL);
668 error = PTR_ERR(dentry);
669 if (!IS_ERR(dentry)) {
670 error = vfs_mkdir(nd.dentry->d_inode, dentry,
671 @@ -1353,6 +1521,7 @@
674 up(&nd.dentry->d_inode->i_sem);
679 @@ -1453,8 +1622,16 @@
683 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
684 + struct inode_operations *op = nd.dentry->d_inode->i_op;
686 + error = op->rmdir_raw(&nd);
687 + /* the file system wants to use normal vfs path now */
688 + if (error != -EOPNOTSUPP)
691 down(&nd.dentry->d_inode->i_sem);
692 - dentry = lookup_hash(&nd.last, nd.dentry);
693 + dentry = lookup_hash_it(&nd.last, nd.dentry, &nd, NULL);
694 error = PTR_ERR(dentry);
695 if (!IS_ERR(dentry)) {
696 error = vfs_rmdir(nd.dentry->d_inode, dentry);
697 @@ -1512,8 +1689,15 @@
699 if (nd.last_type != LAST_NORM)
701 + if (nd.dentry->d_inode->i_op->unlink_raw) {
702 + struct inode_operations *op = nd.dentry->d_inode->i_op;
703 + error = op->unlink_raw(&nd);
704 + /* the file system wants to use normal vfs path now */
705 + if (error != -EOPNOTSUPP)
708 down(&nd.dentry->d_inode->i_sem);
709 - dentry = lookup_hash(&nd.last, nd.dentry);
710 + dentry = lookup_hash_it(&nd.last, nd.dentry, &nd, NULL);
711 error = PTR_ERR(dentry);
712 if (!IS_ERR(dentry)) {
713 /* Why not before? Because we want correct error value */
714 @@ -1580,15 +1764,27 @@
715 error = path_lookup(to, LOOKUP_PARENT, &nd);
718 - dentry = lookup_create(&nd, 0);
719 + if (nd.last_type != LAST_NORM) {
723 + if (nd.dentry->d_inode->i_op->symlink_raw) {
724 + struct inode_operations *op = nd.dentry->d_inode->i_op;
725 + error = op->symlink_raw(&nd, from);
726 + /* the file system wants to use normal vfs path now */
727 + if (error != -EOPNOTSUPP)
730 + dentry = lookup_create(&nd, 0, NULL);
731 error = PTR_ERR(dentry);
732 if (!IS_ERR(dentry)) {
733 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
736 up(&nd.dentry->d_inode->i_sem);
744 @@ -1664,7 +1860,18 @@
746 if (old_nd.mnt != nd.mnt)
748 - new_dentry = lookup_create(&nd, 0);
749 + if (nd.last_type != LAST_NORM) {
753 + if (nd.dentry->d_inode->i_op->link_raw) {
754 + struct inode_operations *op = nd.dentry->d_inode->i_op;
755 + error = op->link_raw(&old_nd, &nd);
756 + /* the file system wants to use normal vfs path now */
757 + if (error != -EOPNOTSUPP)
760 + new_dentry = lookup_create(&nd, 0, NULL);
761 error = PTR_ERR(new_dentry);
762 if (!IS_ERR(new_dentry)) {
763 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
764 @@ -1708,7 +1915,7 @@
767 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
768 - struct inode *new_dir, struct dentry *new_dentry)
769 + struct inode *new_dir, struct dentry *new_dentry)
772 struct inode *target;
773 @@ -1787,7 +1994,7 @@
776 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
777 - struct inode *new_dir, struct dentry *new_dentry)
778 + struct inode *new_dir, struct dentry *new_dentry)
782 @@ -1875,9 +2082,18 @@
783 if (newnd.last_type != LAST_NORM)
786 + if (old_dir->d_inode->i_op->rename_raw) {
788 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
790 + /* the file system wants to use normal vfs path now */
791 + if (error != -EOPNOTSUPP)
795 double_lock(new_dir, old_dir);
797 - old_dentry = lookup_hash(&oldnd.last, old_dir);
798 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, &oldnd, NULL);
799 error = PTR_ERR(old_dentry);
800 if (IS_ERR(old_dentry))
802 @@ -1893,16 +2109,16 @@
803 if (newnd.last.name[newnd.last.len])
806 - new_dentry = lookup_hash(&newnd.last, new_dir);
807 + new_dentry = lookup_hash_it(&newnd.last, new_dir, &newnd, NULL);
808 error = PTR_ERR(new_dentry);
809 if (IS_ERR(new_dentry))
814 error = vfs_rename(old_dir->d_inode, old_dentry,
815 new_dir->d_inode, new_dentry);
821 @@ -1953,20 +2169,26 @@
825 -__vfs_follow_link(struct nameidata *nd, const char *link)
826 +__vfs_follow_link(struct nameidata *nd, const char *link,
827 + struct lookup_intent *it)
836 + else if (it != nd->intent)
837 + printk("it != nd->intent: tell phil@clusterfs.com\n");
841 if (!walk_init_root(link, nd))
842 /* weird __emul_prefix() stuff did it */
845 - res = link_path_walk(link, nd);
846 + res = link_path_walk_it(link, nd, it);
848 if (current->link_count || res || nd->last_type!=LAST_NORM)
850 @@ -1990,7 +2212,13 @@
852 int vfs_follow_link(struct nameidata *nd, const char *link)
854 - return __vfs_follow_link(nd, link);
855 + return __vfs_follow_link(nd, link, NULL);
858 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
859 + struct lookup_intent *it)
861 + return __vfs_follow_link(nd, link, it);
864 /* get the link contents into pagecache */
865 @@ -2032,7 +2260,7 @@
867 struct page *page = NULL;
868 char *s = page_getlink(dentry, &page);
869 - int res = __vfs_follow_link(nd, s);
870 + int res = __vfs_follow_link(nd, s, NULL);
873 page_cache_release(page);
874 Index: lum/fs/namespace.c
875 ===================================================================
876 --- lum.orig/fs/namespace.c 2003-11-28 13:26:21.000000000 -0500
877 +++ lum/fs/namespace.c 2004-06-07 17:19:43.000000000 -0400
879 #include <linux/quotaops.h>
880 #include <linux/acct.h>
881 #include <linux/module.h>
882 +#include <linux/fs.h>
884 #include <asm/uaccess.h>
887 INIT_LIST_HEAD(&mnt->mnt_child);
888 INIT_LIST_HEAD(&mnt->mnt_mounts);
889 INIT_LIST_HEAD(&mnt->mnt_list);
890 + INIT_LIST_HEAD(&mnt->mnt_lustre_list);
892 int size = strlen(name)+1;
893 char * newname = kmalloc(size, GFP_KERNEL);
896 old_nd->dentry = mnt->mnt_mountpoint;
897 old_nd->mnt = mnt->mnt_parent;
898 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
899 mnt->mnt_parent = mnt;
900 mnt->mnt_mountpoint = mnt->mnt_root;
901 list_del_init(&mnt->mnt_child);
904 mnt->mnt_parent = mntget(nd->mnt);
905 mnt->mnt_mountpoint = dget(nd->dentry);
906 + PIN(nd->dentry, nd->mnt, 1);
907 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
908 list_add_tail(&mnt->mnt_child, &nd->mnt->mnt_mounts);
909 nd->dentry->d_mounted++;
912 struct super_block *sb = mnt->mnt_sb;
914 + spin_lock(&dcache_lock);
915 + list_del(&mnt->mnt_lustre_list);
916 + spin_unlock(&dcache_lock);
924 -static int do_umount(struct vfsmount *mnt, int flags)
925 +int do_umount(struct vfsmount *mnt, int flags)
927 struct super_block * sb = mnt->mnt_sb;
933 + if (sb->s_op->umount_lustre)
934 + sb->s_op->umount_lustre(sb);
935 if( (flags&MNT_FORCE) && sb->s_op->umount_begin)
936 sb->s_op->umount_begin(sb);
938 @@ -488,14 +497,17 @@
940 struct nameidata old_nd;
941 struct vfsmount *mnt = NULL;
942 + struct lookup_intent it = { .it_op = IT_GETATTR };
943 int err = mount_is_safe(nd);
946 if (!old_name || !*old_name)
948 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
950 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
952 + intent_release(&it);
956 down_write(¤t->namespace->sem);
961 up_write(¤t->namespace->sem);
962 + intent_release(&it);
963 path_release(&old_nd);
967 unsigned long flags, void *data_page)
970 + struct lookup_intent it = { .it_op = IT_GETATTR };
975 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
977 /* ... and get the mountpoint */
978 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
980 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
982 + intent_release(&it);
986 if (flags & MS_REMOUNT)
987 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
990 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
991 dev_name, data_page);
993 + intent_release(&it);
999 struct vfsmount *tmp;
1000 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
1001 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
1002 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
1005 if (!capable(CAP_SYS_ADMIN))
1006 @@ -911,14 +931,14 @@
1010 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
1011 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
1015 if (!check_mnt(new_nd.mnt))
1018 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
1019 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
1023 @@ -973,8 +993,10 @@
1024 up(&old_nd.dentry->d_inode->i_zombie);
1025 up_write(¤t->namespace->sem);
1026 path_release(&user_nd);
1027 + intent_release(&old_it);
1028 path_release(&old_nd);
1030 + intent_release(&new_it);
1031 path_release(&new_nd);
1034 Index: lum/fs/open.c
1035 ===================================================================
1036 --- lum.orig/fs/open.c 2003-08-25 07:44:43.000000000 -0400
1037 +++ lum/fs/open.c 2004-06-07 17:19:43.000000000 -0400
1039 #include <asm/uaccess.h>
1041 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1042 +extern int path_walk_it(const char *name, struct nameidata *nd,
1043 + struct lookup_intent *it);
1045 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1048 write_unlock(&files->file_lock);
1051 -int do_truncate(struct dentry *dentry, loff_t length)
1052 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1054 struct inode *inode = dentry->d_inode;
1055 + struct inode_operations *op = dentry->d_inode->i_op;
1057 struct iattr newattrs;
1059 @@ -109,7 +112,13 @@
1060 down(&inode->i_sem);
1061 newattrs.ia_size = length;
1062 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1063 - error = notify_change(dentry, &newattrs);
1064 + if (called_from_open)
1065 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1066 + if (op->setattr_raw) {
1067 + newattrs.ia_valid |= ATTR_RAW;
1068 + error = op->setattr_raw(inode, &newattrs);
1070 + error = notify_change(dentry, &newattrs);
1072 up_write(&inode->i_alloc_sem);
1074 @@ -120,12 +129,13 @@
1075 struct nameidata nd;
1076 struct inode * inode;
1078 + struct lookup_intent it = { .it_op = IT_GETATTR };
1081 if (length < 0) /* sorry, but loff_t says... */
1084 - error = user_path_walk(path, &nd);
1085 + error = user_path_walk_it(path, &nd, &it);
1088 inode = nd.dentry->d_inode;
1089 @@ -165,11 +175,13 @@
1090 error = locks_verify_truncate(inode, NULL, length);
1093 - error = do_truncate(nd.dentry, length);
1094 + intent_release(&it);
1095 + error = do_truncate(nd.dentry, length, 0);
1097 put_write_access(inode);
1100 + intent_release(&it);
1106 error = locks_verify_truncate(inode, file, length);
1108 - error = do_truncate(dentry, length);
1109 + error = do_truncate(dentry, length, 0);
1113 @@ -262,11 +274,13 @@
1114 struct inode * inode;
1115 struct iattr newattrs;
1117 - error = user_path_walk(filename, &nd);
1118 + error = user_path_walk_it(filename, &nd, NULL);
1121 inode = nd.dentry->d_inode;
1123 + /* this is safe without a Lustre lock because it only depends
1124 + on the super block */
1126 if (IS_RDONLY(inode))
1128 @@ -281,11 +295,25 @@
1131 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1135 + if (inode->i_op->setattr_raw) {
1136 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1138 + newattrs.ia_valid |= ATTR_RAW;
1139 + error = op->setattr_raw(inode, &newattrs);
1140 + /* the file system wants to use normal vfs path now */
1141 + if (error != -EOPNOTSUPP)
1142 + goto dput_and_out;
1147 if (current->fsuid != inode->i_uid &&
1148 (error = permission(inode,MAY_WRITE)) != 0)
1152 error = notify_change(nd.dentry, &newattrs);
1155 @@ -306,12 +334,14 @@
1156 struct inode * inode;
1157 struct iattr newattrs;
1159 - error = user_path_walk(filename, &nd);
1160 + error = user_path_walk_it(filename, &nd, NULL);
1164 inode = nd.dentry->d_inode;
1166 + /* this is safe without a Lustre lock because it only depends
1167 + on the super block */
1169 if (IS_RDONLY(inode))
1171 @@ -326,7 +356,20 @@
1172 newattrs.ia_atime = times[0].tv_sec;
1173 newattrs.ia_mtime = times[1].tv_sec;
1174 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1178 + if (inode->i_op->setattr_raw) {
1179 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1181 + newattrs.ia_valid |= ATTR_RAW;
1182 + error = op->setattr_raw(inode, &newattrs);
1183 + /* the file system wants to use normal vfs path now */
1184 + if (error != -EOPNOTSUPP)
1185 + goto dput_and_out;
1190 if (current->fsuid != inode->i_uid &&
1191 (error = permission(inode,MAY_WRITE)) != 0)
1194 int old_fsuid, old_fsgid;
1195 kernel_cap_t old_cap;
1197 + struct lookup_intent it = { .it_op = IT_GETATTR };
1199 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1201 @@ -366,13 +410,14 @@
1203 current->cap_effective = current->cap_permitted;
1205 - res = user_path_walk(filename, &nd);
1206 + res = user_path_walk_it(filename, &nd, &it);
1208 res = permission(nd.dentry->d_inode, mode);
1209 /* SuS v2 requires we report a read only fs too */
1210 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1211 && !special_file(nd.dentry->d_inode->i_mode))
1213 + intent_release(&it);
1220 struct nameidata nd;
1221 + struct lookup_intent it = { .it_op = IT_CHDIR };
1223 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1224 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1229 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1232 + intent_release(&it);
1236 @@ -438,9 +485,10 @@
1239 struct nameidata nd;
1240 + struct lookup_intent it = { .it_op = IT_GETATTR };
1242 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1243 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1244 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1245 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1249 @@ -456,39 +504,56 @@
1253 + intent_release(&it);
1259 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1260 +int chmod_common(struct dentry *dentry, mode_t mode)
1262 - struct inode * inode;
1263 - struct dentry * dentry;
1264 - struct file * file;
1266 + struct inode *inode = dentry->d_inode;
1267 struct iattr newattrs;
1272 + if (IS_RDONLY(inode))
1275 - dentry = file->f_dentry;
1276 - inode = dentry->d_inode;
1277 + if (inode->i_op->setattr_raw) {
1278 + newattrs.ia_mode = mode;
1279 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1280 + newattrs.ia_valid |= ATTR_RAW;
1281 + err = inode->i_op->setattr_raw(inode, &newattrs);
1282 + /* the file system wants to use normal vfs path now */
1283 + if (err != -EOPNOTSUPP)
1288 - if (IS_RDONLY(inode))
1291 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1295 if (mode == (mode_t) -1)
1296 mode = inode->i_mode;
1297 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1298 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1299 err = notify_change(dentry, &newattrs);
1306 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1308 + struct file * file;
1315 + err = chmod_common(file->f_dentry, mode);
1320 @@ -497,30 +562,14 @@
1321 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1323 struct nameidata nd;
1324 - struct inode * inode;
1326 - struct iattr newattrs;
1328 error = user_path_walk(filename, &nd);
1331 - inode = nd.dentry->d_inode;
1334 - if (IS_RDONLY(inode))
1335 - goto dput_and_out;
1338 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1339 - goto dput_and_out;
1340 + error = chmod_common(nd.dentry, mode);
1342 - if (mode == (mode_t) -1)
1343 - mode = inode->i_mode;
1344 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1345 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1346 - error = notify_change(nd.dentry, &newattrs);
1352 @@ -540,6 +589,20 @@
1354 if (IS_RDONLY(inode))
1357 + if (inode->i_op->setattr_raw) {
1358 + struct inode_operations *op = dentry->d_inode->i_op;
1360 + newattrs.ia_uid = user;
1361 + newattrs.ia_gid = group;
1362 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1363 + newattrs.ia_valid |= ATTR_RAW;
1364 + error = op->setattr_raw(inode, &newattrs);
1365 + /* the file system wants to use normal vfs path now */
1366 + if (error != -EOPNOTSUPP)
1371 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1375 int namei_flags, error;
1376 struct nameidata nd;
1377 + struct lookup_intent it = { .it_op = IT_OPEN };
1379 namei_flags = flags;
1380 if ((namei_flags+1) & O_ACCMODE)
1381 @@ -651,14 +715,15 @@
1382 if (namei_flags & O_TRUNC)
1385 - error = open_namei(filename, namei_flags, mode, &nd);
1387 - return dentry_open(nd.dentry, nd.mnt, flags);
1388 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1390 + return ERR_PTR(error);
1392 - return ERR_PTR(error);
1393 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1396 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1397 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1398 + int flags, struct lookup_intent *it)
1401 struct inode *inode;
1402 @@ -695,12 +760,15 @@
1405 if (f->f_op && f->f_op->open) {
1407 error = f->f_op->open(inode,f);
1412 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1414 + intent_release(it);
1418 @@ -715,11 +783,17 @@
1422 + intent_release(it);
1425 return ERR_PTR(error);
1428 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1430 + return dentry_open_it(dentry, mnt, flags, NULL);
1434 * Find an empty file descriptor entry, and mark it busy.
1436 Index: lum/fs/stat.c
1437 ===================================================================
1438 --- lum.orig/fs/stat.c 2003-08-25 07:44:43.000000000 -0400
1439 +++ lum/fs/stat.c 2004-06-07 17:19:43.000000000 -0400
1441 * Revalidate the inode. This is required for proper NFS attribute caching.
1443 static __inline__ int
1444 -do_revalidate(struct dentry *dentry)
1445 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1447 struct inode * inode = dentry->d_inode;
1448 - if (inode->i_op && inode->i_op->revalidate)
1449 + if (inode->i_op && inode->i_op->revalidate_it)
1450 + return inode->i_op->revalidate_it(dentry, it);
1451 + else if (inode->i_op && inode->i_op->revalidate)
1452 return inode->i_op->revalidate(dentry);
1455 @@ -137,13 +139,15 @@
1456 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1458 struct nameidata nd;
1459 + struct lookup_intent it = { .it_op = IT_GETATTR };
1462 - error = user_path_walk(filename, &nd);
1463 + error = user_path_walk_it(filename, &nd, &it);
1465 - error = do_revalidate(nd.dentry);
1466 + error = do_revalidate(nd.dentry, &it);
1468 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1469 + intent_release(&it);
1473 @@ -153,13 +157,15 @@
1474 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1476 struct nameidata nd;
1477 + struct lookup_intent it = { .it_op = IT_GETATTR };
1480 - error = user_path_walk(filename, &nd);
1481 + error = user_path_walk_it(filename, &nd, &it);
1483 - error = do_revalidate(nd.dentry);
1484 + error = do_revalidate(nd.dentry, &it);
1486 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1487 + intent_release(&it);
1491 @@ -174,13 +180,15 @@
1492 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1494 struct nameidata nd;
1495 + struct lookup_intent it = { .it_op = IT_GETATTR };
1498 - error = user_path_walk_link(filename, &nd);
1499 + error = user_path_walk_link_it(filename, &nd, &it);
1501 - error = do_revalidate(nd.dentry);
1502 + error = do_revalidate(nd.dentry, &it);
1504 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1505 + intent_release(&it);
1509 @@ -191,13 +199,15 @@
1510 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1512 struct nameidata nd;
1513 + struct lookup_intent it = { .it_op = IT_GETATTR };
1516 - error = user_path_walk_link(filename, &nd);
1517 + error = user_path_walk_link_it(filename, &nd, &it);
1519 - error = do_revalidate(nd.dentry);
1520 + error = do_revalidate(nd.dentry, &it);
1522 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1523 + intent_release(&it);
1529 struct dentry * dentry = f->f_dentry;
1531 - err = do_revalidate(dentry);
1532 + err = do_revalidate(dentry, NULL);
1534 err = cp_old_stat(dentry->d_inode, statbuf);
1538 struct dentry * dentry = f->f_dentry;
1540 - err = do_revalidate(dentry);
1541 + err = do_revalidate(dentry, NULL);
1543 err = cp_new_stat(dentry->d_inode, statbuf);
1548 if (inode->i_op && inode->i_op->readlink &&
1549 - !(error = do_revalidate(nd.dentry))) {
1550 + !(error = do_revalidate(nd.dentry, NULL))) {
1551 UPDATE_ATIME(inode);
1552 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1554 @@ -335,12 +345,14 @@
1556 struct nameidata nd;
1558 + struct lookup_intent it = { .it_op = IT_GETATTR };
1560 - error = user_path_walk(filename, &nd);
1561 + error = user_path_walk_it(filename, &nd, &it);
1563 - error = do_revalidate(nd.dentry);
1564 + error = do_revalidate(nd.dentry, &it);
1566 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1567 + intent_release(&it);
1571 @@ -350,12 +362,14 @@
1573 struct nameidata nd;
1575 + struct lookup_intent it = { .it_op = IT_GETATTR };
1577 - error = user_path_walk_link(filename, &nd);
1578 + error = user_path_walk_link_it(filename, &nd, &it);
1580 - error = do_revalidate(nd.dentry);
1581 + error = do_revalidate(nd.dentry, &it);
1583 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1584 + intent_release(&it);
1590 struct dentry * dentry = f->f_dentry;
1592 - err = do_revalidate(dentry);
1593 + err = do_revalidate(dentry, NULL);
1595 err = cp_new_stat64(dentry->d_inode, statbuf);
1597 Index: lum/include/linux/dcache.h
1598 ===================================================================
1599 --- lum.orig/include/linux/dcache.h 2002-11-28 18:53:15.000000000 -0500
1600 +++ lum/include/linux/dcache.h 2004-06-07 17:19:44.000000000 -0400
1602 #include <asm/atomic.h>
1603 #include <linux/mount.h>
1604 #include <linux/kernel.h>
1605 +#include <linux/string.h>
1607 +#define IT_OPEN 0x0001
1608 +#define IT_CREAT 0x0002
1609 +#define IT_READDIR 0x0004
1610 +#define IT_GETATTR 0x0008
1611 +#define IT_LOOKUP 0x0010
1612 +#define IT_UNLINK 0x0020
1613 +#define IT_GETXATTR 0x0040
1614 +#define IT_EXEC 0x0080
1615 +#define IT_PIN 0x0100
1616 +#define IT_CHDIR 0x0200
1618 +#define IT_FL_LOCKED 0x0001
1619 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1621 +#define INTENT_MAGIC 0x19620323
1624 +struct lustre_intent_data {
1625 + int it_disposition;
1627 + __u64 it_lock_handle;
1632 +struct lookup_intent {
1634 + void (*it_op_release)(struct lookup_intent *);
1637 + int it_create_mode;
1639 + struct lustre_intent_data lustre;
1643 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1645 + memset(it, 0, sizeof(*it));
1646 + it->it_magic = INTENT_MAGIC;
1648 + it->it_flags = flags;
1653 * linux/include/linux/dcache.h
1655 unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */
1660 struct dentry_operations {
1661 int (*d_revalidate)(struct dentry *, int);
1662 int (*d_hash) (struct dentry *, struct qstr *);
1664 int (*d_delete)(struct dentry *);
1665 void (*d_release)(struct dentry *);
1666 void (*d_iput)(struct dentry *, struct inode *);
1667 + int (*d_revalidate_it)(struct dentry *, int, struct nameidata *, struct lookup_intent *);
1668 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1669 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1672 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1673 + de->d_op->d_pin(de, mnt, flag);
1674 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1675 + de->d_op->d_unpin(de, mnt, flag);
1678 +/* defined in fs/namei.c */
1679 +extern void intent_release(struct lookup_intent *it);
1680 +/* defined in fs/dcache.c */
1681 +extern void __d_rehash(struct dentry * entry, int lock);
1683 /* the dentry parameter passed to d_hash and d_compare is the parent
1684 * directory of the entries to be compared. It is used in case these
1685 * functions need any directory specific information for determining
1687 * s_nfsd_free_path semaphore will be down
1689 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1690 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1692 extern spinlock_t dcache_lock;
1694 Index: lum/include/linux/fs.h
1695 ===================================================================
1696 --- lum.orig/include/linux/fs.h 2004-06-03 16:32:26.000000000 -0400
1697 +++ lum/include/linux/fs.h 2004-06-07 17:24:37.000000000 -0400
1700 #define FMODE_READ 1
1701 #define FMODE_WRITE 2
1702 +#define FMODE_EXEC 4
1707 #define ATTR_MTIME_SET 256
1708 #define ATTR_FORCE 512 /* Not a change, but a change it */
1709 #define ATTR_ATTR_FLAG 1024
1710 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1711 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1712 +#define ATTR_CTIME_SET 0x2000
1715 * This is the Inode Attributes structure, used for notify_change(). It
1717 struct pipe_inode_info *i_pipe;
1718 struct block_device *i_bdev;
1719 struct char_device *i_cdev;
1720 + void *i_filterdata;
1722 unsigned long i_dnotify_mask; /* Directory notify events */
1723 struct dnotify_struct *i_dnotify; /* for directory notifications */
1726 /* needed for tty driver, and maybe others */
1728 + struct lookup_intent *f_it;
1730 /* preallocated helper kiobuf to speedup O_DIRECT */
1731 struct kiobuf *f_iobuf;
1736 + struct lookup_intent *intent;
1741 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1742 extern int vfs_rmdir(struct inode *, struct dentry *);
1743 extern int vfs_unlink(struct inode *, struct dentry *);
1744 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1745 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1746 + struct inode *new_dir, struct dentry *new_dentry);
1750 @@ -884,21 +892,32 @@
1752 struct inode_operations {
1753 int (*create) (struct inode *,struct dentry *,int);
1754 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1755 struct dentry * (*lookup) (struct inode *,struct dentry *);
1756 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct nameidata *, struct lookup_intent *, int flags);
1757 int (*link) (struct dentry *,struct inode *,struct dentry *);
1758 + int (*link_raw) (struct nameidata *,struct nameidata *);
1759 int (*unlink) (struct inode *,struct dentry *);
1760 + int (*unlink_raw) (struct nameidata *);
1761 int (*symlink) (struct inode *,struct dentry *,const char *);
1762 + int (*symlink_raw) (struct nameidata *,const char *);
1763 int (*mkdir) (struct inode *,struct dentry *,int);
1764 + int (*mkdir_raw) (struct nameidata *,int);
1765 int (*rmdir) (struct inode *,struct dentry *);
1766 + int (*rmdir_raw) (struct nameidata *);
1767 int (*mknod) (struct inode *,struct dentry *,int,int);
1768 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1769 int (*rename) (struct inode *, struct dentry *,
1770 struct inode *, struct dentry *);
1771 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1772 int (*readlink) (struct dentry *, char *,int);
1773 int (*follow_link) (struct dentry *, struct nameidata *);
1774 void (*truncate) (struct inode *);
1775 int (*permission) (struct inode *, int);
1776 int (*revalidate) (struct dentry *);
1777 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1778 int (*setattr) (struct dentry *, struct iattr *);
1779 + int (*setattr_raw) (struct inode *, struct iattr *);
1780 int (*getattr) (struct dentry *, struct iattr *);
1781 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
1782 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1784 int (*remount_fs) (struct super_block *, int *, char *);
1785 void (*clear_inode) (struct inode *);
1786 void (*umount_begin) (struct super_block *);
1787 + void (*umount_lustre) (struct super_block *);
1789 /* Following are for knfsd to interact with "interesting" filesystems
1790 * Currently just reiserfs, but possibly FAT and others later
1791 @@ -1094,10 +1114,14 @@
1793 asmlinkage long sys_open(const char *, int, int);
1794 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1795 -extern int do_truncate(struct dentry *, loff_t start);
1796 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1798 extern struct file *filp_open(const char *, int, int);
1799 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1800 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1801 + struct nameidata *nd, struct lookup_intent *it);
1802 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1803 + int flags, struct lookup_intent *it);
1804 extern int filp_close(struct file *, fl_owner_t id);
1805 extern char * getname(const char *);
1807 @@ -1386,6 +1410,7 @@
1808 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1810 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1811 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1812 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1813 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1814 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1815 @@ -1394,9 +1419,11 @@
1816 extern int follow_down(struct vfsmount **, struct dentry **);
1817 extern int follow_up(struct vfsmount **, struct dentry **);
1818 extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
1819 -extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1820 +extern struct dentry * lookup_hash(struct qstr *, struct dentry *, struct nameidata *);
1821 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1822 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1823 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1824 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1826 extern void inode_init_once(struct inode *);
1827 extern void iput(struct inode *);
1828 @@ -1500,6 +1527,8 @@
1830 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1831 extern int vfs_follow_link(struct nameidata *, const char *);
1832 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1833 + struct lookup_intent *it);
1834 extern int page_readlink(struct dentry *, char *, int);
1835 extern int page_follow_link(struct dentry *, struct nameidata *);
1836 extern struct inode_operations page_symlink_inode_operations;
1837 Index: lum/include/linux/fs_struct.h
1838 ===================================================================
1839 --- lum.orig/include/linux/fs_struct.h 2001-07-13 18:10:44.000000000 -0400
1840 +++ lum/include/linux/fs_struct.h 2004-06-07 17:19:44.000000000 -0400
1842 write_lock(&fs->lock);
1843 old_root = fs->root;
1844 old_rootmnt = fs->rootmnt;
1845 + PIN(dentry, mnt, 1);
1846 fs->rootmnt = mntget(mnt);
1847 fs->root = dget(dentry);
1848 write_unlock(&fs->lock);
1850 + UNPIN(old_root, old_rootmnt, 1);
1852 mntput(old_rootmnt);
1855 write_lock(&fs->lock);
1857 old_pwdmnt = fs->pwdmnt;
1858 + PIN(dentry, mnt, 0);
1859 fs->pwdmnt = mntget(mnt);
1860 fs->pwd = dget(dentry);
1861 write_unlock(&fs->lock);
1863 + UNPIN(old_pwd, old_pwdmnt, 0);
1867 Index: lum/include/linux/mount.h
1868 ===================================================================
1869 --- lum.orig/include/linux/mount.h 2001-10-05 16:05:55.000000000 -0400
1870 +++ lum/include/linux/mount.h 2004-06-07 17:19:44.000000000 -0400
1873 char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
1874 struct list_head mnt_list;
1875 + struct list_head mnt_lustre_list; /* GNS mount list */
1876 + unsigned long mnt_last_used; /* for GNS auto-umount (jiffies) */
1879 static inline struct vfsmount *mntget(struct vfsmount *mnt)
1883 extern void __mntput(struct vfsmount *mnt);
1884 +extern int do_umount(struct vfsmount *mnt, int flags);
1886 static inline void mntput(struct vfsmount *mnt)
1888 Index: lum/kernel/exit.c
1889 ===================================================================
1890 --- lum.orig/kernel/exit.c 2002-11-28 18:53:15.000000000 -0500
1891 +++ lum/kernel/exit.c 2004-06-07 17:19:44.000000000 -0400
1892 @@ -238,11 +238,14 @@
1894 /* No need to hold fs->lock if we are killing it */
1895 if (atomic_dec_and_test(&fs->count)) {
1896 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1897 + UNPIN(fs->root, fs->rootmnt, 1);
1899 mntput(fs->rootmnt);
1903 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1905 mntput(fs->altrootmnt);
1907 Index: lum/kernel/fork.c
1908 ===================================================================
1909 --- lum.orig/kernel/fork.c 2003-11-28 13:26:21.000000000 -0500
1910 +++ lum/kernel/fork.c 2004-06-07 17:19:44.000000000 -0400
1911 @@ -386,10 +386,13 @@
1912 fs->umask = old->umask;
1913 read_lock(&old->lock);
1914 fs->rootmnt = mntget(old->rootmnt);
1915 + PIN(old->pwd, old->pwdmnt, 0);
1916 + PIN(old->root, old->rootmnt, 1);
1917 fs->root = dget(old->root);
1918 fs->pwdmnt = mntget(old->pwdmnt);
1919 fs->pwd = dget(old->pwd);
1921 + PIN(old->altroot, old->altrootmnt, 1);
1922 fs->altrootmnt = mntget(old->altrootmnt);
1923 fs->altroot = dget(old->altroot);
1925 Index: lum/kernel/ksyms.c
1926 ===================================================================
1927 --- lum.orig/kernel/ksyms.c 2004-06-03 16:32:26.000000000 -0400
1928 +++ lum/kernel/ksyms.c 2004-06-07 17:25:11.000000000 -0400
1930 EXPORT_SYMBOL(mark_page_accessed);
1931 EXPORT_SYMBOL(vfs_readlink);
1932 EXPORT_SYMBOL(vfs_follow_link);
1933 +EXPORT_SYMBOL(vfs_follow_link_it);
1934 +EXPORT_SYMBOL(do_umount);
1935 EXPORT_SYMBOL(page_readlink);
1936 EXPORT_SYMBOL(page_follow_link);
1937 EXPORT_SYMBOL(page_symlink_inode_operations);
1938 Index: lum/net/unix/af_unix.c
1939 ===================================================================
1940 --- lum.orig/net/unix/af_unix.c 2002-11-28 18:53:16.000000000 -0500
1941 +++ lum/net/unix/af_unix.c 2004-06-07 17:19:44.000000000 -0400
1944 * Do the final lookup.
1946 - dentry = lookup_hash(&nd.last, nd.dentry);
1947 + dentry = lookup_hash(&nd.last, nd.dentry, &nd);
1948 err = PTR_ERR(dentry);
1950 goto out_mknod_unlock;
1951 Index: lum/drivers/hotplug/pci_hotplug_core.c
1952 ===================================================================
1953 --- lum.orig/drivers/hotplug/pci_hotplug_core.c 2003-11-28 13:26:20.000000000 -0500
1954 +++ lum/drivers/hotplug/pci_hotplug_core.c 2004-06-08 01:59:32.000000000 -0400
1957 down(&parent->d_inode->i_sem);
1959 - d = lookup_hash(&qstr,parent);
1960 + d = lookup_hash(&qstr,parent,NULL);