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/exec.c
16 ===================================================================
17 --- linux-2.4.19-pre1.orig/fs/exec.c 2003-11-21 02:41:00.000000000 +0300
18 +++ linux-2.4.19-pre1/fs/exec.c 2003-11-21 02:51:38.000000000 +0300
23 + struct lookup_intent it = { .it_op = IT_OPEN,
24 + .it_flags = FMODE_READ|FMODE_EXEC };
26 - error = user_path_walk(library, &nd);
27 + error = user_path_walk_it(library, &nd, &it);
35 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
36 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
37 + intent_release(&it);
38 error = PTR_ERR(file);
45 + struct lookup_intent it = { .it_op = IT_OPEN,
46 + .it_flags = FMODE_READ|FMODE_EXEC };
48 if (path_init(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd))
49 - err = path_walk(name, &nd);
50 + err = path_walk_it(name, &nd, &it);
53 inode = nd.dentry->d_inode;
58 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
59 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
60 + intent_release(&it);
62 err = deny_write_access(file);
68 + intent_release(&it);
74 if (!file->f_op->write)
76 - if (do_truncate(file->f_dentry, 0) != 0)
77 + if (do_truncate(file->f_dentry, 0, 0) != 0)
80 retval = binfmt->core_dump(signr, regs, file);
81 Index: linux-2.4.19-pre1/fs/dcache.c
82 ===================================================================
83 --- linux-2.4.19-pre1.orig/fs/dcache.c 2003-11-21 02:41:00.000000000 +0300
84 +++ linux-2.4.19-pre1/fs/dcache.c 2003-11-21 02:51:38.000000000 +0300
86 spin_unlock(&dcache_lock);
90 + /* network invalidation by Lustre */
91 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
92 + spin_unlock(&dcache_lock);
97 * Check whether to do a partial shrink_dcache
98 * to get rid of unused child entries.
100 * Adds a dentry to the hash according to its name.
103 -void d_rehash(struct dentry * entry)
104 +void __d_rehash(struct dentry * entry, int lock)
106 struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
107 if (!list_empty(&entry->d_hash)) BUG();
108 - spin_lock(&dcache_lock);
109 + if (lock) spin_lock(&dcache_lock);
110 list_add(&entry->d_hash, list);
111 - spin_unlock(&dcache_lock);
112 + if (lock) spin_unlock(&dcache_lock);
114 +EXPORT_SYMBOL(__d_rehash);
116 +void d_rehash(struct dentry * entry)
118 + __d_rehash(entry, 1);
121 #define do_switch(x,y) do { \
122 Index: linux-2.4.19-pre1/fs/namespace.c
123 ===================================================================
124 --- linux-2.4.19-pre1.orig/fs/namespace.c 2003-11-21 02:41:00.000000000 +0300
125 +++ linux-2.4.19-pre1/fs/namespace.c 2003-11-21 02:51:38.000000000 +0300
128 old_nd->dentry = mnt->mnt_mountpoint;
129 old_nd->mnt = mnt->mnt_parent;
130 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
131 mnt->mnt_parent = mnt;
132 mnt->mnt_mountpoint = mnt->mnt_root;
133 list_del_init(&mnt->mnt_child);
136 mnt->mnt_parent = mntget(nd->mnt);
137 mnt->mnt_mountpoint = dget(nd->dentry);
138 + PIN(nd->dentry, nd->mnt, 1);
139 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
140 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
141 nd->dentry->d_mounted++;
142 @@ -500,15 +502,18 @@
144 struct nameidata old_nd;
145 struct vfsmount *mnt = NULL;
146 + struct lookup_intent it = { .it_op = IT_GETATTR };
147 int err = mount_is_safe(nd);
150 if (!old_name || !*old_name)
152 if (path_init(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd))
153 - err = path_walk(old_name, &old_nd);
155 + err = path_walk_it(old_name, &old_nd, &it);
157 + intent_release(&it);
167 + intent_release(&it);
168 path_release(&old_nd);
172 unsigned long flags, void *data_page)
175 + struct lookup_intent it = { .it_op = IT_GETATTR };
181 /* ... and get the mountpoint */
182 if (path_init(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd))
183 - retval = path_walk(dir_name, &nd);
185 + retval = path_walk_it(dir_name, &nd, &it);
187 + intent_release(&it);
191 if (flags & MS_REMOUNT)
192 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
195 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
196 dev_name, data_page);
198 + intent_release(&it);
204 struct vfsmount *tmp;
205 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
206 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
207 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
214 if (path_init(name, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd))
215 - error = path_walk(name, &new_nd);
216 + error = path_walk_it(name, &new_nd, &new_it);
223 if (path_init(name, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd))
224 - error = path_walk(name, &old_nd);
225 + error = path_walk_it(name, &old_nd, &old_it);
230 up(&old_nd.dentry->d_inode->i_zombie);
232 path_release(&user_nd);
233 + intent_release(&old_it);
234 path_release(&old_nd);
236 + intent_release(&new_it);
237 path_release(&new_nd);
240 Index: linux-2.4.19-pre1/fs/namei.c
241 ===================================================================
242 --- linux-2.4.19-pre1.orig/fs/namei.c 2003-11-21 02:41:00.000000000 +0300
243 +++ linux-2.4.19-pre1/fs/namei.c 2003-11-21 02:52:01.000000000 +0300
245 * XEmacs seems to be relying on it...
248 +void intent_release(struct lookup_intent *it)
250 + if (it && it->it_op_release)
251 + it->it_op_release(it);
255 /* In order to reduce some races, while at the same time doing additional
256 * checking and hopefully speeding things up, we copy filenames to the
257 * kernel data space before using them..
258 @@ -260,10 +267,19 @@
259 * Internal lookup() using the new generic dcache.
262 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
263 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
264 + int flags, struct lookup_intent *it)
266 struct dentry * dentry = d_lookup(parent, name);
268 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
269 + if (!dentry->d_op->d_revalidate_it(dentry, flags, it) &&
270 + !d_invalidate(dentry)) {
276 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
277 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
279 @@ -281,11 +297,15 @@
280 * make sure that nobody added the entry to the dcache in the meantime..
283 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
284 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
285 + int flags, struct lookup_intent *it)
287 struct dentry * result;
288 struct inode *dir = parent->d_inode;
295 * First re-do the cached lookup just in case it was created
297 result = ERR_PTR(-ENOMEM);
300 + if (dir->i_op->lookup_it)
301 + result = dir->i_op->lookup_it(dir, dentry, it, flags);
303 result = dir->i_op->lookup(dir, dentry);
308 result = ERR_PTR(-ENOENT);
310 + } else if (result->d_op && result->d_op->d_revalidate_it) {
311 + if (!result->d_op->d_revalidate_it(result, flags, it) &&
312 + !d_invalidate(result)) {
315 + result = ERR_PTR(-ESTALE);
316 + if (!IS_ERR(result))
323 * Without that kind of total limit, nasty chains of consecutive
324 * symlinks can cause almost arbitrarily long lookups.
326 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
327 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
328 + struct lookup_intent *it)
331 if (current->link_count >= 5)
332 @@ -346,10 +379,12 @@
333 current->link_count++;
334 current->total_link_count++;
335 UPDATE_ATIME(dentry->d_inode);
337 err = dentry->d_inode->i_op->follow_link(dentry, nd);
338 current->link_count--;
341 + intent_release(it);
347 * We expect 'base' to be positive and a directory.
349 -int link_path_walk(const char * name, struct nameidata *nd)
350 +int link_path_walk_it(const char *name, struct nameidata *nd,
351 + struct lookup_intent *it)
353 struct dentry *dentry;
362 inode = nd->dentry->d_inode;
363 if (current->link_count)
367 /* This does the actual lookups.. */
368 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
369 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
371 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
372 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE,
374 err = PTR_ERR(dentry);
380 if (inode->i_op->follow_link) {
381 - err = do_follow_link(dentry, nd);
382 + err = do_follow_link(dentry, nd, NULL);
390 - if (!inode->i_op->lookup)
391 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
394 /* here ends the main loop */
395 @@ -574,16 +611,16 @@
396 inode = nd->dentry->d_inode;
402 if (nd->dentry->d_op && nd->dentry->d_op->d_hash) {
403 err = nd->dentry->d_op->d_hash(nd->dentry, &this);
407 - dentry = cached_lookup(nd->dentry, &this, 0);
408 + dentry = cached_lookup(nd->dentry, &this, 0, it);
410 - dentry = real_lookup(nd->dentry, &this, 0);
411 + dentry = real_lookup(nd->dentry, &this, 0, it);
412 err = PTR_ERR(dentry);
416 inode = dentry->d_inode;
417 if ((lookup_flags & LOOKUP_FOLLOW)
418 && inode && inode->i_op && inode->i_op->follow_link) {
419 - err = do_follow_link(dentry, nd);
420 + err = do_follow_link(dentry, nd, it);
426 if (lookup_flags & LOOKUP_DIRECTORY) {
428 - if (!inode->i_op || !inode->i_op->lookup)
429 + if (!inode->i_op ||
430 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
434 @@ -625,21 +663,66 @@
435 nd->last_type = LAST_DOT;
436 else if (this.len == 2 && this.name[1] == '.')
437 nd->last_type = LAST_DOTDOT;
440 + * We bypassed the ordinary revalidation routines.
441 + * Check the cached dentry for staleness.
443 + dentry = nd->dentry;
444 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
446 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
447 + struct dentry *new;
448 + err = permission(dentry->d_parent->d_inode,
452 + new = real_lookup(dentry->d_parent,
453 + &dentry->d_name, 0, NULL);
454 + d_invalidate(dentry);
457 + err = PTR_ERR(new);
463 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
465 + if (!dentry->d_op->d_revalidate(dentry, 0)) {
466 + d_invalidate(dentry);
477 + intent_release(it);
483 +int link_path_walk(const char * name, struct nameidata *nd)
485 + return link_path_walk_it(name, nd, NULL);
488 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
490 + current->total_link_count = 0;
491 + return link_path_walk_it(name, nd, it);
494 int path_walk(const char * name, struct nameidata *nd)
496 current->total_link_count = 0;
497 - return link_path_walk(name, nd);
498 + return link_path_walk_it(name, nd, NULL);
504 nd->last_type = LAST_ROOT; /* if there are only slashes... */
508 return walk_init_root(name,nd);
509 read_lock(¤t->fs->lock);
511 * needs parent already locked. Doesn't follow mounts.
514 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
515 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
516 + struct lookup_intent *it)
518 struct dentry * dentry;
520 @@ -765,13 +850,16 @@
524 - dentry = cached_lookup(base, name, 0);
525 + dentry = cached_lookup(base, name, 0, it);
527 struct dentry *new = d_alloc(base, name);
528 dentry = ERR_PTR(-ENOMEM);
532 + if (inode->i_op->lookup_it)
533 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
535 dentry = inode->i_op->lookup(inode, new);
542 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
544 + return lookup_hash_it(name, base, NULL);
549 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
553 this.hash = end_name_hash(hash);
555 - return lookup_hash(&this, base);
556 + return lookup_hash_it(&this, base, NULL);
558 return ERR_PTR(-EACCES);
564 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
565 + struct lookup_intent *it)
570 + tmp = getname(name);
571 + err = PTR_ERR(tmp);
572 + if (!IS_ERR(tmp)) {
574 + if (path_init(tmp, flags, nd))
575 + err = path_walk_it(tmp, nd, it);
582 * It's inline, so penalty for filesystems that don't use sticky bit is
588 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
589 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
590 + struct lookup_intent *it)
594 @@ -942,12 +1054,15 @@
597 error = -EACCES; /* shouldn't it be ENOSYS? */
598 - if (!dir->i_op || !dir->i_op->create)
599 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
604 - error = dir->i_op->create(dir, dentry, mode);
605 + if (dir->i_op->create_it)
606 + error = dir->i_op->create_it(dir, dentry, mode, it);
608 + error = dir->i_op->create(dir, dentry, mode);
612 @@ -956,6 +1071,11 @@
616 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
618 + return vfs_create_it(dir, dentry, mode, NULL);
625 * for symlinks (where the permissions are checked later).
628 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
629 +int open_namei_it(const char *pathname, int flag, int mode,
630 + struct nameidata *nd, struct lookup_intent *it)
632 int acc_mode, error = 0;
634 @@ -980,12 +1101,14 @@
636 acc_mode = ACC_MODE(flag);
639 + it->it_flags = flag;
641 * The simplest case - just a plain lookup.
643 if (!(flag & O_CREAT)) {
644 if (path_init(pathname, lookup_flags(flag), nd))
645 - error = path_walk(pathname, nd);
646 + error = path_walk_it(pathname, nd, it);
650 @@ -995,6 +1118,10 @@
652 * Create - we need to know the parent.
655 + it->it_create_mode = mode;
656 + it->it_op |= IT_CREAT;
658 if (path_init(pathname, LOOKUP_PARENT, nd))
659 error = path_walk(pathname, nd);
661 @@ -1011,7 +1138,7 @@
664 down(&dir->d_inode->i_sem);
665 - dentry = lookup_hash(&nd->last, nd->dentry);
666 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
669 error = PTR_ERR(dentry);
670 @@ -1020,10 +1147,11 @@
674 + it->it_create_mode = mode;
675 /* Negative dentry, just create the file */
676 if (!dentry->d_inode) {
677 - error = vfs_create(dir->d_inode, dentry,
678 - mode & ~current->fs->umask);
679 + error = vfs_create_it(dir->d_inode, dentry,
680 + mode & ~current->fs->umask, it);
681 up(&dir->d_inode->i_sem);
684 @@ -1127,7 +1255,7 @@
688 - error = do_truncate(dentry, 0);
689 + error = do_truncate(dentry, 0, 1);
691 put_write_access(inode);
693 @@ -1139,8 +1267,10 @@
697 + intent_release(it);
700 + intent_release(it);
704 @@ -1159,7 +1289,10 @@
705 * are done. Procfs-like symlinks just set LAST_BIND.
707 UPDATE_ATIME(dentry->d_inode);
709 error = dentry->d_inode->i_op->follow_link(dentry, nd);
711 + intent_release(it);
715 @@ -1181,13 +1314,20 @@
718 down(&dir->d_inode->i_sem);
719 - dentry = lookup_hash(&nd->last, nd->dentry);
720 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
721 putname(nd->last.name);
725 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
727 + return open_namei_it(pathname, flag, mode, nd, NULL);
732 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
733 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
734 + struct lookup_intent *it)
736 struct dentry *dentry;
738 @@ -1195,7 +1335,7 @@
739 dentry = ERR_PTR(-EEXIST);
740 if (nd->last_type != LAST_NORM)
742 - dentry = lookup_hash(&nd->last, nd->dentry);
743 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
746 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
747 @@ -1252,7 +1392,16 @@
748 error = path_walk(tmp, &nd);
751 - dentry = lookup_create(&nd, 0);
753 + if (nd.dentry->d_inode->i_op->mknod_raw) {
754 + struct inode_operations *op = nd.dentry->d_inode->i_op;
755 + error = op->mknod_raw(&nd, mode, dev);
756 + /* the file system wants to use normal vfs path now */
757 + if (error != -EOPNOTSUPP)
761 + dentry = lookup_create(&nd, 0, NULL);
762 error = PTR_ERR(dentry);
764 mode &= ~current->fs->umask;
765 @@ -1273,6 +1422,7 @@
768 up(&nd.dentry->d_inode->i_sem);
773 @@ -1321,7 +1471,14 @@
774 error = path_walk(tmp, &nd);
777 - dentry = lookup_create(&nd, 1);
778 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
779 + struct inode_operations *op = nd.dentry->d_inode->i_op;
780 + error = op->mkdir_raw(&nd, mode);
781 + /* the file system wants to use normal vfs path now */
782 + if (error != -EOPNOTSUPP)
785 + dentry = lookup_create(&nd, 1, NULL);
786 error = PTR_ERR(dentry);
787 if (!IS_ERR(dentry)) {
788 error = vfs_mkdir(nd.dentry->d_inode, dentry,
789 @@ -1329,6 +1486,7 @@
792 up(&nd.dentry->d_inode->i_sem);
797 @@ -1428,8 +1586,16 @@
801 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
802 + struct inode_operations *op = nd.dentry->d_inode->i_op;
804 + error = op->rmdir_raw(&nd);
805 + /* the file system wants to use normal vfs path now */
806 + if (error != -EOPNOTSUPP)
809 down(&nd.dentry->d_inode->i_sem);
810 - dentry = lookup_hash(&nd.last, nd.dentry);
811 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
812 error = PTR_ERR(dentry);
813 if (!IS_ERR(dentry)) {
814 error = vfs_rmdir(nd.dentry->d_inode, dentry);
815 @@ -1488,8 +1654,15 @@
817 if (nd.last_type != LAST_NORM)
819 + if (nd.dentry->d_inode->i_op->unlink_raw) {
820 + struct inode_operations *op = nd.dentry->d_inode->i_op;
821 + error = op->unlink_raw(&nd);
822 + /* the file system wants to use normal vfs path now */
823 + if (error != -EOPNOTSUPP)
826 down(&nd.dentry->d_inode->i_sem);
827 - dentry = lookup_hash(&nd.last, nd.dentry);
828 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
829 error = PTR_ERR(dentry);
830 if (!IS_ERR(dentry)) {
831 /* Why not before? Because we want correct error value */
832 @@ -1557,15 +1730,23 @@
833 error = path_walk(to, &nd);
836 - dentry = lookup_create(&nd, 0);
837 + if (nd.dentry->d_inode->i_op->symlink_raw) {
838 + struct inode_operations *op = nd.dentry->d_inode->i_op;
839 + error = op->symlink_raw(&nd, from);
840 + /* the file system wants to use normal vfs path now */
841 + if (error != -EOPNOTSUPP)
844 + dentry = lookup_create(&nd, 0, NULL);
845 error = PTR_ERR(dentry);
846 if (!IS_ERR(dentry)) {
847 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
850 up(&nd.dentry->d_inode->i_sem);
858 @@ -1648,7 +1829,14 @@
860 if (old_nd.mnt != nd.mnt)
862 - new_dentry = lookup_create(&nd, 0);
863 + if (nd.dentry->d_inode->i_op->link_raw) {
864 + struct inode_operations *op = nd.dentry->d_inode->i_op;
865 + error = op->link_raw(&old_nd, &nd);
866 + /* the file system wants to use normal vfs path now */
867 + if (error != -EOPNOTSUPP)
870 + new_dentry = lookup_create(&nd, 0, NULL);
871 error = PTR_ERR(new_dentry);
872 if (!IS_ERR(new_dentry)) {
873 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
874 @@ -1694,7 +1882,7 @@
877 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
878 - struct inode *new_dir, struct dentry *new_dentry)
879 + struct inode *new_dir, struct dentry *new_dentry)
882 struct inode *target;
883 @@ -1775,7 +1963,7 @@
886 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
887 - struct inode *new_dir, struct dentry *new_dentry)
888 + struct inode *new_dir, struct dentry *new_dentry)
892 @@ -1866,9 +2054,18 @@
893 if (newnd.last_type != LAST_NORM)
896 + if (old_dir->d_inode->i_op->rename_raw) {
898 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
900 + /* the file system wants to use normal vfs path now */
901 + if (error != -EOPNOTSUPP)
905 double_lock(new_dir, old_dir);
907 - old_dentry = lookup_hash(&oldnd.last, old_dir);
908 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
909 error = PTR_ERR(old_dentry);
910 if (IS_ERR(old_dentry))
912 @@ -1884,16 +2081,16 @@
913 if (newnd.last.name[newnd.last.len])
916 - new_dentry = lookup_hash(&newnd.last, new_dir);
917 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
918 error = PTR_ERR(new_dentry);
919 if (IS_ERR(new_dentry))
924 error = vfs_rename(old_dir->d_inode, old_dentry,
925 new_dir->d_inode, new_dentry);
931 @@ -1944,20 +2141,26 @@
935 -__vfs_follow_link(struct nameidata *nd, const char *link)
936 +__vfs_follow_link(struct nameidata *nd, const char *link,
937 + struct lookup_intent *it)
946 + else if (it != nd->intent)
947 + printk("it != nd->intent: tell phil@clusterfs.com\n");
951 if (!walk_init_root(link, nd))
952 /* weird __emul_prefix() stuff did it */
955 - res = link_path_walk(link, nd);
956 + res = link_path_walk_it(link, nd, it);
958 if (current->link_count || res || nd->last_type!=LAST_NORM)
960 @@ -1979,7 +2182,13 @@
962 int vfs_follow_link(struct nameidata *nd, const char *link)
964 - return __vfs_follow_link(nd, link);
965 + return __vfs_follow_link(nd, link, NULL);
968 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
969 + struct lookup_intent *it)
971 + return __vfs_follow_link(nd, link, it);
974 /* get the link contents into pagecache */
975 @@ -2021,7 +2230,7 @@
977 struct page *page = NULL;
978 char *s = page_getlink(dentry, &page);
979 - int res = __vfs_follow_link(nd, s);
980 + int res = __vfs_follow_link(nd, s, NULL);
983 page_cache_release(page);
984 Index: linux-2.4.19-pre1/fs/open.c
985 ===================================================================
986 --- linux-2.4.19-pre1.orig/fs/open.c 2003-11-21 02:41:00.000000000 +0300
987 +++ linux-2.4.19-pre1/fs/open.c 2003-11-21 02:51:38.000000000 +0300
989 #include <asm/uaccess.h>
991 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
992 +extern int path_walk_it(const char *name, struct nameidata *nd,
993 + struct lookup_intent *it);
995 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1001 -int do_truncate(struct dentry *dentry, loff_t length)
1002 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1004 struct inode *inode = dentry->d_inode;
1005 + struct inode_operations *op = dentry->d_inode->i_op;
1007 struct iattr newattrs;
1010 down(&inode->i_sem);
1011 newattrs.ia_size = length;
1012 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1013 - error = notify_change(dentry, &newattrs);
1014 + if (called_from_open)
1015 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1016 + if (op->setattr_raw) {
1017 + newattrs.ia_valid |= ATTR_RAW;
1018 + error = op->setattr_raw(inode, &newattrs);
1020 + error = notify_change(dentry, &newattrs);
1024 @@ -94,12 +103,13 @@
1025 struct nameidata nd;
1026 struct inode * inode;
1028 + struct lookup_intent it = { .it_op = IT_GETATTR };
1031 if (length < 0) /* sorry, but loff_t says... */
1034 - error = user_path_walk(path, &nd);
1035 + error = user_path_walk_it(path, &nd, &it);
1038 inode = nd.dentry->d_inode;
1039 @@ -139,11 +149,13 @@
1040 error = locks_verify_truncate(inode, NULL, length);
1043 - error = do_truncate(nd.dentry, length);
1044 + intent_release(&it);
1045 + error = do_truncate(nd.dentry, length, 0);
1047 put_write_access(inode);
1050 + intent_release(&it);
1056 error = locks_verify_truncate(inode, file, length);
1058 - error = do_truncate(dentry, length);
1059 + error = do_truncate(dentry, length, 0);
1063 @@ -236,11 +248,13 @@
1064 struct inode * inode;
1065 struct iattr newattrs;
1067 - error = user_path_walk(filename, &nd);
1068 + error = user_path_walk_it(filename, &nd, NULL);
1071 inode = nd.dentry->d_inode;
1073 + /* this is safe without a Lustre lock because it only depends
1074 + on the super block */
1076 if (IS_RDONLY(inode))
1078 @@ -255,11 +269,25 @@
1081 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1085 + if (inode->i_op->setattr_raw) {
1086 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1088 + newattrs.ia_valid |= ATTR_RAW;
1089 + error = op->setattr_raw(inode, &newattrs);
1090 + /* the file system wants to use normal vfs path now */
1091 + if (error != -EOPNOTSUPP)
1092 + goto dput_and_out;
1097 if (current->fsuid != inode->i_uid &&
1098 (error = permission(inode,MAY_WRITE)) != 0)
1102 error = notify_change(nd.dentry, &newattrs);
1105 @@ -280,12 +308,14 @@
1106 struct inode * inode;
1107 struct iattr newattrs;
1109 - error = user_path_walk(filename, &nd);
1110 + error = user_path_walk_it(filename, &nd, NULL);
1114 inode = nd.dentry->d_inode;
1116 + /* this is safe without a Lustre lock because it only depends
1117 + on the super block */
1119 if (IS_RDONLY(inode))
1121 @@ -300,7 +330,20 @@
1122 newattrs.ia_atime = times[0].tv_sec;
1123 newattrs.ia_mtime = times[1].tv_sec;
1124 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1128 + if (inode->i_op->setattr_raw) {
1129 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1131 + newattrs.ia_valid |= ATTR_RAW;
1132 + error = op->setattr_raw(inode, &newattrs);
1133 + /* the file system wants to use normal vfs path now */
1134 + if (error != -EOPNOTSUPP)
1135 + goto dput_and_out;
1140 if ((error = permission(inode,MAY_WRITE)) != 0)
1144 int old_fsuid, old_fsgid;
1145 kernel_cap_t old_cap;
1147 + struct lookup_intent it = { .it_op = IT_GETATTR };
1149 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1151 @@ -339,13 +383,14 @@
1153 current->cap_effective = current->cap_permitted;
1155 - res = user_path_walk(filename, &nd);
1156 + res = user_path_walk_it(filename, &nd, &it);
1158 res = permission(nd.dentry->d_inode, mode);
1159 /* SuS v2 requires we report a read only fs too */
1160 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1161 && !special_file(nd.dentry->d_inode->i_mode))
1163 + intent_release(&it);
1169 struct nameidata nd;
1171 + struct lookup_intent it = { .it_op = IT_GETATTR };
1173 name = getname(filename);
1174 error = PTR_ERR(name);
1178 if (path_init(name,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd))
1179 - error = path_walk(name, &nd);
1180 + error = path_walk_it(name, &nd, &it);
1185 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1188 + intent_release(&it);
1194 struct nameidata nd;
1196 + struct lookup_intent it = { .it_op = IT_GETATTR };
1198 name = getname(filename);
1199 error = PTR_ERR(name);
1202 path_init(name, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1203 LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1204 - error = path_walk(name, &nd);
1205 + error = path_walk_it(name, &nd, &it);
1209 @@ -446,39 +494,56 @@
1213 + intent_release(&it);
1219 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1220 +int chmod_common(struct dentry *dentry, mode_t mode)
1222 - struct inode * inode;
1223 - struct dentry * dentry;
1224 - struct file * file;
1226 + struct inode *inode = dentry->d_inode;
1227 struct iattr newattrs;
1232 + if (IS_RDONLY(inode))
1235 - dentry = file->f_dentry;
1236 - inode = dentry->d_inode;
1237 + if (inode->i_op->setattr_raw) {
1238 + newattrs.ia_mode = mode;
1239 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1240 + newattrs.ia_valid |= ATTR_RAW;
1241 + err = inode->i_op->setattr_raw(inode, &newattrs);
1242 + /* the file system wants to use normal vfs path now */
1243 + if (err != -EOPNOTSUPP)
1248 - if (IS_RDONLY(inode))
1251 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1255 if (mode == (mode_t) -1)
1256 mode = inode->i_mode;
1257 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1258 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1259 err = notify_change(dentry, &newattrs);
1266 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1268 + struct file * file;
1275 + err = chmod_common(file->f_dentry, mode);
1280 @@ -487,30 +552,14 @@
1281 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1283 struct nameidata nd;
1284 - struct inode * inode;
1286 - struct iattr newattrs;
1288 error = user_path_walk(filename, &nd);
1291 - inode = nd.dentry->d_inode;
1294 - if (IS_RDONLY(inode))
1295 - goto dput_and_out;
1298 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1299 - goto dput_and_out;
1300 + error = chmod_common(nd.dentry, mode);
1302 - if (mode == (mode_t) -1)
1303 - mode = inode->i_mode;
1304 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1305 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1306 - error = notify_change(nd.dentry, &newattrs);
1312 @@ -530,6 +579,20 @@
1314 if (IS_RDONLY(inode))
1317 + if (inode->i_op->setattr_raw) {
1318 + struct inode_operations *op = dentry->d_inode->i_op;
1320 + newattrs.ia_uid = user;
1321 + newattrs.ia_gid = group;
1322 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1323 + newattrs.ia_valid |= ATTR_RAW;
1324 + error = op->setattr_raw(inode, &newattrs);
1325 + /* the file system wants to use normal vfs path now */
1326 + if (error != -EOPNOTSUPP)
1331 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1335 int namei_flags, error;
1336 struct nameidata nd;
1337 + struct lookup_intent it = { .it_op = IT_OPEN };
1339 namei_flags = flags;
1340 if ((namei_flags+1) & O_ACCMODE)
1341 @@ -641,14 +705,15 @@
1342 if (namei_flags & O_TRUNC)
1345 - error = open_namei(filename, namei_flags, mode, &nd);
1347 - return dentry_open(nd.dentry, nd.mnt, flags);
1348 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1350 + return ERR_PTR(error);
1352 - return ERR_PTR(error);
1353 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1356 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1357 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1358 + int flags, struct lookup_intent *it)
1361 struct inode *inode;
1362 @@ -685,12 +750,15 @@
1365 if (f->f_op && f->f_op->open) {
1367 error = f->f_op->open(inode,f);
1372 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1374 + intent_release(it);
1378 @@ -705,11 +773,17 @@
1382 + intent_release(it);
1385 return ERR_PTR(error);
1388 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1390 + return dentry_open_it(dentry, mnt, flags, NULL);
1394 * Find an empty file descriptor entry, and mark it busy.
1396 Index: linux-2.4.19-pre1/fs/stat.c
1397 ===================================================================
1398 --- linux-2.4.19-pre1.orig/fs/stat.c 2003-11-21 02:41:00.000000000 +0300
1399 +++ linux-2.4.19-pre1/fs/stat.c 2003-11-21 02:51:38.000000000 +0300
1401 * Revalidate the inode. This is required for proper NFS attribute caching.
1403 static __inline__ int
1404 -do_revalidate(struct dentry *dentry)
1405 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1407 struct inode * inode = dentry->d_inode;
1408 - if (inode->i_op && inode->i_op->revalidate)
1411 + if (inode->i_op && inode->i_op->revalidate_it)
1412 + return inode->i_op->revalidate_it(dentry, it);
1413 + else if (inode->i_op && inode->i_op->revalidate)
1414 return inode->i_op->revalidate(dentry);
1417 @@ -135,13 +139,15 @@
1418 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1420 struct nameidata nd;
1421 + struct lookup_intent it = { .it_op = IT_GETATTR };
1424 - error = user_path_walk(filename, &nd);
1425 + error = user_path_walk_it(filename, &nd, &it);
1427 - error = do_revalidate(nd.dentry);
1428 + error = do_revalidate(nd.dentry, &it);
1430 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1431 + intent_release(&it);
1435 @@ -151,13 +157,15 @@
1436 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1438 struct nameidata nd;
1439 + struct lookup_intent it = { .it_op = IT_GETATTR };
1442 - error = user_path_walk(filename, &nd);
1443 + error = user_path_walk_it(filename, &nd, &it);
1445 - error = do_revalidate(nd.dentry);
1446 + error = do_revalidate(nd.dentry, &it);
1448 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1449 + intent_release(&it);
1453 @@ -172,13 +180,15 @@
1454 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1456 struct nameidata nd;
1457 + struct lookup_intent it = { .it_op = IT_GETATTR };
1460 - error = user_path_walk_link(filename, &nd);
1461 + error = user_path_walk_link_it(filename, &nd, &it);
1463 - error = do_revalidate(nd.dentry);
1464 + error = do_revalidate(nd.dentry, &it);
1466 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1467 + intent_release(&it);
1471 @@ -189,13 +199,15 @@
1472 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1474 struct nameidata nd;
1475 + struct lookup_intent it = { .it_op = IT_GETATTR };
1478 - error = user_path_walk_link(filename, &nd);
1479 + error = user_path_walk_link_it(filename, &nd, &it);
1481 - error = do_revalidate(nd.dentry);
1482 + error = do_revalidate(nd.dentry, &it);
1484 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1485 + intent_release(&it);
1491 struct dentry * dentry = f->f_dentry;
1493 - err = do_revalidate(dentry);
1494 + err = do_revalidate(dentry, NULL);
1496 err = cp_old_stat(dentry->d_inode, statbuf);
1500 struct dentry * dentry = f->f_dentry;
1502 - err = do_revalidate(dentry);
1503 + err = do_revalidate(dentry, NULL);
1505 err = cp_new_stat(dentry->d_inode, statbuf);
1510 if (inode->i_op && inode->i_op->readlink &&
1511 - !(error = do_revalidate(nd.dentry))) {
1512 + !(error = do_revalidate(nd.dentry, NULL))) {
1513 UPDATE_ATIME(inode);
1514 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1516 @@ -333,12 +345,14 @@
1518 struct nameidata nd;
1520 + struct lookup_intent it = { .it_op = IT_GETATTR };
1522 - error = user_path_walk(filename, &nd);
1523 + error = user_path_walk_it(filename, &nd, &it);
1525 - error = do_revalidate(nd.dentry);
1526 + error = do_revalidate(nd.dentry, &it);
1528 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1529 + intent_release(&it);
1533 @@ -348,12 +362,14 @@
1535 struct nameidata nd;
1537 + struct lookup_intent it = { .it_op = IT_GETATTR };
1539 - error = user_path_walk_link(filename, &nd);
1540 + error = user_path_walk_link_it(filename, &nd, &it);
1542 - error = do_revalidate(nd.dentry);
1543 + error = do_revalidate(nd.dentry, &it);
1545 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1546 + intent_release(&it);
1552 struct dentry * dentry = f->f_dentry;
1554 - err = do_revalidate(dentry);
1555 + err = do_revalidate(dentry, NULL);
1557 err = cp_new_stat64(dentry->d_inode, statbuf);
1559 Index: linux-2.4.19-pre1/include/linux/dcache.h
1560 ===================================================================
1561 --- linux-2.4.19-pre1.orig/include/linux/dcache.h 2003-11-21 02:41:00.000000000 +0300
1562 +++ linux-2.4.19-pre1/include/linux/dcache.h 2003-11-21 02:51:38.000000000 +0300
1565 #include <asm/atomic.h>
1566 #include <linux/mount.h>
1567 +#include <linux/string.h>
1569 +#define IT_OPEN 0x0001
1570 +#define IT_CREAT 0x0002
1571 +#define IT_READDIR 0x0004
1572 +#define IT_GETATTR 0x0008
1573 +#define IT_LOOKUP 0x0010
1574 +#define IT_UNLINK 0x0020
1575 +#define IT_GETXATTR 0x0040
1576 +#define IT_EXEC 0x0080
1577 +#define IT_PIN 0x0100
1579 +#define IT_FL_LOCKED 0x0001
1580 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1582 +#define INTENT_MAGIC 0x19620323
1585 +struct lustre_intent_data {
1586 + int it_disposition;
1588 + __u64 it_lock_handle;
1593 +struct lookup_intent {
1595 + void (*it_op_release)(struct lookup_intent *);
1598 + int it_create_mode;
1600 + struct lustre_intent_data lustre;
1604 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1606 + memset(it, 0, sizeof(*it));
1607 + it->it_magic = INTENT_MAGIC;
1609 + it->it_flags = flags;
1614 * linux/include/linux/dcache.h
1616 int (*d_delete)(struct dentry *);
1617 void (*d_release)(struct dentry *);
1618 void (*d_iput)(struct dentry *, struct inode *);
1619 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1620 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1621 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1624 +#define PIN(de,mnt,flag) if (de->d_op && de->d_op->d_pin) \
1625 + de->d_op->d_pin(de, mnt, flag);
1626 +#define UNPIN(de,mnt,flag) if (de->d_op && de->d_op->d_unpin) \
1627 + de->d_op->d_unpin(de, mnt, flag);
1630 +/* defined in fs/namei.c */
1631 +extern void intent_release(struct lookup_intent *it);
1632 +/* defined in fs/dcache.c */
1633 +extern void __d_rehash(struct dentry * entry, int lock);
1635 /* the dentry parameter passed to d_hash and d_compare is the parent
1636 * directory of the entries to be compared. It is used in case these
1637 * functions need any directory specific information for determining
1639 * s_nfsd_free_path semaphore will be down
1641 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1642 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1644 extern spinlock_t dcache_lock;
1646 Index: linux-2.4.19-pre1/include/linux/fs.h
1647 ===================================================================
1648 --- linux-2.4.19-pre1.orig/include/linux/fs.h 2003-11-21 02:51:37.000000000 +0300
1649 +++ linux-2.4.19-pre1/include/linux/fs.h 2003-11-21 02:51:38.000000000 +0300
1652 #define FMODE_READ 1
1653 #define FMODE_WRITE 2
1654 +#define FMODE_EXEC 4
1659 #define ATTR_MTIME_SET 256
1660 #define ATTR_FORCE 512 /* Not a change, but a change it */
1661 #define ATTR_ATTR_FLAG 1024
1662 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1663 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1664 +#define ATTR_CTIME_SET 0x2000
1667 * This is the Inode Attributes structure, used for notify_change(). It
1669 struct pipe_inode_info *i_pipe;
1670 struct block_device *i_bdev;
1671 struct char_device *i_cdev;
1672 + void *i_filterdata;
1674 unsigned long i_dnotify_mask; /* Directory notify events */
1675 struct dnotify_struct *i_dnotify; /* for directory notifications */
1678 /* needed for tty driver, and maybe others */
1680 + struct lookup_intent *f_it;
1682 /* preallocated helper kiobuf to speedup O_DIRECT */
1683 struct kiobuf *f_iobuf;
1688 + struct lookup_intent *intent;
1691 #define DQUOT_USR_ENABLED 0x01 /* User diskquotas enabled */
1693 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1694 extern int vfs_rmdir(struct inode *, struct dentry *);
1695 extern int vfs_unlink(struct inode *, struct dentry *);
1696 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1697 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1698 + struct inode *new_dir, struct dentry *new_dentry);
1702 @@ -837,21 +845,32 @@
1704 struct inode_operations {
1705 int (*create) (struct inode *,struct dentry *,int);
1706 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1707 struct dentry * (*lookup) (struct inode *,struct dentry *);
1708 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1709 int (*link) (struct dentry *,struct inode *,struct dentry *);
1710 + int (*link_raw) (struct nameidata *,struct nameidata *);
1711 int (*unlink) (struct inode *,struct dentry *);
1712 + int (*unlink_raw) (struct nameidata *);
1713 int (*symlink) (struct inode *,struct dentry *,const char *);
1714 + int (*symlink_raw) (struct nameidata *,const char *);
1715 int (*mkdir) (struct inode *,struct dentry *,int);
1716 + int (*mkdir_raw) (struct nameidata *,int);
1717 int (*rmdir) (struct inode *,struct dentry *);
1718 + int (*rmdir_raw) (struct nameidata *);
1719 int (*mknod) (struct inode *,struct dentry *,int,int);
1720 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1721 int (*rename) (struct inode *, struct dentry *,
1722 struct inode *, struct dentry *);
1723 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1724 int (*readlink) (struct dentry *, char *,int);
1725 int (*follow_link) (struct dentry *, struct nameidata *);
1726 void (*truncate) (struct inode *);
1727 int (*permission) (struct inode *, int);
1728 int (*revalidate) (struct dentry *);
1729 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1730 int (*setattr) (struct dentry *, struct iattr *);
1731 + int (*setattr_raw) (struct inode *, struct iattr *);
1732 int (*getattr) (struct dentry *, struct iattr *);
1735 @@ -1049,10 +1068,14 @@
1737 asmlinkage long sys_open(const char *, int, int);
1738 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1739 -extern int do_truncate(struct dentry *, loff_t start);
1740 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1742 extern struct file *filp_open(const char *, int, int);
1743 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1744 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1745 + struct nameidata *nd, struct lookup_intent *it);
1746 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1747 + int flags, struct lookup_intent *it);
1748 extern int filp_close(struct file *, fl_owner_t id);
1749 extern char * getname(const char *);
1751 @@ -1306,6 +1329,7 @@
1752 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1754 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1755 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1756 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1757 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1758 extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
1759 @@ -1316,6 +1340,8 @@
1760 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1761 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1762 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1763 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1764 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1766 extern void iput(struct inode *);
1767 extern void force_delete(struct inode *);
1768 @@ -1423,6 +1449,8 @@
1770 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1771 extern int vfs_follow_link(struct nameidata *, const char *);
1772 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1773 + struct lookup_intent *it);
1774 extern int page_readlink(struct dentry *, char *, int);
1775 extern int page_follow_link(struct dentry *, struct nameidata *);
1776 extern struct inode_operations page_symlink_inode_operations;
1777 Index: linux-2.4.19-pre1/include/linux/fs_struct.h
1778 ===================================================================
1779 --- linux-2.4.19-pre1.orig/include/linux/fs_struct.h 2003-11-21 02:41:00.000000000 +0300
1780 +++ linux-2.4.19-pre1/include/linux/fs_struct.h 2003-11-21 02:51:38.000000000 +0300
1782 write_lock(&fs->lock);
1783 old_root = fs->root;
1784 old_rootmnt = fs->rootmnt;
1785 + PIN(dentry, mnt, 1);
1786 fs->rootmnt = mntget(mnt);
1787 fs->root = dget(dentry);
1788 write_unlock(&fs->lock);
1790 + UNPIN(old_root, old_rootmnt, 1);
1792 mntput(old_rootmnt);
1795 write_lock(&fs->lock);
1797 old_pwdmnt = fs->pwdmnt;
1798 + PIN(dentry, mnt, 0);
1799 fs->pwdmnt = mntget(mnt);
1800 fs->pwd = dget(dentry);
1801 write_unlock(&fs->lock);
1803 + UNPIN(old_pwd, old_pwdmnt, 0);
1807 Index: linux-2.4.19-pre1/kernel/ksyms.c
1808 ===================================================================
1809 --- linux-2.4.19-pre1.orig/kernel/ksyms.c 2003-11-21 02:51:37.000000000 +0300
1810 +++ linux-2.4.19-pre1/kernel/ksyms.c 2003-11-21 02:51:38.000000000 +0300
1812 EXPORT_SYMBOL(set_page_dirty);
1813 EXPORT_SYMBOL(vfs_readlink);
1814 EXPORT_SYMBOL(vfs_follow_link);
1815 +EXPORT_SYMBOL(vfs_follow_link_it);
1816 EXPORT_SYMBOL(page_readlink);
1817 EXPORT_SYMBOL(page_follow_link);
1818 EXPORT_SYMBOL(page_symlink_inode_operations);
1819 Index: linux-2.4.19-pre1/kernel/fork.c
1820 ===================================================================
1821 --- linux-2.4.19-pre1.orig/kernel/fork.c 2003-11-21 02:41:00.000000000 +0300
1822 +++ linux-2.4.19-pre1/kernel/fork.c 2003-11-21 02:51:38.000000000 +0300
1823 @@ -372,10 +372,13 @@
1824 fs->umask = old->umask;
1825 read_lock(&old->lock);
1826 fs->rootmnt = mntget(old->rootmnt);
1827 + PIN(old->pwd, old->pwdmnt, 0);
1828 + PIN(old->root, old->rootmnt, 1);
1829 fs->root = dget(old->root);
1830 fs->pwdmnt = mntget(old->pwdmnt);
1831 fs->pwd = dget(old->pwd);
1833 + PIN(old->altroot, old->altrootmnt, 1);
1834 fs->altrootmnt = mntget(old->altrootmnt);
1835 fs->altroot = dget(old->altroot);
1837 Index: linux-2.4.19-pre1/kernel/exit.c
1838 ===================================================================
1839 --- linux-2.4.19-pre1.orig/kernel/exit.c 2003-11-21 02:41:00.000000000 +0300
1840 +++ linux-2.4.19-pre1/kernel/exit.c 2003-11-21 02:51:38.000000000 +0300
1841 @@ -245,11 +245,14 @@
1843 /* No need to hold fs->lock if we are killing it */
1844 if (atomic_dec_and_test(&fs->count)) {
1845 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1846 + UNPIN(fs->root, fs->rootmnt, 1);
1848 mntput(fs->rootmnt);
1852 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1854 mntput(fs->altrootmnt);