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);
381 + err = PTR_ERR(new);
384 + d_invalidate(dentry);
388 + if (!nd->dentry->d_inode)
390 + if (lookup_flags & LOOKUP_DIRECTORY) {
392 + if (!nd->dentry->d_inode->i_op ||
393 + (!nd->dentry->d_inode->i_op->lookup &&
394 + !nd->dentry->d_inode->i_op->lookup_it))
398 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
400 if (!dentry->d_op->d_revalidate(dentry, 0)) {
401 @@ -658,15 +732,28 @@
406 + intent_release(it);
412 +int link_path_walk(const char * name, struct nameidata *nd)
414 + return link_path_walk_it(name, nd, NULL);
417 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
419 + current->total_link_count = 0;
420 + return link_path_walk_it(name, nd, it);
423 int path_walk(const char * name, struct nameidata *nd)
425 current->total_link_count = 0;
426 - return link_path_walk(name, nd);
427 + return link_path_walk_it(name, nd, NULL);
435 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
436 + struct lookup_intent *it)
439 + if (path_init(path, flags, nd))
440 + error = path_walk_it(path, nd, it);
446 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
451 nd->last_type = LAST_ROOT; /* if there are only slashes... */
455 return walk_init_root(name,nd);
456 read_lock(¤t->fs->lock);
458 * needs parent already locked. Doesn't follow mounts.
461 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
462 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
463 + struct lookup_intent *it)
465 struct dentry * dentry;
467 @@ -802,13 +902,16 @@
471 - dentry = cached_lookup(base, name, 0);
472 + dentry = cached_lookup(base, name, 0, it);
474 struct dentry *new = d_alloc(base, name);
475 dentry = ERR_PTR(-ENOMEM);
479 + if (inode->i_op->lookup_it)
480 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
482 dentry = inode->i_op->lookup(inode, new);
489 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
491 + return lookup_hash_it(name, base, NULL);
496 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
500 this.hash = end_name_hash(hash);
502 - return lookup_hash(&this, base);
503 + return lookup_hash_it(&this, base, NULL);
505 return ERR_PTR(-EACCES);
511 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
512 + struct lookup_intent *it)
517 + tmp = getname(name);
518 + err = PTR_ERR(tmp);
519 + if (!IS_ERR(tmp)) {
521 + if (path_init(tmp, flags, nd))
522 + err = path_walk_it(tmp, nd, it);
529 * It's inline, so penalty for filesystems that don't use sticky bit is
535 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
536 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
537 + struct lookup_intent *it)
541 @@ -982,12 +1109,15 @@
544 error = -EACCES; /* shouldn't it be ENOSYS? */
545 - if (!dir->i_op || !dir->i_op->create)
546 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
551 - error = dir->i_op->create(dir, dentry, mode);
552 + if (dir->i_op->create_it)
553 + error = dir->i_op->create_it(dir, dentry, mode, it);
555 + error = dir->i_op->create(dir, dentry, mode);
559 @@ -996,6 +1126,11 @@
563 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
565 + return vfs_create_it(dir, dentry, mode, NULL);
571 @@ -1010,7 +1145,8 @@
572 * for symlinks (where the permissions are checked later).
575 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
576 +int open_namei_it(const char *pathname, int flag, int mode,
577 + struct nameidata *nd, struct lookup_intent *it)
579 int acc_mode, error = 0;
581 @@ -1020,11 +1156,14 @@
583 acc_mode = ACC_MODE(flag);
586 + it->it_flags = flag;
589 * The simplest case - just a plain lookup.
591 if (!(flag & O_CREAT)) {
592 - error = path_lookup(pathname, lookup_flags(flag), nd);
593 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
597 @@ -1034,6 +1173,10 @@
599 * Create - we need to know the parent.
602 + it->it_create_mode = mode;
603 + it->it_op |= IT_CREAT;
605 error = path_lookup(pathname, LOOKUP_PARENT, nd);
608 @@ -1049,7 +1192,7 @@
611 down(&dir->d_inode->i_sem);
612 - dentry = lookup_hash(&nd->last, nd->dentry);
613 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
616 error = PTR_ERR(dentry);
617 @@ -1058,10 +1201,11 @@
621 + it->it_create_mode = mode;
622 /* Negative dentry, just create the file */
623 if (!dentry->d_inode) {
624 - error = vfs_create(dir->d_inode, dentry,
625 - mode & ~current->fs->umask);
626 + error = vfs_create_it(dir->d_inode, dentry,
627 + mode & ~current->fs->umask, it);
628 up(&dir->d_inode->i_sem);
631 @@ -1086,7 +1230,7 @@
633 if (flag & O_NOFOLLOW)
635 - while (__follow_down(&nd->mnt,&dentry) && d_mountpoint(dentry));
636 + while (__follow_down(&nd->mnt,&dentry,it) && d_mountpoint(dentry));
639 if (!dentry->d_inode)
640 @@ -1165,7 +1309,7 @@
644 - error = do_truncate(dentry, 0);
645 + error = do_truncate(dentry, 0, 1);
647 put_write_access(inode);
649 @@ -1177,8 +1321,10 @@
653 + intent_release(it);
656 + intent_release(it);
660 @@ -1197,7 +1343,16 @@
661 * are done. Procfs-like symlinks just set LAST_BIND.
663 UPDATE_ATIME(dentry->d_inode);
665 error = dentry->d_inode->i_op->follow_link(dentry, nd);
667 + intent_release(it);
668 + } else if (it != NULL && !(it->d.lustre.it_int_flags & IT_FL_FOLLOWED)) {
669 + /* vfs_follow_link was never called */
670 + intent_release(it);
677 @@ -1219,13 +1374,20 @@
680 down(&dir->d_inode->i_sem);
681 - dentry = lookup_hash(&nd->last, nd->dentry);
682 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
683 putname(nd->last.name);
687 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
689 + return open_namei_it(pathname, flag, mode, nd, NULL);
694 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
695 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
696 + struct lookup_intent *it)
698 struct dentry *dentry;
700 @@ -1233,7 +1395,7 @@
701 dentry = ERR_PTR(-EEXIST);
702 if (nd->last_type != LAST_NORM)
704 - dentry = lookup_hash(&nd->last, nd->dentry);
705 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
708 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
709 @@ -1289,7 +1451,20 @@
710 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
713 - dentry = lookup_create(&nd, 0);
715 + if (nd.last_type != LAST_NORM) {
719 + if (nd.dentry->d_inode->i_op->mknod_raw) {
720 + struct inode_operations *op = nd.dentry->d_inode->i_op;
721 + error = op->mknod_raw(&nd, mode, dev);
722 + /* the file system wants to use normal vfs path now */
723 + if (error != -EOPNOTSUPP)
727 + dentry = lookup_create(&nd, 0, NULL);
728 error = PTR_ERR(dentry);
730 mode &= ~current->fs->umask;
731 @@ -1310,6 +1485,7 @@
734 up(&nd.dentry->d_inode->i_sem);
739 @@ -1357,7 +1533,18 @@
740 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
743 - dentry = lookup_create(&nd, 1);
744 + if (nd.last_type != LAST_NORM) {
748 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
749 + struct inode_operations *op = nd.dentry->d_inode->i_op;
750 + error = op->mkdir_raw(&nd, mode);
751 + /* the file system wants to use normal vfs path now */
752 + if (error != -EOPNOTSUPP)
755 + dentry = lookup_create(&nd, 1, NULL);
756 error = PTR_ERR(dentry);
757 if (!IS_ERR(dentry)) {
758 error = vfs_mkdir(nd.dentry->d_inode, dentry,
759 @@ -1365,6 +1552,7 @@
762 up(&nd.dentry->d_inode->i_sem);
767 @@ -1465,8 +1653,16 @@
771 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
772 + struct inode_operations *op = nd.dentry->d_inode->i_op;
774 + error = op->rmdir_raw(&nd);
775 + /* the file system wants to use normal vfs path now */
776 + if (error != -EOPNOTSUPP)
779 down(&nd.dentry->d_inode->i_sem);
780 - dentry = lookup_hash(&nd.last, nd.dentry);
781 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
782 error = PTR_ERR(dentry);
783 if (!IS_ERR(dentry)) {
784 error = vfs_rmdir(nd.dentry->d_inode, dentry);
785 @@ -1524,8 +1720,15 @@
787 if (nd.last_type != LAST_NORM)
789 + if (nd.dentry->d_inode->i_op->unlink_raw) {
790 + struct inode_operations *op = nd.dentry->d_inode->i_op;
791 + error = op->unlink_raw(&nd);
792 + /* the file system wants to use normal vfs path now */
793 + if (error != -EOPNOTSUPP)
796 down(&nd.dentry->d_inode->i_sem);
797 - dentry = lookup_hash(&nd.last, nd.dentry);
798 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
799 error = PTR_ERR(dentry);
800 if (!IS_ERR(dentry)) {
801 /* Why not before? Because we want correct error value */
802 @@ -1592,15 +1795,27 @@
803 error = path_lookup(to, LOOKUP_PARENT, &nd);
806 - dentry = lookup_create(&nd, 0);
807 + if (nd.last_type != LAST_NORM) {
811 + if (nd.dentry->d_inode->i_op->symlink_raw) {
812 + struct inode_operations *op = nd.dentry->d_inode->i_op;
813 + error = op->symlink_raw(&nd, from);
814 + /* the file system wants to use normal vfs path now */
815 + if (error != -EOPNOTSUPP)
818 + dentry = lookup_create(&nd, 0, NULL);
819 error = PTR_ERR(dentry);
820 if (!IS_ERR(dentry)) {
821 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
824 up(&nd.dentry->d_inode->i_sem);
832 @@ -1676,7 +1891,18 @@
834 if (old_nd.mnt != nd.mnt)
836 - new_dentry = lookup_create(&nd, 0);
837 + if (nd.last_type != LAST_NORM) {
841 + if (nd.dentry->d_inode->i_op->link_raw) {
842 + struct inode_operations *op = nd.dentry->d_inode->i_op;
843 + error = op->link_raw(&old_nd, &nd);
844 + /* the file system wants to use normal vfs path now */
845 + if (error != -EOPNOTSUPP)
848 + new_dentry = lookup_create(&nd, 0, NULL);
849 error = PTR_ERR(new_dentry);
850 if (!IS_ERR(new_dentry)) {
851 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
852 @@ -1720,7 +1946,7 @@
855 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
856 - struct inode *new_dir, struct dentry *new_dentry)
857 + struct inode *new_dir, struct dentry *new_dentry)
860 struct inode *target;
861 @@ -1799,7 +2025,7 @@
864 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
865 - struct inode *new_dir, struct dentry *new_dentry)
866 + struct inode *new_dir, struct dentry *new_dentry)
870 @@ -1887,9 +2113,18 @@
871 if (newnd.last_type != LAST_NORM)
874 + if (old_dir->d_inode->i_op->rename_raw) {
876 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
878 + /* the file system wants to use normal vfs path now */
879 + if (error != -EOPNOTSUPP)
883 double_lock(new_dir, old_dir);
885 - old_dentry = lookup_hash(&oldnd.last, old_dir);
886 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
887 error = PTR_ERR(old_dentry);
888 if (IS_ERR(old_dentry))
890 @@ -1905,16 +2140,16 @@
891 if (newnd.last.name[newnd.last.len])
894 - new_dentry = lookup_hash(&newnd.last, new_dir);
895 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
896 error = PTR_ERR(new_dentry);
897 if (IS_ERR(new_dentry))
902 error = vfs_rename(old_dir->d_inode, old_dentry,
903 new_dir->d_inode, new_dentry);
909 @@ -1965,20 +2200,28 @@
913 -__vfs_follow_link(struct nameidata *nd, const char *link)
914 +__vfs_follow_link(struct nameidata *nd, const char *link,
915 + struct lookup_intent *it)
924 + else if (it != nd->intent)
925 + printk("it != nd->intent: tell phil@clusterfs.com\n");
927 + it->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
931 if (!walk_init_root(link, nd))
932 /* weird __emul_prefix() stuff did it */
935 - res = link_path_walk(link, nd);
936 + res = link_path_walk_it(link, nd, it);
938 if (current->link_count || res || nd->last_type!=LAST_NORM)
940 @@ -2002,7 +2245,13 @@
942 int vfs_follow_link(struct nameidata *nd, const char *link)
944 - return __vfs_follow_link(nd, link);
945 + return __vfs_follow_link(nd, link, NULL);
948 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
949 + struct lookup_intent *it)
951 + return __vfs_follow_link(nd, link, it);
954 /* get the link contents into pagecache */
955 @@ -2044,7 +2293,7 @@
957 struct page *page = NULL;
958 char *s = page_getlink(dentry, &page);
959 - int res = __vfs_follow_link(nd, s);
960 + int res = __vfs_follow_link(nd, s, NULL);
963 page_cache_release(page);
964 Index: linux-2.4.20/fs/namespace.c
965 ===================================================================
966 --- linux-2.4.20.orig/fs/namespace.c Wed Mar 17 13:57:05 2004
967 +++ linux-2.4.20/fs/namespace.c Wed Mar 17 13:57:11 2004
970 old_nd->dentry = mnt->mnt_mountpoint;
971 old_nd->mnt = mnt->mnt_parent;
972 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
973 mnt->mnt_parent = mnt;
974 mnt->mnt_mountpoint = mnt->mnt_root;
975 list_del_init(&mnt->mnt_child);
978 mnt->mnt_parent = mntget(nd->mnt);
979 mnt->mnt_mountpoint = dget(nd->dentry);
980 + PIN(nd->dentry, nd->mnt, 1);
981 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
982 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
983 nd->dentry->d_mounted++;
984 @@ -485,14 +487,17 @@
986 struct nameidata old_nd;
987 struct vfsmount *mnt = NULL;
988 + struct lookup_intent it = { .it_op = IT_GETATTR };
989 int err = mount_is_safe(nd);
992 if (!old_name || !*old_name)
994 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
996 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
998 + intent_release(&it);
1002 down_write(¤t->namespace->sem);
1007 up_write(¤t->namespace->sem);
1008 + intent_release(&it);
1009 path_release(&old_nd);
1013 unsigned long flags, void *data_page)
1015 struct nameidata nd;
1016 + struct lookup_intent it = { .it_op = IT_GETATTR };
1020 @@ -722,10 +729,11 @@
1021 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
1023 /* ... and get the mountpoint */
1024 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
1026 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
1028 + intent_release(&it);
1032 if (flags & MS_REMOUNT)
1033 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
1037 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
1038 dev_name, data_page);
1040 + intent_release(&it);
1046 struct vfsmount *tmp;
1047 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
1048 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
1049 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
1052 if (!capable(CAP_SYS_ADMIN))
1053 @@ -908,14 +920,14 @@
1057 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
1058 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
1062 if (!check_mnt(new_nd.mnt))
1065 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
1066 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
1070 @@ -970,8 +982,10 @@
1071 up(&old_nd.dentry->d_inode->i_zombie);
1072 up_write(¤t->namespace->sem);
1073 path_release(&user_nd);
1074 + intent_release(&old_it);
1075 path_release(&old_nd);
1077 + intent_release(&new_it);
1078 path_release(&new_nd);
1081 Index: linux-2.4.20/fs/open.c
1082 ===================================================================
1083 --- linux-2.4.20.orig/fs/open.c Wed Mar 17 13:57:03 2004
1084 +++ linux-2.4.20/fs/open.c Wed Mar 17 13:57:11 2004
1086 #include <asm/uaccess.h>
1088 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1089 +extern int path_walk_it(const char *name, struct nameidata *nd,
1090 + struct lookup_intent *it);
1092 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1095 write_unlock(&files->file_lock);
1098 -int do_truncate(struct dentry *dentry, loff_t length)
1099 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1101 struct inode *inode = dentry->d_inode;
1102 + struct inode_operations *op = dentry->d_inode->i_op;
1104 struct iattr newattrs;
1106 @@ -108,7 +111,13 @@
1107 down(&inode->i_sem);
1108 newattrs.ia_size = length;
1109 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1110 - error = notify_change(dentry, &newattrs);
1111 + if (called_from_open)
1112 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1113 + if (op->setattr_raw) {
1114 + newattrs.ia_valid |= ATTR_RAW;
1115 + error = op->setattr_raw(inode, &newattrs);
1117 + error = notify_change(dentry, &newattrs);
1121 @@ -118,12 +127,13 @@
1122 struct nameidata nd;
1123 struct inode * inode;
1125 + struct lookup_intent it = { .it_op = IT_GETATTR };
1128 if (length < 0) /* sorry, but loff_t says... */
1131 - error = user_path_walk(path, &nd);
1132 + error = user_path_walk_it(path, &nd, &it);
1135 inode = nd.dentry->d_inode;
1136 @@ -163,11 +173,13 @@
1137 error = locks_verify_truncate(inode, NULL, length);
1140 - error = do_truncate(nd.dentry, length);
1141 + intent_release(&it);
1142 + error = do_truncate(nd.dentry, length, 0);
1144 put_write_access(inode);
1147 + intent_release(&it);
1153 error = locks_verify_truncate(inode, file, length);
1155 - error = do_truncate(dentry, length);
1156 + error = do_truncate(dentry, length, 0);
1160 @@ -260,11 +272,13 @@
1161 struct inode * inode;
1162 struct iattr newattrs;
1164 - error = user_path_walk(filename, &nd);
1165 + error = user_path_walk_it(filename, &nd, NULL);
1168 inode = nd.dentry->d_inode;
1170 + /* this is safe without a Lustre lock because it only depends
1171 + on the super block */
1173 if (IS_RDONLY(inode))
1175 @@ -279,11 +293,25 @@
1178 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1182 + if (inode->i_op->setattr_raw) {
1183 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1185 + newattrs.ia_valid |= ATTR_RAW;
1186 + error = op->setattr_raw(inode, &newattrs);
1187 + /* the file system wants to use normal vfs path now */
1188 + if (error != -EOPNOTSUPP)
1189 + goto dput_and_out;
1194 if (current->fsuid != inode->i_uid &&
1195 (error = permission(inode,MAY_WRITE)) != 0)
1199 error = notify_change(nd.dentry, &newattrs);
1202 @@ -304,12 +332,14 @@
1203 struct inode * inode;
1204 struct iattr newattrs;
1206 - error = user_path_walk(filename, &nd);
1207 + error = user_path_walk_it(filename, &nd, NULL);
1211 inode = nd.dentry->d_inode;
1213 + /* this is safe without a Lustre lock because it only depends
1214 + on the super block */
1216 if (IS_RDONLY(inode))
1218 @@ -324,7 +354,20 @@
1219 newattrs.ia_atime = times[0].tv_sec;
1220 newattrs.ia_mtime = times[1].tv_sec;
1221 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1225 + if (inode->i_op->setattr_raw) {
1226 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1228 + newattrs.ia_valid |= ATTR_RAW;
1229 + error = op->setattr_raw(inode, &newattrs);
1230 + /* the file system wants to use normal vfs path now */
1231 + if (error != -EOPNOTSUPP)
1232 + goto dput_and_out;
1237 if (current->fsuid != inode->i_uid &&
1238 (error = permission(inode,MAY_WRITE)) != 0)
1241 int old_fsuid, old_fsgid;
1242 kernel_cap_t old_cap;
1244 + struct lookup_intent it = { .it_op = IT_GETATTR };
1246 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1248 @@ -364,13 +408,14 @@
1250 current->cap_effective = current->cap_permitted;
1252 - res = user_path_walk(filename, &nd);
1253 + res = user_path_walk_it(filename, &nd, &it);
1255 res = permission(nd.dentry->d_inode, mode);
1256 /* SuS v2 requires we report a read only fs too */
1257 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1258 && !special_file(nd.dentry->d_inode->i_mode))
1260 + intent_release(&it);
1267 struct nameidata nd;
1268 + struct lookup_intent it = { .it_op = IT_GETATTR };
1270 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1271 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1276 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1279 + intent_release(&it);
1283 @@ -436,9 +483,10 @@
1286 struct nameidata nd;
1287 + struct lookup_intent it = { .it_op = IT_GETATTR };
1289 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1290 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1291 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1292 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1296 @@ -454,39 +502,56 @@
1300 + intent_release(&it);
1306 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1307 +int chmod_common(struct dentry *dentry, mode_t mode)
1309 - struct inode * inode;
1310 - struct dentry * dentry;
1311 - struct file * file;
1313 + struct inode *inode = dentry->d_inode;
1314 struct iattr newattrs;
1319 + if (IS_RDONLY(inode))
1322 - dentry = file->f_dentry;
1323 - inode = dentry->d_inode;
1324 + if (inode->i_op->setattr_raw) {
1325 + newattrs.ia_mode = mode;
1326 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1327 + newattrs.ia_valid |= ATTR_RAW;
1328 + err = inode->i_op->setattr_raw(inode, &newattrs);
1329 + /* the file system wants to use normal vfs path now */
1330 + if (err != -EOPNOTSUPP)
1335 - if (IS_RDONLY(inode))
1338 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1342 if (mode == (mode_t) -1)
1343 mode = inode->i_mode;
1344 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1345 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1346 err = notify_change(dentry, &newattrs);
1353 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1355 + struct file * file;
1362 + err = chmod_common(file->f_dentry, mode);
1367 @@ -495,30 +560,14 @@
1368 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1370 struct nameidata nd;
1371 - struct inode * inode;
1373 - struct iattr newattrs;
1375 error = user_path_walk(filename, &nd);
1378 - inode = nd.dentry->d_inode;
1381 - if (IS_RDONLY(inode))
1382 - goto dput_and_out;
1385 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1386 - goto dput_and_out;
1388 - if (mode == (mode_t) -1)
1389 - mode = inode->i_mode;
1390 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1391 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1392 - error = notify_change(nd.dentry, &newattrs);
1393 + error = chmod_common(nd.dentry, mode);
1399 @@ -538,6 +587,20 @@
1401 if (IS_RDONLY(inode))
1404 + if (inode->i_op->setattr_raw) {
1405 + struct inode_operations *op = dentry->d_inode->i_op;
1407 + newattrs.ia_uid = user;
1408 + newattrs.ia_gid = group;
1409 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1410 + newattrs.ia_valid |= ATTR_RAW;
1411 + error = op->setattr_raw(inode, &newattrs);
1412 + /* the file system wants to use normal vfs path now */
1413 + if (error != -EOPNOTSUPP)
1418 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1422 int namei_flags, error;
1423 struct nameidata nd;
1425 - flags &= ~O_DIRECT;
1426 + struct lookup_intent it = { .it_op = IT_OPEN };
1428 + //flags &= ~O_DIRECT;
1430 namei_flags = flags;
1431 if ((namei_flags+1) & O_ACCMODE)
1432 @@ -651,14 +715,15 @@
1433 if (namei_flags & O_TRUNC)
1436 - error = open_namei(filename, namei_flags, mode, &nd);
1438 - return dentry_open(nd.dentry, nd.mnt, flags);
1439 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1441 + return ERR_PTR(error);
1443 - return ERR_PTR(error);
1444 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1447 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1448 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1449 + int flags, struct lookup_intent *it)
1452 struct inode *inode;
1453 @@ -695,12 +760,15 @@
1456 if (f->f_op && f->f_op->open) {
1458 error = f->f_op->open(inode,f);
1463 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1465 + intent_release(it);
1469 @@ -715,11 +783,17 @@
1473 + intent_release(it);
1476 return ERR_PTR(error);
1479 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1481 + return dentry_open_it(dentry, mnt, flags, NULL);
1485 * Find an empty file descriptor entry, and mark it busy.
1487 Index: linux-2.4.20/fs/proc/base.c
1488 ===================================================================
1489 --- linux-2.4.20.orig/fs/proc/base.c Wed Mar 17 13:57:05 2004
1490 +++ linux-2.4.20/fs/proc/base.c Wed Mar 17 13:57:11 2004
1493 error = inode->u.proc_i.op.proc_get_link(inode, &nd->dentry, &nd->mnt);
1494 nd->last_type = LAST_BIND;
1496 + if (nd->intent != NULL)
1497 + nd->intent->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
1501 Index: linux-2.4.20/fs/stat.c
1502 ===================================================================
1503 --- linux-2.4.20.orig/fs/stat.c Wed Mar 17 13:57:05 2004
1504 +++ linux-2.4.20/fs/stat.c Wed Mar 17 13:58:01 2004
1506 * Revalidate the inode. This is required for proper NFS attribute caching.
1508 static __inline__ int
1509 -do_revalidate(struct dentry *dentry)
1510 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1512 struct inode * inode = dentry->d_inode;
1513 - if (inode->i_op && inode->i_op->revalidate)
1514 + if (inode->i_op && inode->i_op->revalidate_it)
1515 + return inode->i_op->revalidate_it(dentry, it);
1516 + else if (inode->i_op && inode->i_op->revalidate)
1517 return inode->i_op->revalidate(dentry);
1521 return inode->i_nlink;
1524 -static int do_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
1525 +static int do_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat, struct lookup_intent *it)
1528 unsigned int blocks, indirect;
1529 struct inode *inode = dentry->d_inode;
1531 - res = do_revalidate(dentry);
1532 + res = do_revalidate(dentry, it);
1536 @@ -111,10 +113,12 @@
1538 struct nameidata nd;
1540 + struct lookup_intent it = { .it_op = IT_GETATTR };
1542 - error = user_path_walk(name, &nd);
1543 + error = user_path_walk_it(name, &nd, &it);
1545 - error = do_getattr(nd.mnt, nd.dentry, stat);
1546 + error = do_getattr(nd.mnt, nd.dentry, stat, &it);
1547 + intent_release(&it);
1551 @@ -124,10 +128,12 @@
1553 struct nameidata nd;
1555 + struct lookup_intent it = { .it_op = IT_GETATTR };
1557 - error = user_path_walk_link(name, &nd);
1558 + error = user_path_walk_link_it(name, &nd, &it);
1560 - error = do_getattr(nd.mnt, nd.dentry, stat);
1561 + error = do_getattr(nd.mnt, nd.dentry, stat, &it);
1562 + intent_release(&it);
1570 - error = do_getattr(f->f_vfsmnt, f->f_dentry, stat);
1571 + error = do_getattr(f->f_vfsmnt, f->f_dentry, stat, NULL);
1578 if (inode->i_op && inode->i_op->readlink &&
1579 - !(error = do_revalidate(nd.dentry))) {
1580 + !(error = do_revalidate(nd.dentry, NULL))) {
1581 UPDATE_ATIME(inode);
1582 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1584 Index: linux-2.4.20/include/linux/dcache.h
1585 ===================================================================
1586 --- linux-2.4.20.orig/include/linux/dcache.h Wed Mar 17 13:57:04 2004
1587 +++ linux-2.4.20/include/linux/dcache.h Wed Mar 17 13:57:11 2004
1589 #include <asm/atomic.h>
1590 #include <linux/mount.h>
1591 #include <linux/kernel.h>
1592 +#include <linux/string.h>
1594 +#define IT_OPEN 0x0001
1595 +#define IT_CREAT 0x0002
1596 +#define IT_READDIR 0x0004
1597 +#define IT_GETATTR 0x0008
1598 +#define IT_LOOKUP 0x0010
1599 +#define IT_UNLINK 0x0020
1600 +#define IT_GETXATTR 0x0040
1601 +#define IT_EXEC 0x0080
1602 +#define IT_PIN 0x0100
1604 +#define IT_FL_LOCKED 0x0001
1605 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1607 +#define INTENT_MAGIC 0x19620323
1610 +struct lustre_intent_data {
1611 + int it_disposition;
1613 + __u64 it_lock_handle;
1618 +struct lookup_intent {
1620 + void (*it_op_release)(struct lookup_intent *);
1623 + int it_create_mode;
1625 + struct lustre_intent_data lustre;
1629 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1631 + memset(it, 0, sizeof(*it));
1632 + it->it_magic = INTENT_MAGIC;
1634 + it->it_flags = flags;
1639 * linux/include/linux/dcache.h
1641 int (*d_delete)(struct dentry *);
1642 void (*d_release)(struct dentry *);
1643 void (*d_iput)(struct dentry *, struct inode *);
1644 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1645 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1646 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1649 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1650 + de->d_op->d_pin(de, mnt, flag);
1651 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1652 + de->d_op->d_unpin(de, mnt, flag);
1655 +/* defined in fs/namei.c */
1656 +extern void intent_release(struct lookup_intent *it);
1657 +/* defined in fs/dcache.c */
1658 +extern void __d_rehash(struct dentry * entry, int lock);
1660 /* the dentry parameter passed to d_hash and d_compare is the parent
1661 * directory of the entries to be compared. It is used in case these
1662 * functions need any directory specific information for determining
1664 * s_nfsd_free_path semaphore will be down
1666 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1667 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1669 extern spinlock_t dcache_lock;
1671 Index: linux-2.4.20/include/linux/fs.h
1672 ===================================================================
1673 --- linux-2.4.20.orig/include/linux/fs.h Wed Mar 17 13:57:11 2004
1674 +++ linux-2.4.20/include/linux/fs.h Wed Mar 17 13:57:11 2004
1677 #define FMODE_READ 1
1678 #define FMODE_WRITE 2
1679 +#define FMODE_EXEC 4
1684 #define ATTR_MTIME_SET 256
1685 #define ATTR_FORCE 512 /* Not a change, but a change it */
1686 #define ATTR_ATTR_FLAG 1024
1687 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1688 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1689 +#define ATTR_CTIME_SET 0x2000
1692 * This is the Inode Attributes structure, used for notify_change(). It
1694 struct pipe_inode_info *i_pipe;
1695 struct block_device *i_bdev;
1696 struct char_device *i_cdev;
1697 + void *i_filterdata;
1699 unsigned long i_dnotify_mask; /* Directory notify events */
1700 struct dnotify_struct *i_dnotify; /* for directory notifications */
1703 /* needed for tty driver, and maybe others */
1705 + struct lookup_intent *f_it;
1707 /* preallocated helper kiobuf to speedup O_DIRECT */
1708 struct kiobuf *f_iobuf;
1713 + struct lookup_intent *intent;
1718 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1719 extern int vfs_rmdir(struct inode *, struct dentry *);
1720 extern int vfs_unlink(struct inode *, struct dentry *);
1721 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1722 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1723 + struct inode *new_dir, struct dentry *new_dentry);
1727 @@ -882,21 +890,32 @@
1729 struct inode_operations {
1730 int (*create) (struct inode *,struct dentry *,int);
1731 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1732 struct dentry * (*lookup) (struct inode *,struct dentry *);
1733 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1734 int (*link) (struct dentry *,struct inode *,struct dentry *);
1735 + int (*link_raw) (struct nameidata *,struct nameidata *);
1736 int (*unlink) (struct inode *,struct dentry *);
1737 + int (*unlink_raw) (struct nameidata *);
1738 int (*symlink) (struct inode *,struct dentry *,const char *);
1739 + int (*symlink_raw) (struct nameidata *,const char *);
1740 int (*mkdir) (struct inode *,struct dentry *,int);
1741 + int (*mkdir_raw) (struct nameidata *,int);
1742 int (*rmdir) (struct inode *,struct dentry *);
1743 + int (*rmdir_raw) (struct nameidata *);
1744 int (*mknod) (struct inode *,struct dentry *,int,int);
1745 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1746 int (*rename) (struct inode *, struct dentry *,
1747 struct inode *, struct dentry *);
1748 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1749 int (*readlink) (struct dentry *, char *,int);
1750 int (*follow_link) (struct dentry *, struct nameidata *);
1751 void (*truncate) (struct inode *);
1752 int (*permission) (struct inode *, int);
1753 int (*revalidate) (struct dentry *);
1754 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1755 int (*setattr) (struct dentry *, struct iattr *);
1756 + int (*setattr_raw) (struct inode *, struct iattr *);
1757 int (*getattr) (struct dentry *, struct iattr *);
1758 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
1759 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1760 @@ -1092,10 +1111,14 @@
1762 asmlinkage long sys_open(const char *, int, int);
1763 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1764 -extern int do_truncate(struct dentry *, loff_t start);
1765 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1767 extern struct file *filp_open(const char *, int, int);
1768 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1769 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1770 + struct nameidata *nd, struct lookup_intent *it);
1771 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1772 + int flags, struct lookup_intent *it);
1773 extern int filp_close(struct file *, fl_owner_t id);
1774 extern char * getname(const char *);
1776 @@ -1386,6 +1409,7 @@
1777 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1779 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1780 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1781 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1782 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1783 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1784 @@ -1397,6 +1421,8 @@
1785 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1786 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1787 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1788 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1789 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1791 extern void inode_init_once(struct inode *);
1792 extern void iput(struct inode *);
1793 @@ -1504,6 +1530,8 @@
1795 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1796 extern int vfs_follow_link(struct nameidata *, const char *);
1797 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1798 + struct lookup_intent *it);
1799 extern int page_readlink(struct dentry *, char *, int);
1800 extern int page_follow_link(struct dentry *, struct nameidata *);
1801 extern struct inode_operations page_symlink_inode_operations;
1802 Index: linux-2.4.20/include/linux/fs_struct.h
1803 ===================================================================
1804 --- linux-2.4.20.orig/include/linux/fs_struct.h Wed Mar 17 13:57:02 2004
1805 +++ linux-2.4.20/include/linux/fs_struct.h Wed Mar 17 13:57:11 2004
1807 write_lock(&fs->lock);
1808 old_root = fs->root;
1809 old_rootmnt = fs->rootmnt;
1810 + PIN(dentry, mnt, 1);
1811 fs->rootmnt = mntget(mnt);
1812 fs->root = dget(dentry);
1813 write_unlock(&fs->lock);
1815 + UNPIN(old_root, old_rootmnt, 1);
1817 mntput(old_rootmnt);
1820 write_lock(&fs->lock);
1822 old_pwdmnt = fs->pwdmnt;
1823 + PIN(dentry, mnt, 0);
1824 fs->pwdmnt = mntget(mnt);
1825 fs->pwd = dget(dentry);
1826 write_unlock(&fs->lock);
1828 + UNPIN(old_pwd, old_pwdmnt, 0);
1832 Index: linux-2.4.20/kernel/ksyms.c
1833 ===================================================================
1834 --- linux-2.4.20.orig/kernel/ksyms.c Wed Mar 17 13:57:11 2004
1835 +++ linux-2.4.20/kernel/ksyms.c Wed Mar 17 13:57:11 2004
1837 EXPORT_SYMBOL(set_page_dirty);
1838 EXPORT_SYMBOL(vfs_readlink);
1839 EXPORT_SYMBOL(vfs_follow_link);
1840 +EXPORT_SYMBOL(vfs_follow_link_it);
1841 EXPORT_SYMBOL(page_readlink);
1842 EXPORT_SYMBOL(page_follow_link);
1843 EXPORT_SYMBOL(page_symlink_inode_operations);
1844 Index: linux-2.4.20/kernel/fork.c
1845 ===================================================================
1846 --- linux-2.4.20.orig/kernel/fork.c Wed Mar 17 13:57:05 2004
1847 +++ linux-2.4.20/kernel/fork.c Wed Mar 17 13:57:11 2004
1848 @@ -440,10 +440,13 @@
1849 fs->umask = old->umask;
1850 read_lock(&old->lock);
1851 fs->rootmnt = mntget(old->rootmnt);
1852 + PIN(old->pwd, old->pwdmnt, 0);
1853 + PIN(old->root, old->rootmnt, 1);
1854 fs->root = dget(old->root);
1855 fs->pwdmnt = mntget(old->pwdmnt);
1856 fs->pwd = dget(old->pwd);
1858 + PIN(old->altroot, old->altrootmnt, 1);
1859 fs->altrootmnt = mntget(old->altrootmnt);
1860 fs->altroot = dget(old->altroot);
1862 Index: linux-2.4.20/kernel/exit.c
1863 ===================================================================
1864 --- linux-2.4.20.orig/kernel/exit.c Wed Mar 17 13:57:05 2004
1865 +++ linux-2.4.20/kernel/exit.c Wed Mar 17 13:57:11 2004
1866 @@ -345,11 +345,14 @@
1868 /* No need to hold fs->lock if we are killing it */
1869 if (atomic_dec_and_test(&fs->count)) {
1870 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1871 + UNPIN(fs->root, fs->rootmnt, 1);
1873 mntput(fs->rootmnt);
1877 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1879 mntput(fs->altrootmnt);