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, 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, 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, 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, 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);
380 + d_invalidate(dentry);
383 + err = PTR_ERR(new);
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, 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 +static 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++;
977 @@ -485,14 +487,17 @@
979 struct nameidata old_nd;
980 struct vfsmount *mnt = NULL;
981 + struct lookup_intent it = { .it_op = IT_GETATTR };
982 int err = mount_is_safe(nd);
985 if (!old_name || !*old_name)
987 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
989 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
991 + intent_release(&it);
995 down_write(¤t->namespace->sem);
1000 up_write(¤t->namespace->sem);
1001 + intent_release(&it);
1002 path_release(&old_nd);
1006 unsigned long flags, void *data_page)
1008 struct nameidata nd;
1009 + struct lookup_intent it = { .it_op = IT_GETATTR };
1013 @@ -722,9 +729,11 @@
1014 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
1016 /* ... and get the mountpoint */
1017 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
1019 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
1021 + intent_release(&it);
1025 if (flags & MS_REMOUNT)
1026 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
1029 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
1030 dev_name, data_page);
1032 + intent_release(&it);
1038 struct vfsmount *tmp;
1039 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
1040 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
1041 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
1044 if (!capable(CAP_SYS_ADMIN))
1045 @@ -908,14 +920,14 @@
1049 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
1050 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
1054 if (!check_mnt(new_nd.mnt))
1057 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
1058 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
1062 @@ -970,8 +982,10 @@
1063 up(&old_nd.dentry->d_inode->i_zombie);
1064 up_write(¤t->namespace->sem);
1065 path_release(&user_nd);
1066 + intent_release(&old_it);
1067 path_release(&old_nd);
1069 + intent_release(&new_it);
1070 path_release(&new_nd);
1073 Index: linux-2.4.20/fs/open.c
1074 ===================================================================
1075 --- linux-2.4.20.orig/fs/open.c Wed Mar 17 13:57:03 2004
1076 +++ linux-2.4.20/fs/open.c Wed Mar 17 13:57:11 2004
1078 #include <asm/uaccess.h>
1080 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1081 +extern int path_walk_it(const char *name, struct nameidata *nd,
1082 + struct lookup_intent *it);
1084 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1087 write_unlock(&files->file_lock);
1090 -int do_truncate(struct dentry *dentry, loff_t length)
1091 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1093 struct inode *inode = dentry->d_inode;
1094 + struct inode_operations *op = dentry->d_inode->i_op;
1096 struct iattr newattrs;
1098 @@ -108,7 +111,13 @@
1099 down(&inode->i_sem);
1100 newattrs.ia_size = length;
1101 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1102 - error = notify_change(dentry, &newattrs);
1103 + if (called_from_open)
1104 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1105 + if (op->setattr_raw) {
1106 + newattrs.ia_valid |= ATTR_RAW;
1107 + error = op->setattr_raw(inode, &newattrs);
1109 + error = notify_change(dentry, &newattrs);
1113 @@ -118,12 +127,13 @@
1114 struct nameidata nd;
1115 struct inode * inode;
1117 + struct lookup_intent it = { .it_op = IT_GETATTR };
1120 if (length < 0) /* sorry, but loff_t says... */
1123 - error = user_path_walk(path, &nd);
1124 + error = user_path_walk_it(path, &nd, &it);
1127 inode = nd.dentry->d_inode;
1128 @@ -163,11 +173,13 @@
1129 error = locks_verify_truncate(inode, NULL, length);
1132 - error = do_truncate(nd.dentry, length);
1133 + intent_release(&it);
1134 + error = do_truncate(nd.dentry, length, 0);
1136 put_write_access(inode);
1139 + intent_release(&it);
1145 error = locks_verify_truncate(inode, file, length);
1147 - error = do_truncate(dentry, length);
1148 + error = do_truncate(dentry, length, 0);
1152 @@ -260,11 +272,13 @@
1153 struct inode * inode;
1154 struct iattr newattrs;
1156 - error = user_path_walk(filename, &nd);
1157 + error = user_path_walk_it(filename, &nd, NULL);
1160 inode = nd.dentry->d_inode;
1162 + /* this is safe without a Lustre lock because it only depends
1163 + on the super block */
1165 if (IS_RDONLY(inode))
1167 @@ -279,11 +293,25 @@
1170 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1174 + if (inode->i_op->setattr_raw) {
1175 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1177 + newattrs.ia_valid |= ATTR_RAW;
1178 + error = op->setattr_raw(inode, &newattrs);
1179 + /* the file system wants to use normal vfs path now */
1180 + if (error != -EOPNOTSUPP)
1181 + goto dput_and_out;
1186 if (current->fsuid != inode->i_uid &&
1187 (error = permission(inode,MAY_WRITE)) != 0)
1191 error = notify_change(nd.dentry, &newattrs);
1194 @@ -304,12 +332,14 @@
1195 struct inode * inode;
1196 struct iattr newattrs;
1198 - error = user_path_walk(filename, &nd);
1199 + error = user_path_walk_it(filename, &nd, NULL);
1203 inode = nd.dentry->d_inode;
1205 + /* this is safe without a Lustre lock because it only depends
1206 + on the super block */
1208 if (IS_RDONLY(inode))
1210 @@ -324,7 +354,20 @@
1211 newattrs.ia_atime = times[0].tv_sec;
1212 newattrs.ia_mtime = times[1].tv_sec;
1213 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1217 + if (inode->i_op->setattr_raw) {
1218 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1220 + newattrs.ia_valid |= ATTR_RAW;
1221 + error = op->setattr_raw(inode, &newattrs);
1222 + /* the file system wants to use normal vfs path now */
1223 + if (error != -EOPNOTSUPP)
1224 + goto dput_and_out;
1229 if (current->fsuid != inode->i_uid &&
1230 (error = permission(inode,MAY_WRITE)) != 0)
1233 int old_fsuid, old_fsgid;
1234 kernel_cap_t old_cap;
1236 + struct lookup_intent it = { .it_op = IT_GETATTR };
1238 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1240 @@ -364,13 +408,14 @@
1242 current->cap_effective = current->cap_permitted;
1244 - res = user_path_walk(filename, &nd);
1245 + res = user_path_walk_it(filename, &nd, &it);
1247 res = permission(nd.dentry->d_inode, mode);
1248 /* SuS v2 requires we report a read only fs too */
1249 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1250 && !special_file(nd.dentry->d_inode->i_mode))
1252 + intent_release(&it);
1259 struct nameidata nd;
1260 + struct lookup_intent it = { .it_op = IT_GETATTR };
1262 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1263 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1268 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1271 + intent_release(&it);
1275 @@ -436,9 +483,10 @@
1278 struct nameidata nd;
1279 + struct lookup_intent it = { .it_op = IT_GETATTR };
1281 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1282 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1283 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1284 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1288 @@ -454,39 +502,56 @@
1292 + intent_release(&it);
1298 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1299 +int chmod_common(struct dentry *dentry, mode_t mode)
1301 - struct inode * inode;
1302 - struct dentry * dentry;
1303 - struct file * file;
1305 + struct inode *inode = dentry->d_inode;
1306 struct iattr newattrs;
1311 + if (IS_RDONLY(inode))
1314 - dentry = file->f_dentry;
1315 - inode = dentry->d_inode;
1316 + if (inode->i_op->setattr_raw) {
1317 + newattrs.ia_mode = mode;
1318 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1319 + newattrs.ia_valid |= ATTR_RAW;
1320 + err = inode->i_op->setattr_raw(inode, &newattrs);
1321 + /* the file system wants to use normal vfs path now */
1322 + if (err != -EOPNOTSUPP)
1327 - if (IS_RDONLY(inode))
1330 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1334 if (mode == (mode_t) -1)
1335 mode = inode->i_mode;
1336 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1337 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1338 err = notify_change(dentry, &newattrs);
1345 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1347 + struct file * file;
1354 + err = chmod_common(file->f_dentry, mode);
1359 @@ -495,30 +560,14 @@
1360 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1362 struct nameidata nd;
1363 - struct inode * inode;
1365 - struct iattr newattrs;
1367 error = user_path_walk(filename, &nd);
1370 - inode = nd.dentry->d_inode;
1373 - if (IS_RDONLY(inode))
1374 - goto dput_and_out;
1377 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1378 - goto dput_and_out;
1380 - if (mode == (mode_t) -1)
1381 - mode = inode->i_mode;
1382 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1383 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1384 - error = notify_change(nd.dentry, &newattrs);
1385 + error = chmod_common(nd.dentry, mode);
1391 @@ -538,6 +587,20 @@
1393 if (IS_RDONLY(inode))
1396 + if (inode->i_op->setattr_raw) {
1397 + struct inode_operations *op = dentry->d_inode->i_op;
1399 + newattrs.ia_uid = user;
1400 + newattrs.ia_gid = group;
1401 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1402 + newattrs.ia_valid |= ATTR_RAW;
1403 + error = op->setattr_raw(inode, &newattrs);
1404 + /* the file system wants to use normal vfs path now */
1405 + if (error != -EOPNOTSUPP)
1410 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1414 int namei_flags, error;
1415 struct nameidata nd;
1417 - flags &= ~O_DIRECT;
1418 + struct lookup_intent it = { .it_op = IT_OPEN };
1420 + //flags &= ~O_DIRECT;
1422 namei_flags = flags;
1423 if ((namei_flags+1) & O_ACCMODE)
1424 @@ -651,14 +715,15 @@
1425 if (namei_flags & O_TRUNC)
1428 - error = open_namei(filename, namei_flags, mode, &nd);
1430 - return dentry_open(nd.dentry, nd.mnt, flags);
1431 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1433 + return ERR_PTR(error);
1435 - return ERR_PTR(error);
1436 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1439 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1440 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1441 + int flags, struct lookup_intent *it)
1444 struct inode *inode;
1445 @@ -695,12 +760,15 @@
1448 if (f->f_op && f->f_op->open) {
1450 error = f->f_op->open(inode,f);
1455 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1457 + intent_release(it);
1461 @@ -715,11 +783,17 @@
1465 + intent_release(it);
1468 return ERR_PTR(error);
1471 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1473 + return dentry_open_it(dentry, mnt, flags, NULL);
1477 * Find an empty file descriptor entry, and mark it busy.
1479 Index: linux-2.4.20/fs/proc/base.c
1480 ===================================================================
1481 --- linux-2.4.20.orig/fs/proc/base.c Wed Mar 17 13:57:05 2004
1482 +++ linux-2.4.20/fs/proc/base.c Wed Mar 17 13:57:11 2004
1485 error = inode->u.proc_i.op.proc_get_link(inode, &nd->dentry, &nd->mnt);
1486 nd->last_type = LAST_BIND;
1488 + if (nd->intent != NULL)
1489 + nd->intent->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
1493 Index: linux-2.4.20/fs/stat.c
1494 ===================================================================
1495 --- linux-2.4.20.orig/fs/stat.c Wed Mar 17 13:57:05 2004
1496 +++ linux-2.4.20/fs/stat.c Wed Mar 17 13:58:01 2004
1498 * Revalidate the inode. This is required for proper NFS attribute caching.
1500 static __inline__ int
1501 -do_revalidate(struct dentry *dentry)
1502 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1504 struct inode * inode = dentry->d_inode;
1505 - if (inode->i_op && inode->i_op->revalidate)
1506 + if (inode->i_op && inode->i_op->revalidate_it)
1507 + return inode->i_op->revalidate_it(dentry, it);
1508 + else if (inode->i_op && inode->i_op->revalidate)
1509 return inode->i_op->revalidate(dentry);
1513 return inode->i_nlink;
1516 -static int do_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
1517 +static int do_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat, struct lookup_intent *it)
1520 unsigned int blocks, indirect;
1521 struct inode *inode = dentry->d_inode;
1523 - res = do_revalidate(dentry);
1524 + res = do_revalidate(dentry, it);
1528 @@ -111,10 +113,12 @@
1530 struct nameidata nd;
1532 + struct lookup_intent it = { .it_op = IT_GETATTR };
1534 - error = user_path_walk(name, &nd);
1535 + error = user_path_walk_it(name, &nd, &it);
1537 - error = do_getattr(nd.mnt, nd.dentry, stat);
1538 + error = do_getattr(nd.mnt, nd.dentry, stat, &it);
1539 + intent_release(&it);
1543 @@ -124,10 +128,12 @@
1545 struct nameidata nd;
1547 + struct lookup_intent it = { .it_op = IT_GETATTR };
1549 - error = user_path_walk_link(name, &nd);
1550 + error = user_path_walk_link_it(name, &nd, &it);
1552 - error = do_getattr(nd.mnt, nd.dentry, stat);
1553 + error = do_getattr(nd.mnt, nd.dentry, stat, &it);
1554 + intent_release(&it);
1562 - error = do_getattr(f->f_vfsmnt, f->f_dentry, stat);
1563 + error = do_getattr(f->f_vfsmnt, f->f_dentry, stat, NULL);
1570 if (inode->i_op && inode->i_op->readlink &&
1571 - !(error = do_revalidate(nd.dentry))) {
1572 + !(error = do_revalidate(nd.dentry, NULL))) {
1573 UPDATE_ATIME(inode);
1574 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1576 Index: linux-2.4.20/include/linux/dcache.h
1577 ===================================================================
1578 --- linux-2.4.20.orig/include/linux/dcache.h Wed Mar 17 13:57:04 2004
1579 +++ linux-2.4.20/include/linux/dcache.h Wed Mar 17 13:57:11 2004
1581 #include <asm/atomic.h>
1582 #include <linux/mount.h>
1583 #include <linux/kernel.h>
1584 +#include <linux/string.h>
1586 +#define IT_OPEN 0x0001
1587 +#define IT_CREAT 0x0002
1588 +#define IT_READDIR 0x0004
1589 +#define IT_GETATTR 0x0008
1590 +#define IT_LOOKUP 0x0010
1591 +#define IT_UNLINK 0x0020
1592 +#define IT_GETXATTR 0x0040
1593 +#define IT_EXEC 0x0080
1594 +#define IT_PIN 0x0100
1596 +#define IT_FL_LOCKED 0x0001
1597 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1599 +#define INTENT_MAGIC 0x19620323
1602 +struct lustre_intent_data {
1603 + int it_disposition;
1605 + __u64 it_lock_handle;
1610 +struct lookup_intent {
1612 + void (*it_op_release)(struct lookup_intent *);
1615 + int it_create_mode;
1617 + struct lustre_intent_data lustre;
1621 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1623 + memset(it, 0, sizeof(*it));
1624 + it->it_magic = INTENT_MAGIC;
1626 + it->it_flags = flags;
1631 * linux/include/linux/dcache.h
1633 int (*d_delete)(struct dentry *);
1634 void (*d_release)(struct dentry *);
1635 void (*d_iput)(struct dentry *, struct inode *);
1636 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1637 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1638 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1641 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1642 + de->d_op->d_pin(de, mnt, flag);
1643 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1644 + de->d_op->d_unpin(de, mnt, flag);
1647 +/* defined in fs/namei.c */
1648 +extern void intent_release(struct lookup_intent *it);
1649 +/* defined in fs/dcache.c */
1650 +extern void __d_rehash(struct dentry * entry, int lock);
1652 /* the dentry parameter passed to d_hash and d_compare is the parent
1653 * directory of the entries to be compared. It is used in case these
1654 * functions need any directory specific information for determining
1656 * s_nfsd_free_path semaphore will be down
1658 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1659 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1661 extern spinlock_t dcache_lock;
1663 Index: linux-2.4.20/include/linux/fs.h
1664 ===================================================================
1665 --- linux-2.4.20.orig/include/linux/fs.h Wed Mar 17 13:57:11 2004
1666 +++ linux-2.4.20/include/linux/fs.h Wed Mar 17 13:57:11 2004
1669 #define FMODE_READ 1
1670 #define FMODE_WRITE 2
1671 +#define FMODE_EXEC 4
1676 #define ATTR_MTIME_SET 256
1677 #define ATTR_FORCE 512 /* Not a change, but a change it */
1678 #define ATTR_ATTR_FLAG 1024
1679 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1680 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1681 +#define ATTR_CTIME_SET 0x2000
1684 * This is the Inode Attributes structure, used for notify_change(). It
1686 struct pipe_inode_info *i_pipe;
1687 struct block_device *i_bdev;
1688 struct char_device *i_cdev;
1689 + void *i_filterdata;
1691 unsigned long i_dnotify_mask; /* Directory notify events */
1692 struct dnotify_struct *i_dnotify; /* for directory notifications */
1695 /* needed for tty driver, and maybe others */
1697 + struct lookup_intent *f_it;
1699 /* preallocated helper kiobuf to speedup O_DIRECT */
1700 struct kiobuf *f_iobuf;
1705 + struct lookup_intent *intent;
1710 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1711 extern int vfs_rmdir(struct inode *, struct dentry *);
1712 extern int vfs_unlink(struct inode *, struct dentry *);
1713 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1714 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1715 + struct inode *new_dir, struct dentry *new_dentry);
1719 @@ -882,21 +890,32 @@
1721 struct inode_operations {
1722 int (*create) (struct inode *,struct dentry *,int);
1723 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1724 struct dentry * (*lookup) (struct inode *,struct dentry *);
1725 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1726 int (*link) (struct dentry *,struct inode *,struct dentry *);
1727 + int (*link_raw) (struct nameidata *,struct nameidata *);
1728 int (*unlink) (struct inode *,struct dentry *);
1729 + int (*unlink_raw) (struct nameidata *);
1730 int (*symlink) (struct inode *,struct dentry *,const char *);
1731 + int (*symlink_raw) (struct nameidata *,const char *);
1732 int (*mkdir) (struct inode *,struct dentry *,int);
1733 + int (*mkdir_raw) (struct nameidata *,int);
1734 int (*rmdir) (struct inode *,struct dentry *);
1735 + int (*rmdir_raw) (struct nameidata *);
1736 int (*mknod) (struct inode *,struct dentry *,int,int);
1737 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1738 int (*rename) (struct inode *, struct dentry *,
1739 struct inode *, struct dentry *);
1740 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1741 int (*readlink) (struct dentry *, char *,int);
1742 int (*follow_link) (struct dentry *, struct nameidata *);
1743 void (*truncate) (struct inode *);
1744 int (*permission) (struct inode *, int);
1745 int (*revalidate) (struct dentry *);
1746 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1747 int (*setattr) (struct dentry *, struct iattr *);
1748 + int (*setattr_raw) (struct inode *, struct iattr *);
1749 int (*getattr) (struct dentry *, struct iattr *);
1750 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
1751 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1752 @@ -1092,10 +1111,14 @@
1754 asmlinkage long sys_open(const char *, int, int);
1755 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1756 -extern int do_truncate(struct dentry *, loff_t start);
1757 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1759 extern struct file *filp_open(const char *, int, int);
1760 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1761 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1762 + struct nameidata *nd, struct lookup_intent *it);
1763 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1764 + int flags, struct lookup_intent *it);
1765 extern int filp_close(struct file *, fl_owner_t id);
1766 extern char * getname(const char *);
1768 @@ -1386,6 +1409,7 @@
1769 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1771 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1772 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1773 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1774 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1775 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1776 @@ -1397,6 +1421,8 @@
1777 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1778 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1779 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1780 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1781 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1783 extern void inode_init_once(struct inode *);
1784 extern void iput(struct inode *);
1785 @@ -1504,6 +1530,8 @@
1787 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1788 extern int vfs_follow_link(struct nameidata *, const char *);
1789 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1790 + struct lookup_intent *it);
1791 extern int page_readlink(struct dentry *, char *, int);
1792 extern int page_follow_link(struct dentry *, struct nameidata *);
1793 extern struct inode_operations page_symlink_inode_operations;
1794 Index: linux-2.4.20/include/linux/fs_struct.h
1795 ===================================================================
1796 --- linux-2.4.20.orig/include/linux/fs_struct.h Wed Mar 17 13:57:02 2004
1797 +++ linux-2.4.20/include/linux/fs_struct.h Wed Mar 17 13:57:11 2004
1799 write_lock(&fs->lock);
1800 old_root = fs->root;
1801 old_rootmnt = fs->rootmnt;
1802 + PIN(dentry, mnt, 1);
1803 fs->rootmnt = mntget(mnt);
1804 fs->root = dget(dentry);
1805 write_unlock(&fs->lock);
1807 + UNPIN(old_root, old_rootmnt, 1);
1809 mntput(old_rootmnt);
1812 write_lock(&fs->lock);
1814 old_pwdmnt = fs->pwdmnt;
1815 + PIN(dentry, mnt, 0);
1816 fs->pwdmnt = mntget(mnt);
1817 fs->pwd = dget(dentry);
1818 write_unlock(&fs->lock);
1820 + UNPIN(old_pwd, old_pwdmnt, 0);
1824 Index: linux-2.4.20/kernel/exit.c
1825 ===================================================================
1826 --- linux-2.4.20.orig/kernel/exit.c Wed Mar 17 13:57:05 2004
1827 +++ linux-2.4.20/kernel/exit.c Wed Mar 17 13:57:11 2004
1828 @@ -345,11 +345,14 @@
1830 /* No need to hold fs->lock if we are killing it */
1831 if (atomic_dec_and_test(&fs->count)) {
1832 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1833 + UNPIN(fs->root, fs->rootmnt, 1);
1835 mntput(fs->rootmnt);
1839 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1841 mntput(fs->altrootmnt);
1843 Index: linux-2.4.20/kernel/fork.c
1844 ===================================================================
1845 --- linux-2.4.20.orig/kernel/fork.c Wed Mar 17 13:57:05 2004
1846 +++ linux-2.4.20/kernel/fork.c Wed Mar 17 13:57:11 2004
1847 @@ -440,10 +440,13 @@
1848 fs->umask = old->umask;
1849 read_lock(&old->lock);
1850 fs->rootmnt = mntget(old->rootmnt);
1851 + PIN(old->pwd, old->pwdmnt, 0);
1852 + PIN(old->root, old->rootmnt, 1);
1853 fs->root = dget(old->root);
1854 fs->pwdmnt = mntget(old->pwdmnt);
1855 fs->pwd = dget(old->pwd);
1857 + PIN(old->altroot, old->altrootmnt, 1);
1858 fs->altrootmnt = mntget(old->altrootmnt);
1859 fs->altroot = dget(old->altroot);
1861 Index: linux-2.4.20/kernel/ksyms.c
1862 ===================================================================
1863 --- linux-2.4.20.orig/kernel/ksyms.c Wed Mar 17 13:57:11 2004
1864 +++ linux-2.4.20/kernel/ksyms.c Wed Mar 17 13:57:11 2004
1866 EXPORT_SYMBOL(set_page_dirty);
1867 EXPORT_SYMBOL(vfs_readlink);
1868 EXPORT_SYMBOL(vfs_follow_link);
1869 +EXPORT_SYMBOL(vfs_follow_link_it);
1870 EXPORT_SYMBOL(page_readlink);
1871 EXPORT_SYMBOL(page_follow_link);
1872 EXPORT_SYMBOL(page_symlink_inode_operations);