3 fs/namei.c | 333 ++++++++++++++++++++++++++++++++++++++--------
4 fs/namespace.c | 28 ++-
5 fs/open.c | 176 +++++++++++++++++-------
8 include/linux/dcache.h | 60 ++++++++
9 include/linux/fs.h | 32 ++++
10 include/linux/fs_struct.h | 4
14 13 files changed, 578 insertions(+), 129 deletions(-)
16 Index: linux-2.4.20/fs/dcache.c
17 ===================================================================
18 --- linux-2.4.20.orig/fs/dcache.c Wed Mar 17 13:57:05 2004
19 +++ linux-2.4.20/fs/dcache.c Wed Mar 17 13:57:11 2004
21 spin_unlock(&dcache_lock);
25 + /* network invalidation by Lustre */
26 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
27 + spin_unlock(&dcache_lock);
32 * Check whether to do a partial shrink_dcache
33 * to get rid of unused child entries.
35 * Adds a dentry to the hash according to its name.
38 -void d_rehash(struct dentry * entry)
39 +void __d_rehash(struct dentry * entry, int lock)
41 struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
42 if (!list_empty(&entry->d_hash)) BUG();
43 - spin_lock(&dcache_lock);
44 + if (lock) spin_lock(&dcache_lock);
45 list_add(&entry->d_hash, list);
46 - spin_unlock(&dcache_lock);
47 + if (lock) spin_unlock(&dcache_lock);
49 +EXPORT_SYMBOL(__d_rehash);
51 +void d_rehash(struct dentry * entry)
53 + __d_rehash(entry, 1);
56 #define do_switch(x,y) do { \
57 Index: linux-2.4.20/fs/exec.c
58 ===================================================================
59 --- linux-2.4.20.orig/fs/exec.c Wed Mar 17 13:57:05 2004
60 +++ linux-2.4.20/fs/exec.c Wed Mar 17 13:57:11 2004
65 + struct lookup_intent it = { .it_op = IT_OPEN,
66 + .it_flags = FMODE_READ|FMODE_EXEC };
68 - error = user_path_walk(library, &nd);
69 + error = user_path_walk_it(library, &nd, &it);
77 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
78 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
79 + intent_release(&it);
80 error = PTR_ERR(file);
87 + struct lookup_intent it = { .it_op = IT_OPEN,
88 + .it_flags = FMODE_READ|FMODE_EXEC };
90 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
91 + err = path_lookup_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
94 inode = nd.dentry->d_inode;
99 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
100 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
101 + intent_release(&it);
103 err = deny_write_access(file);
109 + intent_release(&it);
113 @@ -1296,7 +1303,7 @@
115 if (!file->f_op->write)
117 - if (do_truncate(file->f_dentry, 0) != 0)
118 + if (do_truncate(file->f_dentry, 0, 0) != 0)
121 retval = binfmt->core_dump(signr, regs, file);
122 Index: linux-2.4.20/fs/namei.c
123 ===================================================================
124 --- linux-2.4.20.orig/fs/namei.c Wed Mar 17 13:57:03 2004
125 +++ linux-2.4.20/fs/namei.c Wed Mar 17 13:58:01 2004
127 * XEmacs seems to be relying on it...
130 +void intent_release(struct lookup_intent *it)
132 + if (it && it->it_op_release)
133 + it->it_op_release(it);
137 /* In order to reduce some races, while at the same time doing additional
138 * checking and hopefully speeding things up, we copy filenames to the
139 * kernel data space before using them..
140 @@ -260,10 +267,19 @@
141 * Internal lookup() using the new generic dcache.
144 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
145 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
146 + int flags, 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, NULL, 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 +297,15 @@
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 lookup_intent *it)
169 struct dentry * result;
170 struct inode *dir = parent->d_inode;
177 * First re-do the cached lookup just in case it was created
179 result = ERR_PTR(-ENOMEM);
182 + if (dir->i_op->lookup_it)
183 + result = dir->i_op->lookup_it(dir, dentry, NULL, it, flags);
185 result = dir->i_op->lookup(dir, dentry);
190 result = ERR_PTR(-ENOENT);
192 + } else if (result->d_op && result->d_op->d_revalidate_it) {
193 + if (!result->d_op->d_revalidate_it(result, flags, NULL, it) &&
194 + !d_invalidate(result)) {
197 + result = ERR_PTR(-ESTALE);
198 + if (!IS_ERR(result))
205 * Without that kind of total limit, nasty chains of consecutive
206 * symlinks can cause almost arbitrarily long lookups.
208 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
209 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
210 + struct lookup_intent *it)
213 if (current->link_count >= max_recursive_link)
214 @@ -348,10 +381,18 @@
215 current->link_count++;
216 current->total_link_count++;
217 UPDATE_ATIME(dentry->d_inode);
219 err = dentry->d_inode->i_op->follow_link(dentry, nd);
220 + if (!err && it != NULL && !(it->d.lustre.it_int_flags & IT_FL_FOLLOWED)) {
221 + /* vfs_follow_link was never called */
222 + intent_release(it);
226 current->link_count--;
229 + intent_release(it);
233 @@ -381,15 +422,26 @@
234 return __follow_up(mnt, dentry);
237 -static inline int __follow_down(struct vfsmount **mnt, struct dentry **dentry)
238 +static inline int __follow_down(struct vfsmount **mnt, struct dentry **dentry,
239 + struct lookup_intent *it)
241 struct vfsmount *mounted;
243 spin_lock(&dcache_lock);
244 mounted = lookup_mnt(*mnt, *dentry);
246 + int opc = 0, mode = 0;
247 *mnt = mntget(mounted);
248 spin_unlock(&dcache_lock);
251 + mode = it->it_create_mode;
253 + intent_release(it);
256 + it->it_create_mode = mode;
259 mntput(mounted->mnt_parent);
260 *dentry = dget(mounted->mnt_root);
263 int follow_down(struct vfsmount **mnt, struct dentry **dentry)
265 - return __follow_down(mnt,dentry);
266 + return __follow_down(mnt,dentry,NULL);
269 static inline void follow_dotdot(struct nameidata *nd)
274 - while (d_mountpoint(nd->dentry) && __follow_down(&nd->mnt, &nd->dentry))
275 + while (d_mountpoint(nd->dentry) && __follow_down(&nd->mnt, &nd->dentry, NULL))
281 * We expect 'base' to be positive and a directory.
283 -int link_path_walk(const char * name, struct nameidata *nd)
284 +int link_path_walk_it(const char *name, struct nameidata *nd,
285 + struct lookup_intent *it)
287 struct dentry *dentry;
289 @@ -526,18 +579,18 @@
292 /* This does the actual lookups.. */
293 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
294 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
296 err = -EWOULDBLOCKIO;
299 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
300 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
301 err = PTR_ERR(dentry);
305 /* Check mountpoints.. */
306 - while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry))
307 + while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry, NULL))
314 if (inode->i_op->follow_link) {
315 - err = do_follow_link(dentry, nd);
316 + err = do_follow_link(dentry, nd, NULL);
324 - if (!inode->i_op->lookup)
325 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
328 /* here ends the main loop */
329 @@ -592,22 +644,22 @@
333 - dentry = cached_lookup(nd->dentry, &this, 0);
334 + dentry = cached_lookup(nd->dentry, &this, 0, it);
336 err = -EWOULDBLOCKIO;
339 - dentry = real_lookup(nd->dentry, &this, 0);
340 + dentry = real_lookup(nd->dentry, &this, 0, it);
341 err = PTR_ERR(dentry);
345 - while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry))
346 + while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry, it))
348 inode = dentry->d_inode;
349 if ((lookup_flags & LOOKUP_FOLLOW)
350 && inode && inode->i_op && inode->i_op->follow_link) {
351 - err = do_follow_link(dentry, nd);
352 + err = do_follow_link(dentry, nd, it);
358 if (lookup_flags & LOOKUP_DIRECTORY) {
360 - if (!inode->i_op || !inode->i_op->lookup)
361 + if (!inode->i_op ||
362 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
367 * Check the cached dentry for staleness.
370 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
372 + if (!dentry->d_op->d_revalidate_it(dentry, 0, NULL, it)) {
373 + struct dentry *new;
374 + err = permission(dentry->d_parent->d_inode,
378 + new = real_lookup(dentry->d_parent,
379 + &dentry->d_name, 0, it);
381 + err = PTR_ERR(new);
384 + d_invalidate(dentry);
388 + if (!nd->dentry->d_inode)
391 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
393 if (!dentry->d_op->d_revalidate(dentry, 0)) {
394 @@ -658,15 +732,28 @@
399 + intent_release(it);
405 +int link_path_walk(const char * name, struct nameidata *nd)
407 + return link_path_walk_it(name, nd, NULL);
410 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
412 + current->total_link_count = 0;
413 + return link_path_walk_it(name, nd, it);
416 int path_walk(const char * name, struct nameidata *nd)
418 current->total_link_count = 0;
419 - return link_path_walk(name, nd);
420 + return link_path_walk_it(name, nd, NULL);
428 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
429 + struct lookup_intent *it)
432 + if (path_init(path, flags, nd))
433 + error = path_walk_it(path, nd, it);
439 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
444 nd->last_type = LAST_ROOT; /* if there are only slashes... */
448 return walk_init_root(name,nd);
449 read_lock(¤t->fs->lock);
451 * needs parent already locked. Doesn't follow mounts.
454 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
455 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
456 + struct lookup_intent *it)
458 struct dentry * dentry;
460 @@ -802,13 +902,16 @@
464 - dentry = cached_lookup(base, name, 0);
465 + dentry = cached_lookup(base, name, 0, it);
467 struct dentry *new = d_alloc(base, name);
468 dentry = ERR_PTR(-ENOMEM);
472 + if (inode->i_op->lookup_it)
473 + dentry = inode->i_op->lookup_it(inode, new, NULL, it, 0);
475 dentry = inode->i_op->lookup(inode, new);
482 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
484 + return lookup_hash_it(name, base, NULL);
489 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
493 this.hash = end_name_hash(hash);
495 - return lookup_hash(&this, base);
496 + return lookup_hash_it(&this, base, NULL);
498 return ERR_PTR(-EACCES);
504 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
505 + struct lookup_intent *it)
510 + tmp = getname(name);
511 + err = PTR_ERR(tmp);
512 + if (!IS_ERR(tmp)) {
514 + if (path_init(tmp, flags, nd))
515 + err = path_walk_it(tmp, nd, it);
522 * It's inline, so penalty for filesystems that don't use sticky bit is
528 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
529 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
530 + struct lookup_intent *it)
534 @@ -982,12 +1109,15 @@
537 error = -EACCES; /* shouldn't it be ENOSYS? */
538 - if (!dir->i_op || !dir->i_op->create)
539 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
544 - error = dir->i_op->create(dir, dentry, mode);
545 + if (dir->i_op->create_it)
546 + error = dir->i_op->create_it(dir, dentry, mode, it);
548 + error = dir->i_op->create(dir, dentry, mode);
552 @@ -996,6 +1126,11 @@
556 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
558 + return vfs_create_it(dir, dentry, mode, NULL);
564 @@ -1010,7 +1145,8 @@
565 * for symlinks (where the permissions are checked later).
568 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
569 +int open_namei_it(const char *pathname, int flag, int mode,
570 + struct nameidata *nd, struct lookup_intent *it)
572 int acc_mode, error = 0;
574 @@ -1020,11 +1156,14 @@
576 acc_mode = ACC_MODE(flag);
579 + it->it_flags = flag;
582 * The simplest case - just a plain lookup.
584 if (!(flag & O_CREAT)) {
585 - error = path_lookup(pathname, lookup_flags(flag), nd);
586 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
590 @@ -1034,6 +1173,10 @@
592 * Create - we need to know the parent.
595 + it->it_create_mode = mode;
596 + it->it_op |= IT_CREAT;
598 error = path_lookup(pathname, LOOKUP_PARENT, nd);
601 @@ -1049,7 +1192,7 @@
604 down(&dir->d_inode->i_sem);
605 - dentry = lookup_hash(&nd->last, nd->dentry);
606 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
609 error = PTR_ERR(dentry);
610 @@ -1058,10 +1201,11 @@
614 + it->it_create_mode = mode;
615 /* Negative dentry, just create the file */
616 if (!dentry->d_inode) {
617 - error = vfs_create(dir->d_inode, dentry,
618 - mode & ~current->fs->umask);
619 + error = vfs_create_it(dir->d_inode, dentry,
620 + mode & ~current->fs->umask, it);
621 up(&dir->d_inode->i_sem);
624 @@ -1086,7 +1230,7 @@
626 if (flag & O_NOFOLLOW)
628 - while (__follow_down(&nd->mnt,&dentry) && d_mountpoint(dentry));
629 + while (__follow_down(&nd->mnt,&dentry,it) && d_mountpoint(dentry));
632 if (!dentry->d_inode)
633 @@ -1165,7 +1309,7 @@
637 - error = do_truncate(dentry, 0);
638 + error = do_truncate(dentry, 0, 1);
640 put_write_access(inode);
642 @@ -1177,8 +1321,10 @@
646 + intent_release(it);
649 + intent_release(it);
653 @@ -1197,7 +1343,16 @@
654 * are done. Procfs-like symlinks just set LAST_BIND.
656 UPDATE_ATIME(dentry->d_inode);
658 error = dentry->d_inode->i_op->follow_link(dentry, nd);
660 + intent_release(it);
661 + } else if (it != NULL && !(it->d.lustre.it_int_flags & IT_FL_FOLLOWED)) {
662 + /* vfs_follow_link was never called */
663 + intent_release(it);
670 @@ -1219,13 +1374,20 @@
673 down(&dir->d_inode->i_sem);
674 - dentry = lookup_hash(&nd->last, nd->dentry);
675 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
676 putname(nd->last.name);
680 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
682 + return open_namei_it(pathname, flag, mode, nd, NULL);
687 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
688 +struct dentry *lookup_create(struct nameidata *nd, int is_dir,
689 + struct lookup_intent *it)
691 struct dentry *dentry;
693 @@ -1233,7 +1395,7 @@
694 dentry = ERR_PTR(-EEXIST);
695 if (nd->last_type != LAST_NORM)
697 - dentry = lookup_hash(&nd->last, nd->dentry);
698 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
701 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
702 @@ -1289,7 +1451,20 @@
703 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
706 - dentry = lookup_create(&nd, 0);
708 + if (nd.last_type != LAST_NORM) {
712 + if (nd.dentry->d_inode->i_op->mknod_raw) {
713 + struct inode_operations *op = nd.dentry->d_inode->i_op;
714 + error = op->mknod_raw(&nd, mode, dev);
715 + /* the file system wants to use normal vfs path now */
716 + if (error != -EOPNOTSUPP)
720 + dentry = lookup_create(&nd, 0, NULL);
721 error = PTR_ERR(dentry);
723 mode &= ~current->fs->umask;
724 @@ -1310,6 +1485,7 @@
727 up(&nd.dentry->d_inode->i_sem);
732 @@ -1357,7 +1533,18 @@
733 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
736 - dentry = lookup_create(&nd, 1);
737 + if (nd.last_type != LAST_NORM) {
741 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
742 + struct inode_operations *op = nd.dentry->d_inode->i_op;
743 + error = op->mkdir_raw(&nd, mode);
744 + /* the file system wants to use normal vfs path now */
745 + if (error != -EOPNOTSUPP)
748 + dentry = lookup_create(&nd, 1, NULL);
749 error = PTR_ERR(dentry);
750 if (!IS_ERR(dentry)) {
751 error = vfs_mkdir(nd.dentry->d_inode, dentry,
752 @@ -1365,6 +1552,7 @@
755 up(&nd.dentry->d_inode->i_sem);
760 @@ -1465,8 +1653,16 @@
764 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
765 + struct inode_operations *op = nd.dentry->d_inode->i_op;
767 + error = op->rmdir_raw(&nd);
768 + /* the file system wants to use normal vfs path now */
769 + if (error != -EOPNOTSUPP)
772 down(&nd.dentry->d_inode->i_sem);
773 - dentry = lookup_hash(&nd.last, nd.dentry);
774 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
775 error = PTR_ERR(dentry);
776 if (!IS_ERR(dentry)) {
777 error = vfs_rmdir(nd.dentry->d_inode, dentry);
778 @@ -1524,8 +1720,15 @@
780 if (nd.last_type != LAST_NORM)
782 + if (nd.dentry->d_inode->i_op->unlink_raw) {
783 + struct inode_operations *op = nd.dentry->d_inode->i_op;
784 + error = op->unlink_raw(&nd);
785 + /* the file system wants to use normal vfs path now */
786 + if (error != -EOPNOTSUPP)
789 down(&nd.dentry->d_inode->i_sem);
790 - dentry = lookup_hash(&nd.last, nd.dentry);
791 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
792 error = PTR_ERR(dentry);
793 if (!IS_ERR(dentry)) {
794 /* Why not before? Because we want correct error value */
795 @@ -1592,15 +1795,27 @@
796 error = path_lookup(to, LOOKUP_PARENT, &nd);
799 - dentry = lookup_create(&nd, 0);
800 + if (nd.last_type != LAST_NORM) {
804 + if (nd.dentry->d_inode->i_op->symlink_raw) {
805 + struct inode_operations *op = nd.dentry->d_inode->i_op;
806 + error = op->symlink_raw(&nd, from);
807 + /* the file system wants to use normal vfs path now */
808 + if (error != -EOPNOTSUPP)
811 + dentry = lookup_create(&nd, 0, NULL);
812 error = PTR_ERR(dentry);
813 if (!IS_ERR(dentry)) {
814 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
817 up(&nd.dentry->d_inode->i_sem);
825 @@ -1676,7 +1891,18 @@
827 if (old_nd.mnt != nd.mnt)
829 - new_dentry = lookup_create(&nd, 0);
830 + if (nd.last_type != LAST_NORM) {
834 + if (nd.dentry->d_inode->i_op->link_raw) {
835 + struct inode_operations *op = nd.dentry->d_inode->i_op;
836 + error = op->link_raw(&old_nd, &nd);
837 + /* the file system wants to use normal vfs path now */
838 + if (error != -EOPNOTSUPP)
841 + new_dentry = lookup_create(&nd, 0, NULL);
842 error = PTR_ERR(new_dentry);
843 if (!IS_ERR(new_dentry)) {
844 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
845 @@ -1720,7 +1946,7 @@
848 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
849 - struct inode *new_dir, struct dentry *new_dentry)
850 + struct inode *new_dir, struct dentry *new_dentry)
853 struct inode *target;
854 @@ -1799,7 +2025,7 @@
857 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
858 - struct inode *new_dir, struct dentry *new_dentry)
859 + struct inode *new_dir, struct dentry *new_dentry)
863 @@ -1887,9 +2113,18 @@
864 if (newnd.last_type != LAST_NORM)
867 + if (old_dir->d_inode->i_op->rename_raw) {
869 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
871 + /* the file system wants to use normal vfs path now */
872 + if (error != -EOPNOTSUPP)
876 double_lock(new_dir, old_dir);
878 - old_dentry = lookup_hash(&oldnd.last, old_dir);
879 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
880 error = PTR_ERR(old_dentry);
881 if (IS_ERR(old_dentry))
883 @@ -1905,16 +2140,16 @@
884 if (newnd.last.name[newnd.last.len])
887 - new_dentry = lookup_hash(&newnd.last, new_dir);
888 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
889 error = PTR_ERR(new_dentry);
890 if (IS_ERR(new_dentry))
895 error = vfs_rename(old_dir->d_inode, old_dentry,
896 new_dir->d_inode, new_dentry);
902 @@ -1965,20 +2200,28 @@
906 -__vfs_follow_link(struct nameidata *nd, const char *link)
907 +__vfs_follow_link(struct nameidata *nd, const char *link,
908 + struct lookup_intent *it)
917 + else if (it != nd->intent)
918 + printk("it != nd->intent: tell phil@clusterfs.com\n");
920 + it->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
924 if (!walk_init_root(link, nd))
925 /* weird __emul_prefix() stuff did it */
928 - res = link_path_walk(link, nd);
929 + res = link_path_walk_it(link, nd, it);
931 if (current->link_count || res || nd->last_type!=LAST_NORM)
933 @@ -2002,7 +2245,13 @@
935 int vfs_follow_link(struct nameidata *nd, const char *link)
937 - return __vfs_follow_link(nd, link);
938 + return __vfs_follow_link(nd, link, NULL);
941 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
942 + struct lookup_intent *it)
944 + return __vfs_follow_link(nd, link, it);
947 /* get the link contents into pagecache */
948 @@ -2044,7 +2293,7 @@
950 struct page *page = NULL;
951 char *s = page_getlink(dentry, &page);
952 - int res = __vfs_follow_link(nd, s);
953 + int res = __vfs_follow_link(nd, s, NULL);
956 page_cache_release(page);
957 Index: linux-2.4.20/fs/namespace.c
958 ===================================================================
959 --- linux-2.4.20.orig/fs/namespace.c Wed Mar 17 13:57:05 2004
960 +++ linux-2.4.20/fs/namespace.c Wed Mar 17 13:57:11 2004
963 old_nd->dentry = mnt->mnt_mountpoint;
964 old_nd->mnt = mnt->mnt_parent;
965 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
966 mnt->mnt_parent = mnt;
967 mnt->mnt_mountpoint = mnt->mnt_root;
968 list_del_init(&mnt->mnt_child);
971 mnt->mnt_parent = mntget(nd->mnt);
972 mnt->mnt_mountpoint = dget(nd->dentry);
973 + PIN(nd->dentry, nd->mnt, 1);
974 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
975 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
976 nd->dentry->d_mounted++;
981 -static int do_umount(struct vfsmount *mnt, int flags)
982 +int do_umount(struct vfsmount *mnt, int flags)
984 struct super_block * sb = mnt->mnt_sb;
986 @@ -485,14 +487,17 @@
988 struct nameidata old_nd;
989 struct vfsmount *mnt = NULL;
990 + struct lookup_intent it = { .it_op = IT_GETATTR };
991 int err = mount_is_safe(nd);
994 if (!old_name || !*old_name)
996 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
998 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
1000 + intent_release(&it);
1004 down_write(¤t->namespace->sem);
1009 up_write(¤t->namespace->sem);
1010 + intent_release(&it);
1011 path_release(&old_nd);
1015 unsigned long flags, void *data_page)
1017 struct nameidata nd;
1018 + struct lookup_intent it = { .it_op = IT_GETATTR };
1022 @@ -722,9 +729,11 @@
1023 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
1025 /* ... and get the mountpoint */
1026 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
1028 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
1030 + intent_release(&it);
1034 if (flags & MS_REMOUNT)
1035 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
1038 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
1039 dev_name, data_page);
1041 + intent_release(&it);
1047 struct vfsmount *tmp;
1048 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
1049 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
1050 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
1053 if (!capable(CAP_SYS_ADMIN))
1054 @@ -908,14 +920,14 @@
1058 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
1059 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
1063 if (!check_mnt(new_nd.mnt))
1066 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
1067 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
1071 @@ -970,8 +982,10 @@
1072 up(&old_nd.dentry->d_inode->i_zombie);
1073 up_write(¤t->namespace->sem);
1074 path_release(&user_nd);
1075 + intent_release(&old_it);
1076 path_release(&old_nd);
1078 + intent_release(&new_it);
1079 path_release(&new_nd);
1082 Index: linux-2.4.20/fs/open.c
1083 ===================================================================
1084 --- linux-2.4.20.orig/fs/open.c Wed Mar 17 13:57:03 2004
1085 +++ linux-2.4.20/fs/open.c Wed Mar 17 13:57:11 2004
1087 #include <asm/uaccess.h>
1089 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1090 +extern int path_walk_it(const char *name, struct nameidata *nd,
1091 + struct lookup_intent *it);
1093 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1096 write_unlock(&files->file_lock);
1099 -int do_truncate(struct dentry *dentry, loff_t length)
1100 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1102 struct inode *inode = dentry->d_inode;
1103 + struct inode_operations *op = dentry->d_inode->i_op;
1105 struct iattr newattrs;
1107 @@ -108,7 +111,13 @@
1108 down(&inode->i_sem);
1109 newattrs.ia_size = length;
1110 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1111 - error = notify_change(dentry, &newattrs);
1112 + if (called_from_open)
1113 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1114 + if (op->setattr_raw) {
1115 + newattrs.ia_valid |= ATTR_RAW;
1116 + error = op->setattr_raw(inode, &newattrs);
1118 + error = notify_change(dentry, &newattrs);
1122 @@ -118,12 +127,13 @@
1123 struct nameidata nd;
1124 struct inode * inode;
1126 + struct lookup_intent it = { .it_op = IT_GETATTR };
1129 if (length < 0) /* sorry, but loff_t says... */
1132 - error = user_path_walk(path, &nd);
1133 + error = user_path_walk_it(path, &nd, &it);
1136 inode = nd.dentry->d_inode;
1137 @@ -163,11 +173,13 @@
1138 error = locks_verify_truncate(inode, NULL, length);
1141 - error = do_truncate(nd.dentry, length);
1142 + intent_release(&it);
1143 + error = do_truncate(nd.dentry, length, 0);
1145 put_write_access(inode);
1148 + intent_release(&it);
1154 error = locks_verify_truncate(inode, file, length);
1156 - error = do_truncate(dentry, length);
1157 + error = do_truncate(dentry, length, 0);
1161 @@ -260,11 +272,13 @@
1162 struct inode * inode;
1163 struct iattr newattrs;
1165 - error = user_path_walk(filename, &nd);
1166 + error = user_path_walk_it(filename, &nd, NULL);
1169 inode = nd.dentry->d_inode;
1171 + /* this is safe without a Lustre lock because it only depends
1172 + on the super block */
1174 if (IS_RDONLY(inode))
1176 @@ -279,11 +293,25 @@
1179 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1183 + if (inode->i_op->setattr_raw) {
1184 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1186 + newattrs.ia_valid |= ATTR_RAW;
1187 + error = op->setattr_raw(inode, &newattrs);
1188 + /* the file system wants to use normal vfs path now */
1189 + if (error != -EOPNOTSUPP)
1190 + goto dput_and_out;
1195 if (current->fsuid != inode->i_uid &&
1196 (error = permission(inode,MAY_WRITE)) != 0)
1200 error = notify_change(nd.dentry, &newattrs);
1203 @@ -304,12 +332,14 @@
1204 struct inode * inode;
1205 struct iattr newattrs;
1207 - error = user_path_walk(filename, &nd);
1208 + error = user_path_walk_it(filename, &nd, NULL);
1212 inode = nd.dentry->d_inode;
1214 + /* this is safe without a Lustre lock because it only depends
1215 + on the super block */
1217 if (IS_RDONLY(inode))
1219 @@ -324,7 +354,20 @@
1220 newattrs.ia_atime = times[0].tv_sec;
1221 newattrs.ia_mtime = times[1].tv_sec;
1222 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1226 + if (inode->i_op->setattr_raw) {
1227 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1229 + newattrs.ia_valid |= ATTR_RAW;
1230 + error = op->setattr_raw(inode, &newattrs);
1231 + /* the file system wants to use normal vfs path now */
1232 + if (error != -EOPNOTSUPP)
1233 + goto dput_and_out;
1238 if (current->fsuid != inode->i_uid &&
1239 (error = permission(inode,MAY_WRITE)) != 0)
1242 int old_fsuid, old_fsgid;
1243 kernel_cap_t old_cap;
1245 + struct lookup_intent it = { .it_op = IT_GETATTR };
1247 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1249 @@ -364,13 +408,14 @@
1251 current->cap_effective = current->cap_permitted;
1253 - res = user_path_walk(filename, &nd);
1254 + res = user_path_walk_it(filename, &nd, &it);
1256 res = permission(nd.dentry->d_inode, mode);
1257 /* SuS v2 requires we report a read only fs too */
1258 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1259 && !special_file(nd.dentry->d_inode->i_mode))
1261 + intent_release(&it);
1268 struct nameidata nd;
1269 + struct lookup_intent it = { .it_op = IT_GETATTR };
1271 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1272 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1277 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1280 + intent_release(&it);
1284 @@ -436,9 +483,10 @@
1287 struct nameidata nd;
1288 + struct lookup_intent it = { .it_op = IT_GETATTR };
1290 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1291 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1292 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1293 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1297 @@ -454,39 +502,56 @@
1301 + intent_release(&it);
1307 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1308 +int chmod_common(struct dentry *dentry, mode_t mode)
1310 - struct inode * inode;
1311 - struct dentry * dentry;
1312 - struct file * file;
1314 + struct inode *inode = dentry->d_inode;
1315 struct iattr newattrs;
1320 + if (IS_RDONLY(inode))
1323 - dentry = file->f_dentry;
1324 - inode = dentry->d_inode;
1325 + if (inode->i_op->setattr_raw) {
1326 + newattrs.ia_mode = mode;
1327 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1328 + newattrs.ia_valid |= ATTR_RAW;
1329 + err = inode->i_op->setattr_raw(inode, &newattrs);
1330 + /* the file system wants to use normal vfs path now */
1331 + if (err != -EOPNOTSUPP)
1336 - if (IS_RDONLY(inode))
1339 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1343 if (mode == (mode_t) -1)
1344 mode = inode->i_mode;
1345 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1346 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1347 err = notify_change(dentry, &newattrs);
1354 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1356 + struct file * file;
1363 + err = chmod_common(file->f_dentry, mode);
1368 @@ -495,30 +560,14 @@
1369 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1371 struct nameidata nd;
1372 - struct inode * inode;
1374 - struct iattr newattrs;
1376 error = user_path_walk(filename, &nd);
1379 - inode = nd.dentry->d_inode;
1382 - if (IS_RDONLY(inode))
1383 - goto dput_and_out;
1386 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1387 - goto dput_and_out;
1389 - if (mode == (mode_t) -1)
1390 - mode = inode->i_mode;
1391 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1392 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1393 - error = notify_change(nd.dentry, &newattrs);
1394 + error = chmod_common(nd.dentry, mode);
1400 @@ -538,6 +587,20 @@
1402 if (IS_RDONLY(inode))
1405 + if (inode->i_op->setattr_raw) {
1406 + struct inode_operations *op = dentry->d_inode->i_op;
1408 + newattrs.ia_uid = user;
1409 + newattrs.ia_gid = group;
1410 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1411 + newattrs.ia_valid |= ATTR_RAW;
1412 + error = op->setattr_raw(inode, &newattrs);
1413 + /* the file system wants to use normal vfs path now */
1414 + if (error != -EOPNOTSUPP)
1419 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1423 int namei_flags, error;
1424 struct nameidata nd;
1426 - flags &= ~O_DIRECT;
1427 + struct lookup_intent it = { .it_op = IT_OPEN };
1429 + //flags &= ~O_DIRECT;
1431 namei_flags = flags;
1432 if ((namei_flags+1) & O_ACCMODE)
1433 @@ -651,14 +715,15 @@
1434 if (namei_flags & O_TRUNC)
1437 - error = open_namei(filename, namei_flags, mode, &nd);
1439 - return dentry_open(nd.dentry, nd.mnt, flags);
1440 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1442 + return ERR_PTR(error);
1444 - return ERR_PTR(error);
1445 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1448 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1449 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1450 + int flags, struct lookup_intent *it)
1453 struct inode *inode;
1454 @@ -695,12 +760,15 @@
1457 if (f->f_op && f->f_op->open) {
1459 error = f->f_op->open(inode,f);
1464 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1466 + intent_release(it);
1470 @@ -715,11 +783,17 @@
1474 + intent_release(it);
1477 return ERR_PTR(error);
1480 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1482 + return dentry_open_it(dentry, mnt, flags, NULL);
1486 * Find an empty file descriptor entry, and mark it busy.
1488 Index: linux-2.4.20/fs/proc/base.c
1489 ===================================================================
1490 --- linux-2.4.20.orig/fs/proc/base.c Wed Mar 17 13:57:05 2004
1491 +++ linux-2.4.20/fs/proc/base.c Wed Mar 17 13:57:11 2004
1494 error = inode->u.proc_i.op.proc_get_link(inode, &nd->dentry, &nd->mnt);
1495 nd->last_type = LAST_BIND;
1497 + if (nd->intent != NULL)
1498 + nd->intent->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
1502 Index: linux-2.4.20/fs/stat.c
1503 ===================================================================
1504 --- linux-2.4.20.orig/fs/stat.c Wed Mar 17 13:57:05 2004
1505 +++ linux-2.4.20/fs/stat.c Wed Mar 17 13:58:01 2004
1507 * Revalidate the inode. This is required for proper NFS attribute caching.
1509 static __inline__ int
1510 -do_revalidate(struct dentry *dentry)
1511 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1513 struct inode * inode = dentry->d_inode;
1514 - if (inode->i_op && inode->i_op->revalidate)
1515 + if (inode->i_op && inode->i_op->revalidate_it)
1516 + return inode->i_op->revalidate_it(dentry, it);
1517 + else if (inode->i_op && inode->i_op->revalidate)
1518 return inode->i_op->revalidate(dentry);
1522 return inode->i_nlink;
1525 -static int do_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
1526 +static int do_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat, struct lookup_intent *it)
1529 unsigned int blocks, indirect;
1530 struct inode *inode = dentry->d_inode;
1532 - res = do_revalidate(dentry);
1533 + res = do_revalidate(dentry, it);
1537 @@ -111,10 +113,12 @@
1539 struct nameidata nd;
1541 + struct lookup_intent it = { .it_op = IT_GETATTR };
1543 - error = user_path_walk(name, &nd);
1544 + error = user_path_walk_it(name, &nd, &it);
1546 - error = do_getattr(nd.mnt, nd.dentry, stat);
1547 + error = do_getattr(nd.mnt, nd.dentry, stat, &it);
1548 + intent_release(&it);
1552 @@ -124,10 +128,12 @@
1554 struct nameidata nd;
1556 + struct lookup_intent it = { .it_op = IT_GETATTR };
1558 - error = user_path_walk_link(name, &nd);
1559 + error = user_path_walk_link_it(name, &nd, &it);
1561 - error = do_getattr(nd.mnt, nd.dentry, stat);
1562 + error = do_getattr(nd.mnt, nd.dentry, stat, &it);
1563 + intent_release(&it);
1571 - error = do_getattr(f->f_vfsmnt, f->f_dentry, stat);
1572 + error = do_getattr(f->f_vfsmnt, f->f_dentry, stat, NULL);
1579 if (inode->i_op && inode->i_op->readlink &&
1580 - !(error = do_revalidate(nd.dentry))) {
1581 + !(error = do_revalidate(nd.dentry, NULL))) {
1582 UPDATE_ATIME(inode);
1583 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1585 Index: linux-2.4.20/include/linux/dcache.h
1586 ===================================================================
1587 --- linux-2.4.20.orig/include/linux/dcache.h Wed Mar 17 13:57:04 2004
1588 +++ linux-2.4.20/include/linux/dcache.h Wed Mar 17 13:57:11 2004
1590 #include <asm/atomic.h>
1591 #include <linux/mount.h>
1592 #include <linux/kernel.h>
1593 +#include <linux/string.h>
1595 +#define IT_OPEN 0x0001
1596 +#define IT_CREAT 0x0002
1597 +#define IT_READDIR 0x0004
1598 +#define IT_GETATTR 0x0008
1599 +#define IT_LOOKUP 0x0010
1600 +#define IT_UNLINK 0x0020
1601 +#define IT_GETXATTR 0x0040
1602 +#define IT_EXEC 0x0080
1603 +#define IT_PIN 0x0100
1604 +#define IT_CHDIR 0x0200
1606 +#define IT_FL_LOCKED 0x0001
1607 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1609 +#define INTENT_MAGIC 0x19620323
1612 +struct lustre_intent_data {
1613 + int it_disposition;
1615 + __u64 it_lock_handle;
1620 +struct lookup_intent {
1622 + void (*it_op_release)(struct lookup_intent *);
1625 + int it_create_mode;
1627 + struct lustre_intent_data lustre;
1631 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1633 + memset(it, 0, sizeof(*it));
1634 + it->it_magic = INTENT_MAGIC;
1636 + it->it_flags = flags;
1641 * linux/include/linux/dcache.h
1643 unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */
1648 struct dentry_operations {
1649 int (*d_revalidate)(struct dentry *, int);
1650 int (*d_hash) (struct dentry *, struct qstr *);
1652 int (*d_delete)(struct dentry *);
1653 void (*d_release)(struct dentry *);
1654 void (*d_iput)(struct dentry *, struct inode *);
1655 + int (*d_revalidate_it)(struct dentry *, int, struct nameidata *, struct lookup_intent *);
1656 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1657 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1660 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1661 + de->d_op->d_pin(de, mnt, flag);
1662 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1663 + de->d_op->d_unpin(de, mnt, flag);
1666 +/* defined in fs/namei.c */
1667 +extern void intent_release(struct lookup_intent *it);
1668 +/* defined in fs/dcache.c */
1669 +extern void __d_rehash(struct dentry * entry, int lock);
1671 /* the dentry parameter passed to d_hash and d_compare is the parent
1672 * directory of the entries to be compared. It is used in case these
1673 * functions need any directory specific information for determining
1675 * s_nfsd_free_path semaphore will be down
1677 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1678 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1680 extern spinlock_t dcache_lock;
1682 Index: linux-2.4.20/include/linux/fs.h
1683 ===================================================================
1684 --- linux-2.4.20.orig/include/linux/fs.h Wed Mar 17 13:57:11 2004
1685 +++ linux-2.4.20/include/linux/fs.h Wed Mar 17 13:57:11 2004
1688 #define FMODE_READ 1
1689 #define FMODE_WRITE 2
1690 +#define FMODE_EXEC 4
1695 #define ATTR_MTIME_SET 256
1696 #define ATTR_FORCE 512 /* Not a change, but a change it */
1697 #define ATTR_ATTR_FLAG 1024
1698 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1699 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1700 +#define ATTR_CTIME_SET 0x2000
1703 * This is the Inode Attributes structure, used for notify_change(). It
1705 struct pipe_inode_info *i_pipe;
1706 struct block_device *i_bdev;
1707 struct char_device *i_cdev;
1708 + void *i_filterdata;
1710 unsigned long i_dnotify_mask; /* Directory notify events */
1711 struct dnotify_struct *i_dnotify; /* for directory notifications */
1714 /* needed for tty driver, and maybe others */
1716 + struct lookup_intent *f_it;
1718 /* preallocated helper kiobuf to speedup O_DIRECT */
1719 struct kiobuf *f_iobuf;
1724 + struct lookup_intent *intent;
1729 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1730 extern int vfs_rmdir(struct inode *, struct dentry *);
1731 extern int vfs_unlink(struct inode *, struct dentry *);
1732 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1733 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1734 + struct inode *new_dir, struct dentry *new_dentry);
1738 @@ -882,21 +890,32 @@
1740 struct inode_operations {
1741 int (*create) (struct inode *,struct dentry *,int);
1742 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1743 struct dentry * (*lookup) (struct inode *,struct dentry *);
1744 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct nameidata *, struct lookup_intent *, int flags);
1745 int (*link) (struct dentry *,struct inode *,struct dentry *);
1746 + int (*link_raw) (struct nameidata *,struct nameidata *);
1747 int (*unlink) (struct inode *,struct dentry *);
1748 + int (*unlink_raw) (struct nameidata *);
1749 int (*symlink) (struct inode *,struct dentry *,const char *);
1750 + int (*symlink_raw) (struct nameidata *,const char *);
1751 int (*mkdir) (struct inode *,struct dentry *,int);
1752 + int (*mkdir_raw) (struct nameidata *,int);
1753 int (*rmdir) (struct inode *,struct dentry *);
1754 + int (*rmdir_raw) (struct nameidata *);
1755 int (*mknod) (struct inode *,struct dentry *,int,int);
1756 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1757 int (*rename) (struct inode *, struct dentry *,
1758 struct inode *, struct dentry *);
1759 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1760 int (*readlink) (struct dentry *, char *,int);
1761 int (*follow_link) (struct dentry *, struct nameidata *);
1762 void (*truncate) (struct inode *);
1763 int (*permission) (struct inode *, int);
1764 int (*revalidate) (struct dentry *);
1765 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1766 int (*setattr) (struct dentry *, struct iattr *);
1767 + int (*setattr_raw) (struct inode *, struct iattr *);
1768 int (*getattr) (struct dentry *, struct iattr *);
1769 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
1770 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1772 int (*remount_fs) (struct super_block *, int *, char *);
1773 void (*clear_inode) (struct inode *);
1774 void (*umount_begin) (struct super_block *);
1775 + void (*umount_lustre) (struct super_block *);
1777 /* Following are for knfsd to interact with "interesting" filesystems
1778 * Currently just reiserfs, but possibly FAT and others later
1779 @@ -1092,10 +1111,16 @@
1781 asmlinkage long sys_open(const char *, int, int);
1782 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1783 -extern int do_truncate(struct dentry *, loff_t start);
1784 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1785 +struct dentry *lookup_create(struct nameidata *nd, int is_dir,
1786 + struct lookup_intent *it);
1788 extern struct file *filp_open(const char *, int, int);
1789 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1790 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1791 + struct nameidata *nd, struct lookup_intent *it);
1792 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1793 + int flags, struct lookup_intent *it);
1794 extern int filp_close(struct file *, fl_owner_t id);
1795 extern char * getname(const char *);
1797 @@ -1386,6 +1409,7 @@
1798 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1800 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1801 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1802 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1803 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1804 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1805 @@ -1397,6 +1421,8 @@
1806 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1807 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1808 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1809 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1810 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1812 extern void inode_init_once(struct inode *);
1813 extern void iput(struct inode *);
1814 @@ -1504,6 +1530,8 @@
1816 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1817 extern int vfs_follow_link(struct nameidata *, const char *);
1818 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1819 + struct lookup_intent *it);
1820 extern int page_readlink(struct dentry *, char *, int);
1821 extern int page_follow_link(struct dentry *, struct nameidata *);
1822 extern struct inode_operations page_symlink_inode_operations;
1823 Index: linux-2.4.20/include/linux/fs_struct.h
1824 ===================================================================
1825 --- linux-2.4.20.orig/include/linux/fs_struct.h Wed Mar 17 13:57:02 2004
1826 +++ linux-2.4.20/include/linux/fs_struct.h Wed Mar 17 13:57:11 2004
1828 write_lock(&fs->lock);
1829 old_root = fs->root;
1830 old_rootmnt = fs->rootmnt;
1831 + PIN(dentry, mnt, 1);
1832 fs->rootmnt = mntget(mnt);
1833 fs->root = dget(dentry);
1834 write_unlock(&fs->lock);
1836 + UNPIN(old_root, old_rootmnt, 1);
1838 mntput(old_rootmnt);
1841 write_lock(&fs->lock);
1843 old_pwdmnt = fs->pwdmnt;
1844 + PIN(dentry, mnt, 0);
1845 fs->pwdmnt = mntget(mnt);
1846 fs->pwd = dget(dentry);
1847 write_unlock(&fs->lock);
1849 + UNPIN(old_pwd, old_pwdmnt, 0);
1853 Index: linux-2.4.20/kernel/exit.c
1854 ===================================================================
1855 --- linux-2.4.20.orig/kernel/exit.c Wed Mar 17 13:57:05 2004
1856 +++ linux-2.4.20/kernel/exit.c Wed Mar 17 13:57:11 2004
1857 @@ -345,11 +345,14 @@
1859 /* No need to hold fs->lock if we are killing it */
1860 if (atomic_dec_and_test(&fs->count)) {
1861 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1862 + UNPIN(fs->root, fs->rootmnt, 1);
1864 mntput(fs->rootmnt);
1868 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1870 mntput(fs->altrootmnt);
1872 Index: linux-2.4.20/kernel/fork.c
1873 ===================================================================
1874 --- linux-2.4.20.orig/kernel/fork.c Wed Mar 17 13:57:05 2004
1875 +++ linux-2.4.20/kernel/fork.c Wed Mar 17 13:57:11 2004
1876 @@ -440,10 +440,13 @@
1877 fs->umask = old->umask;
1878 read_lock(&old->lock);
1879 fs->rootmnt = mntget(old->rootmnt);
1880 + PIN(old->pwd, old->pwdmnt, 0);
1881 + PIN(old->root, old->rootmnt, 1);
1882 fs->root = dget(old->root);
1883 fs->pwdmnt = mntget(old->pwdmnt);
1884 fs->pwd = dget(old->pwd);
1886 + PIN(old->altroot, old->altrootmnt, 1);
1887 fs->altrootmnt = mntget(old->altrootmnt);
1888 fs->altroot = dget(old->altroot);
1890 Index: linux-2.4.20/kernel/ksyms.c
1891 ===================================================================
1892 --- linux-2.4.20.orig/kernel/ksyms.c Wed Mar 17 13:57:11 2004
1893 +++ linux-2.4.20/kernel/ksyms.c Wed Mar 17 13:57:11 2004
1895 EXPORT_SYMBOL(set_page_dirty);
1896 EXPORT_SYMBOL(vfs_readlink);
1897 EXPORT_SYMBOL(vfs_follow_link);
1898 +EXPORT_SYMBOL(vfs_follow_link_it);
1899 +EXPORT_SYMBOL(do_umount);
1900 +EXPORT_SYMBOL(lookup_create);
1901 EXPORT_SYMBOL(page_readlink);
1902 EXPORT_SYMBOL(page_follow_link);
1903 EXPORT_SYMBOL(page_symlink_inode_operations);
1904 ===== include/linux/mount.h 1.7 vs edited =====
1905 --- linux-2.4.20.orig/include/linux/mount.h Tue Feb 5 09:49:35 2002
1906 +++ linux-2.4.20/include/linux/mount.h Tue May 4 19:23:48 2004
1909 char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
1910 struct list_head mnt_list;
1911 + struct list_head mnt_lustre_list; /* GNS mount list */
1912 + unsigned long mnt_last_used; /* for GNS auto-umount (jiffies) */
1915 static inline struct vfsmount *mntget(struct vfsmount *mnt)
1919 extern void __mntput(struct vfsmount *mnt);
1920 +extern int do_umount(struct vfsmount *mnt, int flags);
1922 static inline void mntput(struct vfsmount *mnt)