3 fs/namei.c | 295 +++++++++++++++++++++++++++++++++++++++-------
4 fs/namespace.c | 28 +++-
5 fs/open.c | 172 +++++++++++++++++++-------
6 fs/stat.c | 52 +++++---
7 include/linux/dcache.h | 60 +++++++++
8 include/linux/fs.h | 32 ++++
9 include/linux/fs_struct.h | 4
13 12 files changed, 558 insertions(+), 128 deletions(-)
15 Index: linux-2.4.19-pre1/fs/dcache.c
16 ===================================================================
17 --- linux-2.4.19-pre1.orig/fs/dcache.c 2003-11-21 02:41:00.000000000 +0300
18 +++ linux-2.4.19-pre1/fs/dcache.c 2003-11-21 02:51:38.000000000 +0300
20 spin_unlock(&dcache_lock);
24 + /* network invalidation by Lustre */
25 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
26 + spin_unlock(&dcache_lock);
31 * Check whether to do a partial shrink_dcache
32 * to get rid of unused child entries.
34 * Adds a dentry to the hash according to its name.
37 -void d_rehash(struct dentry * entry)
38 +void __d_rehash(struct dentry * entry, int lock)
40 struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
41 if (!list_empty(&entry->d_hash)) BUG();
42 - spin_lock(&dcache_lock);
43 + if (lock) spin_lock(&dcache_lock);
44 list_add(&entry->d_hash, list);
45 - spin_unlock(&dcache_lock);
46 + if (lock) spin_unlock(&dcache_lock);
48 +EXPORT_SYMBOL(__d_rehash);
50 +void d_rehash(struct dentry * entry)
52 + __d_rehash(entry, 1);
55 #define do_switch(x,y) do { \
56 Index: linux-2.4.19-pre1/fs/exec.c
57 ===================================================================
58 --- linux-2.4.19-pre1.orig/fs/exec.c 2003-11-21 02:41:00.000000000 +0300
59 +++ linux-2.4.19-pre1/fs/exec.c 2003-11-21 02:51:38.000000000 +0300
64 + struct lookup_intent it = { .it_op = IT_OPEN,
65 + .it_flags = FMODE_READ|FMODE_EXEC };
67 - error = user_path_walk(library, &nd);
68 + error = user_path_walk_it(library, &nd, &it);
76 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
77 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
78 + intent_release(&it);
79 error = PTR_ERR(file);
86 + struct lookup_intent it = { .it_op = IT_OPEN,
87 + .it_flags = FMODE_READ|FMODE_EXEC };
89 if (path_init(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd))
90 - err = path_walk(name, &nd);
91 + err = path_walk_it(name, &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);
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.19-pre1/fs/namei.c
123 ===================================================================
124 --- linux-2.4.19-pre1.orig/fs/namei.c 2003-11-21 02:41:00.000000000 +0300
125 +++ linux-2.4.19-pre1/fs/namei.c 2003-11-21 02:52:01.000000000 +0300
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 >= 5)
214 @@ -346,10 +379,12 @@
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 current->link_count--;
223 + intent_release(it);
229 * We expect 'base' to be positive and a directory.
231 -int link_path_walk(const char * name, struct nameidata *nd)
232 +int link_path_walk_it(const char *name, struct nameidata *nd,
233 + struct lookup_intent *it)
235 struct dentry *dentry;
244 inode = nd->dentry->d_inode;
245 if (current->link_count)
249 /* This does the actual lookups.. */
250 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
251 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
253 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
254 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE,
256 err = PTR_ERR(dentry);
262 if (inode->i_op->follow_link) {
263 - err = do_follow_link(dentry, nd);
264 + err = do_follow_link(dentry, nd, NULL);
272 - if (!inode->i_op->lookup)
273 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
276 /* here ends the main loop */
277 @@ -574,16 +611,16 @@
278 inode = nd->dentry->d_inode;
284 if (nd->dentry->d_op && nd->dentry->d_op->d_hash) {
285 err = nd->dentry->d_op->d_hash(nd->dentry, &this);
289 - dentry = cached_lookup(nd->dentry, &this, 0);
290 + dentry = cached_lookup(nd->dentry, &this, 0, it);
292 - dentry = real_lookup(nd->dentry, &this, 0);
293 + dentry = real_lookup(nd->dentry, &this, 0, it);
294 err = PTR_ERR(dentry);
298 inode = dentry->d_inode;
299 if ((lookup_flags & LOOKUP_FOLLOW)
300 && inode && inode->i_op && inode->i_op->follow_link) {
301 - err = do_follow_link(dentry, nd);
302 + err = do_follow_link(dentry, nd, it);
308 if (lookup_flags & LOOKUP_DIRECTORY) {
310 - if (!inode->i_op || !inode->i_op->lookup)
311 + if (!inode->i_op ||
312 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
316 @@ -625,21 +663,68 @@
317 nd->last_type = LAST_DOT;
318 else if (this.len == 2 && this.name[1] == '.')
319 nd->last_type = LAST_DOTDOT;
322 + * We bypassed the ordinary revalidation routines.
323 + * Check the cached dentry for staleness.
325 + dentry = nd->dentry;
326 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
328 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
329 + struct dentry *new;
330 + err = permission(dentry->d_parent->d_inode,
334 + new = real_lookup(dentry->d_parent,
335 + &dentry->d_name, 0, it);
337 + err = PTR_ERR(new);
340 + d_invalidate(dentry);
344 + if (!nd->dentry->d_inode)
347 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
349 + if (!dentry->d_op->d_revalidate(dentry, 0)) {
350 + d_invalidate(dentry);
361 + intent_release(it);
367 +int link_path_walk(const char * name, struct nameidata *nd)
369 + return link_path_walk_it(name, nd, NULL);
372 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
374 + current->total_link_count = 0;
375 + return link_path_walk_it(name, nd, it);
378 int path_walk(const char * name, struct nameidata *nd)
380 current->total_link_count = 0;
381 - return link_path_walk(name, nd);
382 + return link_path_walk_it(name, nd, NULL);
388 nd->last_type = LAST_ROOT; /* if there are only slashes... */
392 return walk_init_root(name,nd);
393 read_lock(¤t->fs->lock);
395 * needs parent already locked. Doesn't follow mounts.
398 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
399 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
400 + struct lookup_intent *it)
402 struct dentry * dentry;
404 @@ -765,13 +850,16 @@
408 - dentry = cached_lookup(base, name, 0);
409 + dentry = cached_lookup(base, name, 0, it);
411 struct dentry *new = d_alloc(base, name);
412 dentry = ERR_PTR(-ENOMEM);
416 + if (inode->i_op->lookup_it)
417 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
419 dentry = inode->i_op->lookup(inode, new);
426 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
428 + return lookup_hash_it(name, base, NULL);
433 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
437 this.hash = end_name_hash(hash);
439 - return lookup_hash(&this, base);
440 + return lookup_hash_it(&this, base, NULL);
442 return ERR_PTR(-EACCES);
448 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
449 + struct lookup_intent *it)
454 + tmp = getname(name);
455 + err = PTR_ERR(tmp);
456 + if (!IS_ERR(tmp)) {
458 + if (path_init(tmp, flags, nd))
459 + err = path_walk_it(tmp, nd, it);
466 * It's inline, so penalty for filesystems that don't use sticky bit is
472 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
473 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
474 + struct lookup_intent *it)
478 @@ -942,12 +1054,15 @@
481 error = -EACCES; /* shouldn't it be ENOSYS? */
482 - if (!dir->i_op || !dir->i_op->create)
483 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
488 - error = dir->i_op->create(dir, dentry, mode);
489 + if (dir->i_op->create_it)
490 + error = dir->i_op->create_it(dir, dentry, mode, it);
492 + error = dir->i_op->create(dir, dentry, mode);
496 @@ -956,6 +1071,11 @@
500 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
502 + return vfs_create_it(dir, dentry, mode, NULL);
509 * for symlinks (where the permissions are checked later).
512 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
513 +int open_namei_it(const char *pathname, int flag, int mode,
514 + struct nameidata *nd, struct lookup_intent *it)
516 int acc_mode, error = 0;
518 @@ -980,12 +1101,14 @@
520 acc_mode = ACC_MODE(flag);
523 + it->it_flags = flag;
525 * The simplest case - just a plain lookup.
527 if (!(flag & O_CREAT)) {
528 if (path_init(pathname, lookup_flags(flag), nd))
529 - error = path_walk(pathname, nd);
530 + error = path_walk_it(pathname, nd, it);
534 @@ -995,6 +1118,10 @@
536 * Create - we need to know the parent.
539 + it->it_create_mode = mode;
540 + it->it_op |= IT_CREAT;
542 if (path_init(pathname, LOOKUP_PARENT, nd))
543 error = path_walk(pathname, nd);
545 @@ -1011,7 +1138,7 @@
548 down(&dir->d_inode->i_sem);
549 - dentry = lookup_hash(&nd->last, nd->dentry);
550 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
553 error = PTR_ERR(dentry);
554 @@ -1020,10 +1147,11 @@
558 + it->it_create_mode = mode;
559 /* Negative dentry, just create the file */
560 if (!dentry->d_inode) {
561 - error = vfs_create(dir->d_inode, dentry,
562 - mode & ~current->fs->umask);
563 + error = vfs_create_it(dir->d_inode, dentry,
564 + mode & ~current->fs->umask, it);
565 up(&dir->d_inode->i_sem);
568 @@ -1127,7 +1255,7 @@
572 - error = do_truncate(dentry, 0);
573 + error = do_truncate(dentry, 0, 1);
575 put_write_access(inode);
577 @@ -1139,8 +1267,10 @@
581 + intent_release(it);
584 + intent_release(it);
588 @@ -1159,7 +1289,10 @@
589 * are done. Procfs-like symlinks just set LAST_BIND.
591 UPDATE_ATIME(dentry->d_inode);
593 error = dentry->d_inode->i_op->follow_link(dentry, nd);
595 + intent_release(it);
599 @@ -1181,13 +1314,20 @@
602 down(&dir->d_inode->i_sem);
603 - dentry = lookup_hash(&nd->last, nd->dentry);
604 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
605 putname(nd->last.name);
609 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
611 + return open_namei_it(pathname, flag, mode, nd, NULL);
616 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
617 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
618 + struct lookup_intent *it)
620 struct dentry *dentry;
622 @@ -1195,7 +1335,7 @@
623 dentry = ERR_PTR(-EEXIST);
624 if (nd->last_type != LAST_NORM)
626 - dentry = lookup_hash(&nd->last, nd->dentry);
627 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
630 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
631 @@ -1252,7 +1392,20 @@
632 error = path_walk(tmp, &nd);
635 - dentry = lookup_create(&nd, 0);
637 + if (nd.last_type != LAST_NORM) {
641 + if (nd.dentry->d_inode->i_op->mknod_raw) {
642 + struct inode_operations *op = nd.dentry->d_inode->i_op;
643 + error = op->mknod_raw(&nd, mode, dev);
644 + /* the file system wants to use normal vfs path now */
645 + if (error != -EOPNOTSUPP)
649 + dentry = lookup_create(&nd, 0, NULL);
650 error = PTR_ERR(dentry);
652 mode &= ~current->fs->umask;
653 @@ -1273,6 +1422,7 @@
656 up(&nd.dentry->d_inode->i_sem);
661 @@ -1321,7 +1471,18 @@
662 error = path_walk(tmp, &nd);
665 - dentry = lookup_create(&nd, 1);
666 + if (nd.last_type != LAST_NORM) {
670 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
671 + struct inode_operations *op = nd.dentry->d_inode->i_op;
672 + error = op->mkdir_raw(&nd, mode);
673 + /* the file system wants to use normal vfs path now */
674 + if (error != -EOPNOTSUPP)
677 + dentry = lookup_create(&nd, 1, NULL);
678 error = PTR_ERR(dentry);
679 if (!IS_ERR(dentry)) {
680 error = vfs_mkdir(nd.dentry->d_inode, dentry,
681 @@ -1329,6 +1486,7 @@
684 up(&nd.dentry->d_inode->i_sem);
689 @@ -1428,8 +1586,16 @@
693 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
694 + struct inode_operations *op = nd.dentry->d_inode->i_op;
696 + error = op->rmdir_raw(&nd);
697 + /* the file system wants to use normal vfs path now */
698 + if (error != -EOPNOTSUPP)
701 down(&nd.dentry->d_inode->i_sem);
702 - dentry = lookup_hash(&nd.last, nd.dentry);
703 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
704 error = PTR_ERR(dentry);
705 if (!IS_ERR(dentry)) {
706 error = vfs_rmdir(nd.dentry->d_inode, dentry);
707 @@ -1488,8 +1654,15 @@
709 if (nd.last_type != LAST_NORM)
711 + if (nd.dentry->d_inode->i_op->unlink_raw) {
712 + struct inode_operations *op = nd.dentry->d_inode->i_op;
713 + error = op->unlink_raw(&nd);
714 + /* the file system wants to use normal vfs path now */
715 + if (error != -EOPNOTSUPP)
718 down(&nd.dentry->d_inode->i_sem);
719 - dentry = lookup_hash(&nd.last, nd.dentry);
720 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
721 error = PTR_ERR(dentry);
722 if (!IS_ERR(dentry)) {
723 /* Why not before? Because we want correct error value */
724 @@ -1557,15 +1730,27 @@
725 error = path_walk(to, &nd);
728 - dentry = lookup_create(&nd, 0);
729 + if (nd.last_type != LAST_NORM) {
733 + if (nd.dentry->d_inode->i_op->symlink_raw) {
734 + struct inode_operations *op = nd.dentry->d_inode->i_op;
735 + error = op->symlink_raw(&nd, from);
736 + /* the file system wants to use normal vfs path now */
737 + if (error != -EOPNOTSUPP)
740 + dentry = lookup_create(&nd, 0, NULL);
741 error = PTR_ERR(dentry);
742 if (!IS_ERR(dentry)) {
743 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
746 up(&nd.dentry->d_inode->i_sem);
754 @@ -1648,7 +1829,18 @@
756 if (old_nd.mnt != nd.mnt)
758 - new_dentry = lookup_create(&nd, 0);
759 + if (nd.last_type != LAST_NORM) {
763 + if (nd.dentry->d_inode->i_op->link_raw) {
764 + struct inode_operations *op = nd.dentry->d_inode->i_op;
765 + error = op->link_raw(&old_nd, &nd);
766 + /* the file system wants to use normal vfs path now */
767 + if (error != -EOPNOTSUPP)
770 + new_dentry = lookup_create(&nd, 0, NULL);
771 error = PTR_ERR(new_dentry);
772 if (!IS_ERR(new_dentry)) {
773 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
774 @@ -1694,7 +1882,7 @@
777 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
778 - struct inode *new_dir, struct dentry *new_dentry)
779 + struct inode *new_dir, struct dentry *new_dentry)
782 struct inode *target;
783 @@ -1775,7 +1963,7 @@
786 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
787 - struct inode *new_dir, struct dentry *new_dentry)
788 + struct inode *new_dir, struct dentry *new_dentry)
792 @@ -1866,9 +2054,18 @@
793 if (newnd.last_type != LAST_NORM)
796 + if (old_dir->d_inode->i_op->rename_raw) {
798 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
800 + /* the file system wants to use normal vfs path now */
801 + if (error != -EOPNOTSUPP)
805 double_lock(new_dir, old_dir);
807 - old_dentry = lookup_hash(&oldnd.last, old_dir);
808 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
809 error = PTR_ERR(old_dentry);
810 if (IS_ERR(old_dentry))
812 @@ -1884,16 +2081,16 @@
813 if (newnd.last.name[newnd.last.len])
816 - new_dentry = lookup_hash(&newnd.last, new_dir);
817 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
818 error = PTR_ERR(new_dentry);
819 if (IS_ERR(new_dentry))
824 error = vfs_rename(old_dir->d_inode, old_dentry,
825 new_dir->d_inode, new_dentry);
831 @@ -1944,20 +2141,26 @@
835 -__vfs_follow_link(struct nameidata *nd, const char *link)
836 +__vfs_follow_link(struct nameidata *nd, const char *link,
837 + struct lookup_intent *it)
846 + else if (it != nd->intent)
847 + printk("it != nd->intent: tell phil@clusterfs.com\n");
851 if (!walk_init_root(link, nd))
852 /* weird __emul_prefix() stuff did it */
855 - res = link_path_walk(link, nd);
856 + res = link_path_walk_it(link, nd, it);
858 if (current->link_count || res || nd->last_type!=LAST_NORM)
860 @@ -1979,7 +2182,13 @@
862 int vfs_follow_link(struct nameidata *nd, const char *link)
864 - return __vfs_follow_link(nd, link);
865 + return __vfs_follow_link(nd, link, NULL);
868 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
869 + struct lookup_intent *it)
871 + return __vfs_follow_link(nd, link, it);
874 /* get the link contents into pagecache */
875 @@ -2021,7 +2230,7 @@
877 struct page *page = NULL;
878 char *s = page_getlink(dentry, &page);
879 - int res = __vfs_follow_link(nd, s);
880 + int res = __vfs_follow_link(nd, s, NULL);
883 page_cache_release(page);
884 Index: linux-2.4.19-pre1/fs/namespace.c
885 ===================================================================
886 --- linux-2.4.19-pre1.orig/fs/namespace.c 2003-11-21 02:41:00.000000000 +0300
887 +++ linux-2.4.19-pre1/fs/namespace.c 2003-11-21 02:51:38.000000000 +0300
890 old_nd->dentry = mnt->mnt_mountpoint;
891 old_nd->mnt = mnt->mnt_parent;
892 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
893 mnt->mnt_parent = mnt;
894 mnt->mnt_mountpoint = mnt->mnt_root;
895 list_del_init(&mnt->mnt_child);
898 mnt->mnt_parent = mntget(nd->mnt);
899 mnt->mnt_mountpoint = dget(nd->dentry);
900 + PIN(nd->dentry, nd->mnt, 1);
901 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
902 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
903 nd->dentry->d_mounted++;
904 @@ -500,15 +502,18 @@
906 struct nameidata old_nd;
907 struct vfsmount *mnt = NULL;
908 + struct lookup_intent it = { .it_op = IT_GETATTR };
909 int err = mount_is_safe(nd);
912 if (!old_name || !*old_name)
914 if (path_init(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd))
915 - err = path_walk(old_name, &old_nd);
917 + err = path_walk_it(old_name, &old_nd, &it);
919 + intent_release(&it);
929 + intent_release(&it);
930 path_release(&old_nd);
934 unsigned long flags, void *data_page)
937 + struct lookup_intent it = { .it_op = IT_GETATTR };
943 /* ... and get the mountpoint */
944 if (path_init(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd))
945 - retval = path_walk(dir_name, &nd);
947 + retval = path_walk_it(dir_name, &nd, &it);
949 + intent_release(&it);
953 if (flags & MS_REMOUNT)
954 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
957 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
958 dev_name, data_page);
960 + intent_release(&it);
966 struct vfsmount *tmp;
967 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
968 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
969 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
976 if (path_init(name, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd))
977 - error = path_walk(name, &new_nd);
978 + error = path_walk_it(name, &new_nd, &new_it);
985 if (path_init(name, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd))
986 - error = path_walk(name, &old_nd);
987 + error = path_walk_it(name, &old_nd, &old_it);
992 up(&old_nd.dentry->d_inode->i_zombie);
994 path_release(&user_nd);
995 + intent_release(&old_it);
996 path_release(&old_nd);
998 + intent_release(&new_it);
999 path_release(&new_nd);
1002 Index: linux-2.4.19-pre1/fs/open.c
1003 ===================================================================
1004 --- linux-2.4.19-pre1.orig/fs/open.c 2003-11-21 02:41:00.000000000 +0300
1005 +++ linux-2.4.19-pre1/fs/open.c 2003-11-21 02:51:38.000000000 +0300
1007 #include <asm/uaccess.h>
1009 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1010 +extern int path_walk_it(const char *name, struct nameidata *nd,
1011 + struct lookup_intent *it);
1013 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1019 -int do_truncate(struct dentry *dentry, loff_t length)
1020 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1022 struct inode *inode = dentry->d_inode;
1023 + struct inode_operations *op = dentry->d_inode->i_op;
1025 struct iattr newattrs;
1028 down(&inode->i_sem);
1029 newattrs.ia_size = length;
1030 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1031 - error = notify_change(dentry, &newattrs);
1032 + if (called_from_open)
1033 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1034 + if (op->setattr_raw) {
1035 + newattrs.ia_valid |= ATTR_RAW;
1036 + error = op->setattr_raw(inode, &newattrs);
1038 + error = notify_change(dentry, &newattrs);
1042 @@ -94,12 +103,13 @@
1043 struct nameidata nd;
1044 struct inode * inode;
1046 + struct lookup_intent it = { .it_op = IT_GETATTR };
1049 if (length < 0) /* sorry, but loff_t says... */
1052 - error = user_path_walk(path, &nd);
1053 + error = user_path_walk_it(path, &nd, &it);
1056 inode = nd.dentry->d_inode;
1057 @@ -139,11 +149,13 @@
1058 error = locks_verify_truncate(inode, NULL, length);
1061 - error = do_truncate(nd.dentry, length);
1062 + intent_release(&it);
1063 + error = do_truncate(nd.dentry, length, 0);
1065 put_write_access(inode);
1068 + intent_release(&it);
1074 error = locks_verify_truncate(inode, file, length);
1076 - error = do_truncate(dentry, length);
1077 + error = do_truncate(dentry, length, 0);
1081 @@ -236,11 +248,13 @@
1082 struct inode * inode;
1083 struct iattr newattrs;
1085 - error = user_path_walk(filename, &nd);
1086 + error = user_path_walk_it(filename, &nd, NULL);
1089 inode = nd.dentry->d_inode;
1091 + /* this is safe without a Lustre lock because it only depends
1092 + on the super block */
1094 if (IS_RDONLY(inode))
1096 @@ -255,11 +269,25 @@
1099 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1103 + if (inode->i_op->setattr_raw) {
1104 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1106 + newattrs.ia_valid |= ATTR_RAW;
1107 + error = op->setattr_raw(inode, &newattrs);
1108 + /* the file system wants to use normal vfs path now */
1109 + if (error != -EOPNOTSUPP)
1110 + goto dput_and_out;
1115 if (current->fsuid != inode->i_uid &&
1116 (error = permission(inode,MAY_WRITE)) != 0)
1120 error = notify_change(nd.dentry, &newattrs);
1123 @@ -280,12 +308,14 @@
1124 struct inode * inode;
1125 struct iattr newattrs;
1127 - error = user_path_walk(filename, &nd);
1128 + error = user_path_walk_it(filename, &nd, NULL);
1132 inode = nd.dentry->d_inode;
1134 + /* this is safe without a Lustre lock because it only depends
1135 + on the super block */
1137 if (IS_RDONLY(inode))
1139 @@ -300,7 +330,20 @@
1140 newattrs.ia_atime = times[0].tv_sec;
1141 newattrs.ia_mtime = times[1].tv_sec;
1142 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1146 + if (inode->i_op->setattr_raw) {
1147 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1149 + newattrs.ia_valid |= ATTR_RAW;
1150 + error = op->setattr_raw(inode, &newattrs);
1151 + /* the file system wants to use normal vfs path now */
1152 + if (error != -EOPNOTSUPP)
1153 + goto dput_and_out;
1158 if ((error = permission(inode,MAY_WRITE)) != 0)
1162 int old_fsuid, old_fsgid;
1163 kernel_cap_t old_cap;
1165 + struct lookup_intent it = { .it_op = IT_GETATTR };
1167 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1169 @@ -339,13 +383,14 @@
1171 current->cap_effective = current->cap_permitted;
1173 - res = user_path_walk(filename, &nd);
1174 + res = user_path_walk_it(filename, &nd, &it);
1176 res = permission(nd.dentry->d_inode, mode);
1177 /* SuS v2 requires we report a read only fs too */
1178 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1179 && !special_file(nd.dentry->d_inode->i_mode))
1181 + intent_release(&it);
1187 struct nameidata nd;
1189 + struct lookup_intent it = { .it_op = IT_GETATTR };
1191 name = getname(filename);
1192 error = PTR_ERR(name);
1196 if (path_init(name,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd))
1197 - error = path_walk(name, &nd);
1198 + error = path_walk_it(name, &nd, &it);
1203 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1206 + intent_release(&it);
1212 struct nameidata nd;
1214 + struct lookup_intent it = { .it_op = IT_GETATTR };
1216 name = getname(filename);
1217 error = PTR_ERR(name);
1220 path_init(name, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1221 LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1222 - error = path_walk(name, &nd);
1223 + error = path_walk_it(name, &nd, &it);
1227 @@ -446,39 +494,56 @@
1231 + intent_release(&it);
1237 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1238 +int chmod_common(struct dentry *dentry, mode_t mode)
1240 - struct inode * inode;
1241 - struct dentry * dentry;
1242 - struct file * file;
1244 + struct inode *inode = dentry->d_inode;
1245 struct iattr newattrs;
1250 + if (IS_RDONLY(inode))
1253 - dentry = file->f_dentry;
1254 - inode = dentry->d_inode;
1255 + if (inode->i_op->setattr_raw) {
1256 + newattrs.ia_mode = mode;
1257 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1258 + newattrs.ia_valid |= ATTR_RAW;
1259 + err = inode->i_op->setattr_raw(inode, &newattrs);
1260 + /* the file system wants to use normal vfs path now */
1261 + if (err != -EOPNOTSUPP)
1266 - if (IS_RDONLY(inode))
1269 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1273 if (mode == (mode_t) -1)
1274 mode = inode->i_mode;
1275 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1276 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1277 err = notify_change(dentry, &newattrs);
1284 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1286 + struct file * file;
1293 + err = chmod_common(file->f_dentry, mode);
1298 @@ -487,30 +552,14 @@
1299 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1301 struct nameidata nd;
1302 - struct inode * inode;
1304 - struct iattr newattrs;
1306 error = user_path_walk(filename, &nd);
1309 - inode = nd.dentry->d_inode;
1312 - if (IS_RDONLY(inode))
1313 - goto dput_and_out;
1316 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1317 - goto dput_and_out;
1318 + error = chmod_common(nd.dentry, mode);
1320 - if (mode == (mode_t) -1)
1321 - mode = inode->i_mode;
1322 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1323 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1324 - error = notify_change(nd.dentry, &newattrs);
1330 @@ -530,6 +579,20 @@
1332 if (IS_RDONLY(inode))
1335 + if (inode->i_op->setattr_raw) {
1336 + struct inode_operations *op = dentry->d_inode->i_op;
1338 + newattrs.ia_uid = user;
1339 + newattrs.ia_gid = group;
1340 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1341 + newattrs.ia_valid |= ATTR_RAW;
1342 + error = op->setattr_raw(inode, &newattrs);
1343 + /* the file system wants to use normal vfs path now */
1344 + if (error != -EOPNOTSUPP)
1349 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1353 int namei_flags, error;
1354 struct nameidata nd;
1355 + struct lookup_intent it = { .it_op = IT_OPEN };
1357 namei_flags = flags;
1358 if ((namei_flags+1) & O_ACCMODE)
1359 @@ -641,14 +705,15 @@
1360 if (namei_flags & O_TRUNC)
1363 - error = open_namei(filename, namei_flags, mode, &nd);
1365 - return dentry_open(nd.dentry, nd.mnt, flags);
1366 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1368 + return ERR_PTR(error);
1370 - return ERR_PTR(error);
1371 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1374 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1375 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1376 + int flags, struct lookup_intent *it)
1379 struct inode *inode;
1380 @@ -685,12 +750,15 @@
1383 if (f->f_op && f->f_op->open) {
1385 error = f->f_op->open(inode,f);
1390 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1392 + intent_release(it);
1396 @@ -705,11 +773,17 @@
1400 + intent_release(it);
1403 return ERR_PTR(error);
1406 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1408 + return dentry_open_it(dentry, mnt, flags, NULL);
1412 * Find an empty file descriptor entry, and mark it busy.
1414 Index: linux-2.4.19-pre1/fs/stat.c
1415 ===================================================================
1416 --- linux-2.4.19-pre1.orig/fs/stat.c 2003-11-21 02:41:00.000000000 +0300
1417 +++ linux-2.4.19-pre1/fs/stat.c 2003-11-21 02:51:38.000000000 +0300
1419 * Revalidate the inode. This is required for proper NFS attribute caching.
1421 static __inline__ int
1422 -do_revalidate(struct dentry *dentry)
1423 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1425 struct inode * inode = dentry->d_inode;
1426 - if (inode->i_op && inode->i_op->revalidate)
1427 + if (inode->i_op && inode->i_op->revalidate_it)
1428 + return inode->i_op->revalidate_it(dentry, it);
1429 + else if (inode->i_op && inode->i_op->revalidate)
1430 return inode->i_op->revalidate(dentry);
1433 @@ -135,13 +139,15 @@
1434 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1436 struct nameidata nd;
1437 + struct lookup_intent it = { .it_op = IT_GETATTR };
1440 - error = user_path_walk(filename, &nd);
1441 + error = user_path_walk_it(filename, &nd, &it);
1443 - error = do_revalidate(nd.dentry);
1444 + error = do_revalidate(nd.dentry, &it);
1446 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1447 + intent_release(&it);
1451 @@ -151,13 +157,15 @@
1452 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1454 struct nameidata nd;
1455 + struct lookup_intent it = { .it_op = IT_GETATTR };
1458 - error = user_path_walk(filename, &nd);
1459 + error = user_path_walk_it(filename, &nd, &it);
1461 - error = do_revalidate(nd.dentry);
1462 + error = do_revalidate(nd.dentry, &it);
1464 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1465 + intent_release(&it);
1469 @@ -172,13 +180,15 @@
1470 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1472 struct nameidata nd;
1473 + struct lookup_intent it = { .it_op = IT_GETATTR };
1476 - error = user_path_walk_link(filename, &nd);
1477 + error = user_path_walk_link_it(filename, &nd, &it);
1479 - error = do_revalidate(nd.dentry);
1480 + error = do_revalidate(nd.dentry, &it);
1482 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1483 + intent_release(&it);
1487 @@ -189,13 +199,15 @@
1488 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1490 struct nameidata nd;
1491 + struct lookup_intent it = { .it_op = IT_GETATTR };
1494 - error = user_path_walk_link(filename, &nd);
1495 + error = user_path_walk_link_it(filename, &nd, &it);
1497 - error = do_revalidate(nd.dentry);
1498 + error = do_revalidate(nd.dentry, &it);
1500 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1501 + intent_release(&it);
1507 struct dentry * dentry = f->f_dentry;
1509 - err = do_revalidate(dentry);
1510 + err = do_revalidate(dentry, NULL);
1512 err = cp_old_stat(dentry->d_inode, statbuf);
1516 struct dentry * dentry = f->f_dentry;
1518 - err = do_revalidate(dentry);
1519 + err = do_revalidate(dentry, NULL);
1521 err = cp_new_stat(dentry->d_inode, statbuf);
1526 if (inode->i_op && inode->i_op->readlink &&
1527 - !(error = do_revalidate(nd.dentry))) {
1528 + !(error = do_revalidate(nd.dentry, NULL))) {
1529 UPDATE_ATIME(inode);
1530 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1532 @@ -333,12 +345,14 @@
1534 struct nameidata nd;
1536 + struct lookup_intent it = { .it_op = IT_GETATTR };
1538 - error = user_path_walk(filename, &nd);
1539 + error = user_path_walk_it(filename, &nd, &it);
1541 - error = do_revalidate(nd.dentry);
1542 + error = do_revalidate(nd.dentry, &it);
1544 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1545 + intent_release(&it);
1549 @@ -348,12 +362,14 @@
1551 struct nameidata nd;
1553 + struct lookup_intent it = { .it_op = IT_GETATTR };
1555 - error = user_path_walk_link(filename, &nd);
1556 + error = user_path_walk_link_it(filename, &nd, &it);
1558 - error = do_revalidate(nd.dentry);
1559 + error = do_revalidate(nd.dentry, &it);
1561 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1562 + intent_release(&it);
1568 struct dentry * dentry = f->f_dentry;
1570 - err = do_revalidate(dentry);
1571 + err = do_revalidate(dentry, NULL);
1573 err = cp_new_stat64(dentry->d_inode, statbuf);
1575 Index: linux-2.4.19-pre1/include/linux/dcache.h
1576 ===================================================================
1577 --- linux-2.4.19-pre1.orig/include/linux/dcache.h 2003-11-21 02:41:00.000000000 +0300
1578 +++ linux-2.4.19-pre1/include/linux/dcache.h 2003-11-21 02:51:38.000000000 +0300
1581 #include <asm/atomic.h>
1582 #include <linux/mount.h>
1583 +#include <linux/string.h>
1585 +#define IT_OPEN 0x0001
1586 +#define IT_CREAT 0x0002
1587 +#define IT_READDIR 0x0004
1588 +#define IT_GETATTR 0x0008
1589 +#define IT_LOOKUP 0x0010
1590 +#define IT_UNLINK 0x0020
1591 +#define IT_GETXATTR 0x0040
1592 +#define IT_EXEC 0x0080
1593 +#define IT_PIN 0x0100
1595 +#define IT_FL_LOCKED 0x0001
1596 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1598 +#define INTENT_MAGIC 0x19620323
1601 +struct lustre_intent_data {
1602 + int it_disposition;
1604 + __u64 it_lock_handle;
1609 +struct lookup_intent {
1611 + void (*it_op_release)(struct lookup_intent *);
1614 + int it_create_mode;
1616 + struct lustre_intent_data lustre;
1620 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1622 + memset(it, 0, sizeof(*it));
1623 + it->it_magic = INTENT_MAGIC;
1625 + it->it_flags = flags;
1630 * linux/include/linux/dcache.h
1632 int (*d_delete)(struct dentry *);
1633 void (*d_release)(struct dentry *);
1634 void (*d_iput)(struct dentry *, struct inode *);
1635 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1636 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1637 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1640 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1641 + de->d_op->d_pin(de, mnt, flag);
1642 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1643 + de->d_op->d_unpin(de, mnt, flag);
1646 +/* defined in fs/namei.c */
1647 +extern void intent_release(struct lookup_intent *it);
1648 +/* defined in fs/dcache.c */
1649 +extern void __d_rehash(struct dentry * entry, int lock);
1651 /* the dentry parameter passed to d_hash and d_compare is the parent
1652 * directory of the entries to be compared. It is used in case these
1653 * functions need any directory specific information for determining
1655 * s_nfsd_free_path semaphore will be down
1657 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1658 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1660 extern spinlock_t dcache_lock;
1662 Index: linux-2.4.19-pre1/include/linux/fs.h
1663 ===================================================================
1664 --- linux-2.4.19-pre1.orig/include/linux/fs.h 2003-11-21 02:51:37.000000000 +0300
1665 +++ linux-2.4.19-pre1/include/linux/fs.h 2003-11-21 02:51:38.000000000 +0300
1668 #define FMODE_READ 1
1669 #define FMODE_WRITE 2
1670 +#define FMODE_EXEC 4
1675 #define ATTR_MTIME_SET 256
1676 #define ATTR_FORCE 512 /* Not a change, but a change it */
1677 #define ATTR_ATTR_FLAG 1024
1678 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1679 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1680 +#define ATTR_CTIME_SET 0x2000
1683 * This is the Inode Attributes structure, used for notify_change(). It
1685 struct pipe_inode_info *i_pipe;
1686 struct block_device *i_bdev;
1687 struct char_device *i_cdev;
1688 + void *i_filterdata;
1690 unsigned long i_dnotify_mask; /* Directory notify events */
1691 struct dnotify_struct *i_dnotify; /* for directory notifications */
1694 /* needed for tty driver, and maybe others */
1696 + struct lookup_intent *f_it;
1698 /* preallocated helper kiobuf to speedup O_DIRECT */
1699 struct kiobuf *f_iobuf;
1704 + struct lookup_intent *intent;
1707 #define DQUOT_USR_ENABLED 0x01 /* User diskquotas enabled */
1709 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1710 extern int vfs_rmdir(struct inode *, struct dentry *);
1711 extern int vfs_unlink(struct inode *, struct dentry *);
1712 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1713 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1714 + struct inode *new_dir, struct dentry *new_dentry);
1718 @@ -837,21 +845,32 @@
1720 struct inode_operations {
1721 int (*create) (struct inode *,struct dentry *,int);
1722 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1723 struct dentry * (*lookup) (struct inode *,struct dentry *);
1724 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1725 int (*link) (struct dentry *,struct inode *,struct dentry *);
1726 + int (*link_raw) (struct nameidata *,struct nameidata *);
1727 int (*unlink) (struct inode *,struct dentry *);
1728 + int (*unlink_raw) (struct nameidata *);
1729 int (*symlink) (struct inode *,struct dentry *,const char *);
1730 + int (*symlink_raw) (struct nameidata *,const char *);
1731 int (*mkdir) (struct inode *,struct dentry *,int);
1732 + int (*mkdir_raw) (struct nameidata *,int);
1733 int (*rmdir) (struct inode *,struct dentry *);
1734 + int (*rmdir_raw) (struct nameidata *);
1735 int (*mknod) (struct inode *,struct dentry *,int,int);
1736 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1737 int (*rename) (struct inode *, struct dentry *,
1738 struct inode *, struct dentry *);
1739 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1740 int (*readlink) (struct dentry *, char *,int);
1741 int (*follow_link) (struct dentry *, struct nameidata *);
1742 void (*truncate) (struct inode *);
1743 int (*permission) (struct inode *, int);
1744 int (*revalidate) (struct dentry *);
1745 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1746 int (*setattr) (struct dentry *, struct iattr *);
1747 + int (*setattr_raw) (struct inode *, struct iattr *);
1748 int (*getattr) (struct dentry *, struct iattr *);
1751 @@ -1049,10 +1068,14 @@
1753 asmlinkage long sys_open(const char *, int, int);
1754 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1755 -extern int do_truncate(struct dentry *, loff_t start);
1756 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1758 extern struct file *filp_open(const char *, int, int);
1759 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1760 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1761 + struct nameidata *nd, struct lookup_intent *it);
1762 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1763 + int flags, struct lookup_intent *it);
1764 extern int filp_close(struct file *, fl_owner_t id);
1765 extern char * getname(const char *);
1767 @@ -1306,6 +1329,7 @@
1768 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1770 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1771 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1772 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1773 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1774 extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
1775 @@ -1316,6 +1340,8 @@
1776 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1777 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1778 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1779 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1780 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1782 extern void iput(struct inode *);
1783 extern void force_delete(struct inode *);
1784 @@ -1423,6 +1449,8 @@
1786 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1787 extern int vfs_follow_link(struct nameidata *, const char *);
1788 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1789 + struct lookup_intent *it);
1790 extern int page_readlink(struct dentry *, char *, int);
1791 extern int page_follow_link(struct dentry *, struct nameidata *);
1792 extern struct inode_operations page_symlink_inode_operations;
1793 Index: linux-2.4.19-pre1/include/linux/fs_struct.h
1794 ===================================================================
1795 --- linux-2.4.19-pre1.orig/include/linux/fs_struct.h 2003-11-21 02:41:00.000000000 +0300
1796 +++ linux-2.4.19-pre1/include/linux/fs_struct.h 2003-11-21 02:51:38.000000000 +0300
1798 write_lock(&fs->lock);
1799 old_root = fs->root;
1800 old_rootmnt = fs->rootmnt;
1801 + PIN(dentry, mnt, 1);
1802 fs->rootmnt = mntget(mnt);
1803 fs->root = dget(dentry);
1804 write_unlock(&fs->lock);
1806 + UNPIN(old_root, old_rootmnt, 1);
1808 mntput(old_rootmnt);
1811 write_lock(&fs->lock);
1813 old_pwdmnt = fs->pwdmnt;
1814 + PIN(dentry, mnt, 0);
1815 fs->pwdmnt = mntget(mnt);
1816 fs->pwd = dget(dentry);
1817 write_unlock(&fs->lock);
1819 + UNPIN(old_pwd, old_pwdmnt, 0);
1823 Index: linux-2.4.19-pre1/kernel/exit.c
1824 ===================================================================
1825 --- linux-2.4.19-pre1.orig/kernel/exit.c 2003-11-21 02:41:00.000000000 +0300
1826 +++ linux-2.4.19-pre1/kernel/exit.c 2003-11-21 02:51:38.000000000 +0300
1827 @@ -245,11 +245,14 @@
1829 /* No need to hold fs->lock if we are killing it */
1830 if (atomic_dec_and_test(&fs->count)) {
1831 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1832 + UNPIN(fs->root, fs->rootmnt, 1);
1834 mntput(fs->rootmnt);
1838 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1840 mntput(fs->altrootmnt);
1842 Index: linux-2.4.19-pre1/kernel/fork.c
1843 ===================================================================
1844 --- linux-2.4.19-pre1.orig/kernel/fork.c 2003-11-21 02:41:00.000000000 +0300
1845 +++ linux-2.4.19-pre1/kernel/fork.c 2003-11-21 02:51:38.000000000 +0300
1846 @@ -372,10 +372,13 @@
1847 fs->umask = old->umask;
1848 read_lock(&old->lock);
1849 fs->rootmnt = mntget(old->rootmnt);
1850 + PIN(old->pwd, old->pwdmnt, 0);
1851 + PIN(old->root, old->rootmnt, 1);
1852 fs->root = dget(old->root);
1853 fs->pwdmnt = mntget(old->pwdmnt);
1854 fs->pwd = dget(old->pwd);
1856 + PIN(old->altroot, old->altrootmnt, 1);
1857 fs->altrootmnt = mntget(old->altrootmnt);
1858 fs->altroot = dget(old->altroot);
1860 Index: linux-2.4.19-pre1/kernel/ksyms.c
1861 ===================================================================
1862 --- linux-2.4.19-pre1.orig/kernel/ksyms.c 2003-11-21 02:51:37.000000000 +0300
1863 +++ linux-2.4.19-pre1/kernel/ksyms.c 2003-11-21 02:51:38.000000000 +0300
1865 EXPORT_SYMBOL(set_page_dirty);
1866 EXPORT_SYMBOL(vfs_readlink);
1867 EXPORT_SYMBOL(vfs_follow_link);
1868 +EXPORT_SYMBOL(vfs_follow_link_it);
1869 EXPORT_SYMBOL(page_readlink);
1870 EXPORT_SYMBOL(page_follow_link);
1871 EXPORT_SYMBOL(page_symlink_inode_operations);