3 fs/namei.c | 330 +++++++++++++++++++++++++++++++++++++++-------
4 fs/namespace.c | 28 ++-
5 fs/open.c | 172 +++++++++++++++++------
8 include/linux/dcache.h | 60 ++++++++
9 include/linux/fs.h | 32 ++++
10 include/linux/fs_struct.h | 4
14 13 files changed, 591 insertions(+), 133 deletions(-)
16 Index: linux/fs/dcache.c
17 ===================================================================
18 --- linux.orig/fs/dcache.c Thu Nov 28 18:53:15 2002
19 +++ linux/fs/dcache.c Wed Mar 17 13:11:25 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/fs/exec.c
58 ===================================================================
59 --- linux.orig/fs/exec.c Wed Mar 17 13:00:38 2004
60 +++ linux/fs/exec.c Wed Mar 17 13:11:25 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 @@ -1120,7 +1127,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/fs/namei.c
123 ===================================================================
124 --- linux.orig/fs/namei.c Wed Mar 17 13:00:37 2004
125 +++ linux/fs/namei.c Wed Mar 17 13:12:31 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 >= 5)
214 @@ -346,10 +379,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 @@ -379,15 +420,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 @@ -520,15 +573,15 @@
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 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
297 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
298 err = PTR_ERR(dentry);
302 /* Check mountpoints.. */
303 - while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry))
304 + while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry, NULL))
311 if (inode->i_op->follow_link) {
312 - err = do_follow_link(dentry, nd);
313 + err = do_follow_link(dentry, nd, NULL);
321 - if (!inode->i_op->lookup)
322 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
325 /* here ends the main loop */
326 @@ -583,19 +636,19 @@
330 - dentry = cached_lookup(nd->dentry, &this, 0);
331 + dentry = cached_lookup(nd->dentry, &this, 0, it);
333 - dentry = real_lookup(nd->dentry, &this, 0);
334 + dentry = real_lookup(nd->dentry, &this, 0, it);
335 err = PTR_ERR(dentry);
339 - while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry))
340 + while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry, it))
342 inode = dentry->d_inode;
343 if ((lookup_flags & LOOKUP_FOLLOW)
344 && inode && inode->i_op && inode->i_op->follow_link) {
345 - err = do_follow_link(dentry, nd);
346 + err = do_follow_link(dentry, nd, it);
352 if (lookup_flags & LOOKUP_DIRECTORY) {
354 - if (!inode->i_op || !inode->i_op->lookup)
355 + if (!inode->i_op ||
356 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
361 * Check the cached dentry for staleness.
364 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
366 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
367 + struct dentry *new;
368 + err = permission(dentry->d_parent->d_inode,
372 + new = real_lookup(dentry->d_parent,
373 + &dentry->d_name, 0, it);
374 + d_invalidate(dentry);
377 + err = PTR_ERR(new);
382 + if (!nd->dentry->d_inode)
385 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
387 if (!dentry->d_op->d_revalidate(dentry, 0)) {
388 @@ -646,15 +721,28 @@
393 + intent_release(it);
399 +int link_path_walk(const char * name, struct nameidata *nd)
401 + return link_path_walk_it(name, nd, NULL);
404 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
406 + current->total_link_count = 0;
407 + return link_path_walk_it(name, nd, it);
410 int path_walk(const char * name, struct nameidata *nd)
412 current->total_link_count = 0;
413 - return link_path_walk(name, nd);
414 + return link_path_walk_it(name, nd, NULL);
422 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
423 + struct lookup_intent *it)
426 + if (path_init(path, flags, nd))
427 + error = path_walk_it(path, nd, it);
433 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
438 nd->last_type = LAST_ROOT; /* if there are only slashes... */
442 return walk_init_root(name,nd);
443 read_lock(¤t->fs->lock);
445 * needs parent already locked. Doesn't follow mounts.
448 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
449 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
450 + struct lookup_intent *it)
452 struct dentry * dentry;
454 @@ -790,13 +891,16 @@
458 - dentry = cached_lookup(base, name, 0);
459 + dentry = cached_lookup(base, name, 0, it);
461 struct dentry *new = d_alloc(base, name);
462 dentry = ERR_PTR(-ENOMEM);
466 + if (inode->i_op->lookup_it)
467 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
469 dentry = inode->i_op->lookup(inode, new);
476 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
478 + return lookup_hash_it(name, base, NULL);
483 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
487 this.hash = end_name_hash(hash);
489 - return lookup_hash(&this, base);
490 + return lookup_hash_it(&this, base, NULL);
492 return ERR_PTR(-EACCES);
498 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
499 + struct lookup_intent *it)
504 + tmp = getname(name);
505 + err = PTR_ERR(tmp);
506 + if (!IS_ERR(tmp)) {
508 + if (path_init(tmp, flags, nd))
509 + err = path_walk_it(tmp, nd, it);
516 * It's inline, so penalty for filesystems that don't use sticky bit is
522 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
523 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
524 + struct lookup_intent *it)
528 @@ -968,12 +1096,15 @@
531 error = -EACCES; /* shouldn't it be ENOSYS? */
532 - if (!dir->i_op || !dir->i_op->create)
533 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
538 - error = dir->i_op->create(dir, dentry, mode);
539 + if (dir->i_op->create_it)
540 + error = dir->i_op->create_it(dir, dentry, mode, it);
542 + error = dir->i_op->create(dir, dentry, mode);
546 @@ -982,6 +1113,11 @@
550 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
552 + return vfs_create_it(dir, dentry, mode, NULL);
559 * for symlinks (where the permissions are checked later).
562 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
563 +int open_namei_it(const char *pathname, int flag, int mode,
564 + struct nameidata *nd, struct lookup_intent *it)
566 int acc_mode, error = 0;
568 @@ -1006,11 +1143,14 @@
570 acc_mode = ACC_MODE(flag);
573 + it->it_flags = flag;
576 * The simplest case - just a plain lookup.
578 if (!(flag & O_CREAT)) {
579 - error = path_lookup(pathname, lookup_flags(flag), nd);
580 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
584 @@ -1020,6 +1160,10 @@
586 * Create - we need to know the parent.
589 + it->it_create_mode = mode;
590 + it->it_op |= IT_CREAT;
592 error = path_lookup(pathname, LOOKUP_PARENT, nd);
595 @@ -1035,7 +1179,7 @@
598 down(&dir->d_inode->i_sem);
599 - dentry = lookup_hash(&nd->last, nd->dentry);
600 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
603 error = PTR_ERR(dentry);
604 @@ -1044,11 +1188,12 @@
608 + it->it_create_mode = mode;
609 /* Negative dentry, just create the file */
610 if (!dentry->d_inode) {
611 if (!IS_POSIXACL(dir->d_inode))
612 mode &= ~current->fs->umask;
613 - error = vfs_create(dir->d_inode, dentry, mode);
614 + error = vfs_create_it(dir->d_inode, dentry, mode, it);
615 up(&dir->d_inode->i_sem);
618 @@ -1073,7 +1218,7 @@
620 if (flag & O_NOFOLLOW)
622 - while (__follow_down(&nd->mnt,&dentry) && d_mountpoint(dentry));
623 + while (__follow_down(&nd->mnt,&dentry,it) && d_mountpoint(dentry));
626 if (!dentry->d_inode)
627 @@ -1152,7 +1297,7 @@
631 - error = do_truncate(dentry, 0);
632 + error = do_truncate(dentry, 0, 1);
634 put_write_access(inode);
636 @@ -1164,8 +1309,10 @@
640 + intent_release(it);
643 + intent_release(it);
647 @@ -1184,7 +1331,16 @@
648 * are done. Procfs-like symlinks just set LAST_BIND.
650 UPDATE_ATIME(dentry->d_inode);
652 error = dentry->d_inode->i_op->follow_link(dentry, nd);
654 + intent_release(it);
655 + } else if (it != NULL && !(it->d.lustre.it_int_flags & IT_FL_FOLLOWED)) {
656 + /* vfs_follow_link was never called */
657 + intent_release(it);
664 @@ -1206,13 +1362,20 @@
667 down(&dir->d_inode->i_sem);
668 - dentry = lookup_hash(&nd->last, nd->dentry);
669 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
670 putname(nd->last.name);
674 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
676 + return open_namei_it(pathname, flag, mode, nd, NULL);
681 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
682 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
683 + struct lookup_intent *it)
685 struct dentry *dentry;
687 @@ -1220,7 +1383,7 @@
688 dentry = ERR_PTR(-EEXIST);
689 if (nd->last_type != LAST_NORM)
691 - dentry = lookup_hash(&nd->last, nd->dentry);
692 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
695 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
696 @@ -1276,7 +1439,20 @@
697 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
700 - dentry = lookup_create(&nd, 0);
702 + if (nd.last_type != LAST_NORM) {
706 + if (nd.dentry->d_inode->i_op->mknod_raw) {
707 + struct inode_operations *op = nd.dentry->d_inode->i_op;
708 + error = op->mknod_raw(&nd, mode, dev);
709 + /* the file system wants to use normal vfs path now */
710 + if (error != -EOPNOTSUPP)
714 + dentry = lookup_create(&nd, 0, NULL);
715 error = PTR_ERR(dentry);
717 if (!IS_POSIXACL(nd.dentry->d_inode))
718 @@ -1298,6 +1474,7 @@
721 up(&nd.dentry->d_inode->i_sem);
726 @@ -1345,7 +1522,18 @@
727 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
730 - dentry = lookup_create(&nd, 1);
731 + if (nd.last_type != LAST_NORM) {
735 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
736 + struct inode_operations *op = nd.dentry->d_inode->i_op;
737 + error = op->mkdir_raw(&nd, mode);
738 + /* the file system wants to use normal vfs path now */
739 + if (error != -EOPNOTSUPP)
742 + dentry = lookup_create(&nd, 1, NULL);
743 error = PTR_ERR(dentry);
744 if (!IS_ERR(dentry)) {
745 if (!IS_POSIXACL(nd.dentry->d_inode))
746 @@ -1354,6 +1542,7 @@
749 up(&nd.dentry->d_inode->i_sem);
754 @@ -1454,8 +1643,16 @@
758 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
759 + struct inode_operations *op = nd.dentry->d_inode->i_op;
761 + error = op->rmdir_raw(&nd);
762 + /* the file system wants to use normal vfs path now */
763 + if (error != -EOPNOTSUPP)
766 down(&nd.dentry->d_inode->i_sem);
767 - dentry = lookup_hash(&nd.last, nd.dentry);
768 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
769 error = PTR_ERR(dentry);
770 if (!IS_ERR(dentry)) {
771 error = vfs_rmdir(nd.dentry->d_inode, dentry);
772 @@ -1513,8 +1710,15 @@
774 if (nd.last_type != LAST_NORM)
776 + if (nd.dentry->d_inode->i_op->unlink_raw) {
777 + struct inode_operations *op = nd.dentry->d_inode->i_op;
778 + error = op->unlink_raw(&nd);
779 + /* the file system wants to use normal vfs path now */
780 + if (error != -EOPNOTSUPP)
783 down(&nd.dentry->d_inode->i_sem);
784 - dentry = lookup_hash(&nd.last, nd.dentry);
785 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
786 error = PTR_ERR(dentry);
787 if (!IS_ERR(dentry)) {
788 /* Why not before? Because we want correct error value */
789 @@ -1581,15 +1785,27 @@
790 error = path_lookup(to, LOOKUP_PARENT, &nd);
793 - dentry = lookup_create(&nd, 0);
794 + if (nd.last_type != LAST_NORM) {
798 + if (nd.dentry->d_inode->i_op->symlink_raw) {
799 + struct inode_operations *op = nd.dentry->d_inode->i_op;
800 + error = op->symlink_raw(&nd, from);
801 + /* the file system wants to use normal vfs path now */
802 + if (error != -EOPNOTSUPP)
805 + dentry = lookup_create(&nd, 0, NULL);
806 error = PTR_ERR(dentry);
807 if (!IS_ERR(dentry)) {
808 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
811 up(&nd.dentry->d_inode->i_sem);
819 @@ -1665,7 +1881,18 @@
821 if (old_nd.mnt != nd.mnt)
823 - new_dentry = lookup_create(&nd, 0);
824 + if (nd.last_type != LAST_NORM) {
828 + if (nd.dentry->d_inode->i_op->link_raw) {
829 + struct inode_operations *op = nd.dentry->d_inode->i_op;
830 + error = op->link_raw(&old_nd, &nd);
831 + /* the file system wants to use normal vfs path now */
832 + if (error != -EOPNOTSUPP)
835 + new_dentry = lookup_create(&nd, 0, NULL);
836 error = PTR_ERR(new_dentry);
837 if (!IS_ERR(new_dentry)) {
838 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
839 @@ -1709,7 +1936,7 @@
842 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
843 - struct inode *new_dir, struct dentry *new_dentry)
844 + struct inode *new_dir, struct dentry *new_dentry)
847 struct inode *target;
848 @@ -1788,7 +2015,7 @@
851 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
852 - struct inode *new_dir, struct dentry *new_dentry)
853 + struct inode *new_dir, struct dentry *new_dentry)
857 @@ -1876,9 +2103,18 @@
858 if (newnd.last_type != LAST_NORM)
861 + if (old_dir->d_inode->i_op->rename_raw) {
863 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
865 + /* the file system wants to use normal vfs path now */
866 + if (error != -EOPNOTSUPP)
870 double_lock(new_dir, old_dir);
872 - old_dentry = lookup_hash(&oldnd.last, old_dir);
873 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
874 error = PTR_ERR(old_dentry);
875 if (IS_ERR(old_dentry))
877 @@ -1894,16 +2130,16 @@
878 if (newnd.last.name[newnd.last.len])
881 - new_dentry = lookup_hash(&newnd.last, new_dir);
882 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
883 error = PTR_ERR(new_dentry);
884 if (IS_ERR(new_dentry))
889 error = vfs_rename(old_dir->d_inode, old_dentry,
890 new_dir->d_inode, new_dentry);
896 @@ -1954,20 +2190,28 @@
900 -__vfs_follow_link(struct nameidata *nd, const char *link)
901 +__vfs_follow_link(struct nameidata *nd, const char *link,
902 + struct lookup_intent *it)
911 + else if (it != nd->intent)
912 + printk("it != nd->intent: tell phil@clusterfs.com\n");
914 + it->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
918 if (!walk_init_root(link, nd))
919 /* weird __emul_prefix() stuff did it */
922 - res = link_path_walk(link, nd);
923 + res = link_path_walk_it(link, nd, it);
925 if (current->link_count || res || nd->last_type!=LAST_NORM)
927 @@ -1989,7 +2233,13 @@
929 int vfs_follow_link(struct nameidata *nd, const char *link)
931 - return __vfs_follow_link(nd, link);
932 + return __vfs_follow_link(nd, link, NULL);
935 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
936 + struct lookup_intent *it)
938 + return __vfs_follow_link(nd, link, it);
941 /* get the link contents into pagecache */
942 @@ -2031,7 +2281,7 @@
944 struct page *page = NULL;
945 char *s = page_getlink(dentry, &page);
946 - int res = __vfs_follow_link(nd, s);
947 + int res = __vfs_follow_link(nd, s, NULL);
950 page_cache_release(page);
951 Index: linux/fs/namespace.c
952 ===================================================================
953 --- linux.orig/fs/namespace.c Thu Nov 28 18:53:15 2002
954 +++ linux/fs/namespace.c Wed Mar 17 13:11:25 2004
957 old_nd->dentry = mnt->mnt_mountpoint;
958 old_nd->mnt = mnt->mnt_parent;
959 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
960 mnt->mnt_parent = mnt;
961 mnt->mnt_mountpoint = mnt->mnt_root;
962 list_del_init(&mnt->mnt_child);
965 mnt->mnt_parent = mntget(nd->mnt);
966 mnt->mnt_mountpoint = dget(nd->dentry);
967 + PIN(nd->dentry, nd->mnt, 1);
968 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
969 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
970 nd->dentry->d_mounted++;
971 @@ -485,14 +487,17 @@
973 struct nameidata old_nd;
974 struct vfsmount *mnt = NULL;
975 + struct lookup_intent it = { .it_op = IT_GETATTR };
976 int err = mount_is_safe(nd);
979 if (!old_name || !*old_name)
981 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
983 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
985 + intent_release(&it);
989 down_write(¤t->namespace->sem);
994 up_write(¤t->namespace->sem);
995 + intent_release(&it);
996 path_release(&old_nd);
1000 unsigned long flags, void *data_page)
1002 struct nameidata nd;
1003 + struct lookup_intent it = { .it_op = IT_GETATTR };
1007 @@ -722,10 +729,11 @@
1008 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
1010 /* ... and get the mountpoint */
1011 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
1013 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
1015 + intent_release(&it);
1019 if (flags & MS_REMOUNT)
1020 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
1024 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
1025 dev_name, data_page);
1027 + intent_release(&it);
1033 struct vfsmount *tmp;
1034 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
1035 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
1036 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
1039 if (!capable(CAP_SYS_ADMIN))
1040 @@ -908,14 +920,14 @@
1044 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
1045 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
1049 if (!check_mnt(new_nd.mnt))
1052 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
1053 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
1057 @@ -970,8 +982,10 @@
1058 up(&old_nd.dentry->d_inode->i_zombie);
1059 up_write(¤t->namespace->sem);
1060 path_release(&user_nd);
1061 + intent_release(&old_it);
1062 path_release(&old_nd);
1064 + intent_release(&new_it);
1065 path_release(&new_nd);
1068 Index: linux/fs/open.c
1069 ===================================================================
1070 --- linux.orig/fs/open.c Thu Nov 28 18:53:15 2002
1071 +++ linux/fs/open.c Wed Mar 17 13:11:25 2004
1073 #include <asm/uaccess.h>
1075 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1076 +extern int path_walk_it(const char *name, struct nameidata *nd,
1077 + struct lookup_intent *it);
1079 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1082 write_unlock(&files->file_lock);
1085 -int do_truncate(struct dentry *dentry, loff_t length)
1086 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1088 struct inode *inode = dentry->d_inode;
1089 + struct inode_operations *op = dentry->d_inode->i_op;
1091 struct iattr newattrs;
1093 @@ -108,7 +111,13 @@
1094 down(&inode->i_sem);
1095 newattrs.ia_size = length;
1096 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1097 - error = notify_change(dentry, &newattrs);
1098 + if (called_from_open)
1099 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1100 + if (op->setattr_raw) {
1101 + newattrs.ia_valid |= ATTR_RAW;
1102 + error = op->setattr_raw(inode, &newattrs);
1104 + error = notify_change(dentry, &newattrs);
1108 @@ -118,12 +127,13 @@
1109 struct nameidata nd;
1110 struct inode * inode;
1112 + struct lookup_intent it = { .it_op = IT_GETATTR };
1115 if (length < 0) /* sorry, but loff_t says... */
1118 - error = user_path_walk(path, &nd);
1119 + error = user_path_walk_it(path, &nd, &it);
1122 inode = nd.dentry->d_inode;
1123 @@ -163,11 +173,13 @@
1124 error = locks_verify_truncate(inode, NULL, length);
1127 - error = do_truncate(nd.dentry, length);
1128 + intent_release(&it);
1129 + error = do_truncate(nd.dentry, length, 0);
1131 put_write_access(inode);
1134 + intent_release(&it);
1140 error = locks_verify_truncate(inode, file, length);
1142 - error = do_truncate(dentry, length);
1143 + error = do_truncate(dentry, length, 0);
1147 @@ -260,11 +272,13 @@
1148 struct inode * inode;
1149 struct iattr newattrs;
1151 - error = user_path_walk(filename, &nd);
1152 + error = user_path_walk_it(filename, &nd, NULL);
1155 inode = nd.dentry->d_inode;
1157 + /* this is safe without a Lustre lock because it only depends
1158 + on the super block */
1160 if (IS_RDONLY(inode))
1162 @@ -279,11 +293,25 @@
1165 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1169 + if (inode->i_op->setattr_raw) {
1170 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1172 + newattrs.ia_valid |= ATTR_RAW;
1173 + error = op->setattr_raw(inode, &newattrs);
1174 + /* the file system wants to use normal vfs path now */
1175 + if (error != -EOPNOTSUPP)
1176 + goto dput_and_out;
1181 if (current->fsuid != inode->i_uid &&
1182 (error = permission(inode,MAY_WRITE)) != 0)
1186 error = notify_change(nd.dentry, &newattrs);
1189 @@ -304,12 +332,14 @@
1190 struct inode * inode;
1191 struct iattr newattrs;
1193 - error = user_path_walk(filename, &nd);
1194 + error = user_path_walk_it(filename, &nd, NULL);
1198 inode = nd.dentry->d_inode;
1200 + /* this is safe without a Lustre lock because it only depends
1201 + on the super block */
1203 if (IS_RDONLY(inode))
1205 @@ -324,7 +354,20 @@
1206 newattrs.ia_atime = times[0].tv_sec;
1207 newattrs.ia_mtime = times[1].tv_sec;
1208 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1212 + if (inode->i_op->setattr_raw) {
1213 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1215 + newattrs.ia_valid |= ATTR_RAW;
1216 + error = op->setattr_raw(inode, &newattrs);
1217 + /* the file system wants to use normal vfs path now */
1218 + if (error != -EOPNOTSUPP)
1219 + goto dput_and_out;
1224 if (current->fsuid != inode->i_uid &&
1225 (error = permission(inode,MAY_WRITE)) != 0)
1228 int old_fsuid, old_fsgid;
1229 kernel_cap_t old_cap;
1231 + struct lookup_intent it = { .it_op = IT_GETATTR };
1233 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1235 @@ -364,13 +408,14 @@
1237 current->cap_effective = current->cap_permitted;
1239 - res = user_path_walk(filename, &nd);
1240 + res = user_path_walk_it(filename, &nd, &it);
1242 res = permission(nd.dentry->d_inode, mode);
1243 /* SuS v2 requires we report a read only fs too */
1244 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1245 && !special_file(nd.dentry->d_inode->i_mode))
1247 + intent_release(&it);
1254 struct nameidata nd;
1255 + struct lookup_intent it = { .it_op = IT_GETATTR };
1257 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1258 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1263 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1266 + intent_release(&it);
1270 @@ -436,9 +483,10 @@
1273 struct nameidata nd;
1274 + struct lookup_intent it = { .it_op = IT_GETATTR };
1276 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1277 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1278 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1279 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1283 @@ -454,39 +502,56 @@
1287 + intent_release(&it);
1293 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1294 +int chmod_common(struct dentry *dentry, mode_t mode)
1296 - struct inode * inode;
1297 - struct dentry * dentry;
1298 - struct file * file;
1300 + struct inode *inode = dentry->d_inode;
1301 struct iattr newattrs;
1306 + if (IS_RDONLY(inode))
1309 - dentry = file->f_dentry;
1310 - inode = dentry->d_inode;
1311 + if (inode->i_op->setattr_raw) {
1312 + newattrs.ia_mode = mode;
1313 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1314 + newattrs.ia_valid |= ATTR_RAW;
1315 + err = inode->i_op->setattr_raw(inode, &newattrs);
1316 + /* the file system wants to use normal vfs path now */
1317 + if (err != -EOPNOTSUPP)
1322 - if (IS_RDONLY(inode))
1325 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1329 if (mode == (mode_t) -1)
1330 mode = inode->i_mode;
1331 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1332 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1333 err = notify_change(dentry, &newattrs);
1340 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1342 + struct file * file;
1349 + err = chmod_common(file->f_dentry, mode);
1354 @@ -495,30 +560,14 @@
1355 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1357 struct nameidata nd;
1358 - struct inode * inode;
1360 - struct iattr newattrs;
1362 error = user_path_walk(filename, &nd);
1365 - inode = nd.dentry->d_inode;
1368 - if (IS_RDONLY(inode))
1369 - goto dput_and_out;
1372 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1373 - goto dput_and_out;
1374 + error = chmod_common(nd.dentry, mode);
1376 - if (mode == (mode_t) -1)
1377 - mode = inode->i_mode;
1378 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1379 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1380 - error = notify_change(nd.dentry, &newattrs);
1386 @@ -538,6 +587,20 @@
1388 if (IS_RDONLY(inode))
1391 + if (inode->i_op->setattr_raw) {
1392 + struct inode_operations *op = dentry->d_inode->i_op;
1394 + newattrs.ia_uid = user;
1395 + newattrs.ia_gid = group;
1396 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1397 + newattrs.ia_valid |= ATTR_RAW;
1398 + error = op->setattr_raw(inode, &newattrs);
1399 + /* the file system wants to use normal vfs path now */
1400 + if (error != -EOPNOTSUPP)
1405 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1409 int namei_flags, error;
1410 struct nameidata nd;
1411 + struct lookup_intent it = { .it_op = IT_OPEN };
1413 namei_flags = flags;
1414 if ((namei_flags+1) & O_ACCMODE)
1415 @@ -649,14 +713,15 @@
1416 if (namei_flags & O_TRUNC)
1419 - error = open_namei(filename, namei_flags, mode, &nd);
1421 - return dentry_open(nd.dentry, nd.mnt, flags);
1422 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1424 + return ERR_PTR(error);
1426 - return ERR_PTR(error);
1427 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1430 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1431 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1432 + int flags, struct lookup_intent *it)
1435 struct inode *inode;
1436 @@ -693,12 +758,15 @@
1439 if (f->f_op && f->f_op->open) {
1441 error = f->f_op->open(inode,f);
1446 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1448 + intent_release(it);
1452 @@ -713,11 +781,17 @@
1456 + intent_release(it);
1459 return ERR_PTR(error);
1462 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1464 + return dentry_open_it(dentry, mnt, flags, NULL);
1468 * Find an empty file descriptor entry, and mark it busy.
1470 Index: linux/fs/proc/base.c
1471 ===================================================================
1472 --- linux.orig/fs/proc/base.c Wed Mar 17 13:00:35 2004
1473 +++ linux/fs/proc/base.c Wed Mar 17 13:11:25 2004
1476 error = inode->u.proc_i.op.proc_get_link(inode, &nd->dentry, &nd->mnt);
1477 nd->last_type = LAST_BIND;
1479 + if (nd->intent != NULL)
1480 + nd->intent->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
1484 Index: linux/fs/stat.c
1485 ===================================================================
1486 --- linux.orig/fs/stat.c Thu Sep 13 19:04:43 2001
1487 +++ linux/fs/stat.c Wed Mar 17 13:12:31 2004
1489 * Revalidate the inode. This is required for proper NFS attribute caching.
1491 static __inline__ int
1492 -do_revalidate(struct dentry *dentry)
1493 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1495 struct inode * inode = dentry->d_inode;
1496 - if (inode->i_op && inode->i_op->revalidate)
1497 + if (inode->i_op && inode->i_op->revalidate_it)
1498 + return inode->i_op->revalidate_it(dentry, it);
1499 + else if (inode->i_op && inode->i_op->revalidate)
1500 return inode->i_op->revalidate(dentry);
1503 @@ -135,13 +137,15 @@
1504 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1506 struct nameidata nd;
1507 + struct lookup_intent it = { .it_op = IT_GETATTR };
1510 - error = user_path_walk(filename, &nd);
1511 + error = user_path_walk_it(filename, &nd, &it);
1513 - error = do_revalidate(nd.dentry);
1514 + error = do_revalidate(nd.dentry, &it);
1516 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1517 + intent_release(&it);
1521 @@ -151,13 +155,15 @@
1522 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1524 struct nameidata nd;
1525 + struct lookup_intent it = { .it_op = IT_GETATTR };
1528 - error = user_path_walk(filename, &nd);
1529 + error = user_path_walk_it(filename, &nd, &it);
1531 - error = do_revalidate(nd.dentry);
1532 + error = do_revalidate(nd.dentry, &it);
1534 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1535 + intent_release(&it);
1539 @@ -172,13 +178,15 @@
1540 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1542 struct nameidata nd;
1543 + struct lookup_intent it = { .it_op = IT_GETATTR };
1546 - error = user_path_walk_link(filename, &nd);
1547 + error = user_path_walk_link_it(filename, &nd, &it);
1549 - error = do_revalidate(nd.dentry);
1550 + error = do_revalidate(nd.dentry, &it);
1552 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1553 + intent_release(&it);
1557 @@ -189,13 +197,15 @@
1558 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1560 struct nameidata nd;
1561 + struct lookup_intent it = { .it_op = IT_GETATTR };
1564 - error = user_path_walk_link(filename, &nd);
1565 + error = user_path_walk_link_it(filename, &nd, &it);
1567 - error = do_revalidate(nd.dentry);
1568 + error = do_revalidate(nd.dentry, &it);
1570 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1571 + intent_release(&it);
1577 struct dentry * dentry = f->f_dentry;
1579 - err = do_revalidate(dentry);
1580 + err = do_revalidate(dentry, NULL);
1582 err = cp_old_stat(dentry->d_inode, statbuf);
1586 struct dentry * dentry = f->f_dentry;
1588 - err = do_revalidate(dentry);
1589 + err = do_revalidate(dentry, NULL);
1591 err = cp_new_stat(dentry->d_inode, statbuf);
1596 if (inode->i_op && inode->i_op->readlink &&
1597 - !(error = do_revalidate(nd.dentry))) {
1598 + !(error = do_revalidate(nd.dentry, NULL))) {
1599 UPDATE_ATIME(inode);
1600 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1602 @@ -333,12 +343,14 @@
1604 struct nameidata nd;
1606 + struct lookup_intent it = { .it_op = IT_GETATTR };
1608 - error = user_path_walk(filename, &nd);
1609 + error = user_path_walk_it(filename, &nd, &it);
1611 - error = do_revalidate(nd.dentry);
1612 + error = do_revalidate(nd.dentry, &it);
1614 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1615 + intent_release(&it);
1619 @@ -348,12 +360,14 @@
1621 struct nameidata nd;
1623 + struct lookup_intent it = { .it_op = IT_GETATTR };
1625 - error = user_path_walk_link(filename, &nd);
1626 + error = user_path_walk_link_it(filename, &nd, &it);
1628 - error = do_revalidate(nd.dentry);
1629 + error = do_revalidate(nd.dentry, &it);
1631 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1632 + intent_release(&it);
1638 struct dentry * dentry = f->f_dentry;
1640 - err = do_revalidate(dentry);
1641 + err = do_revalidate(dentry, NULL);
1643 err = cp_new_stat64(dentry->d_inode, statbuf);
1645 Index: linux/include/linux/dcache.h
1646 ===================================================================
1647 --- linux.orig/include/linux/dcache.h Thu Nov 28 18:53:15 2002
1648 +++ linux/include/linux/dcache.h Wed Mar 17 13:11:25 2004
1650 #include <asm/atomic.h>
1651 #include <linux/mount.h>
1652 #include <linux/kernel.h>
1653 +#include <linux/string.h>
1655 +#define IT_OPEN 0x0001
1656 +#define IT_CREAT 0x0002
1657 +#define IT_READDIR 0x0004
1658 +#define IT_GETATTR 0x0008
1659 +#define IT_LOOKUP 0x0010
1660 +#define IT_UNLINK 0x0020
1661 +#define IT_GETXATTR 0x0040
1662 +#define IT_EXEC 0x0080
1663 +#define IT_PIN 0x0100
1665 +#define IT_FL_LOCKED 0x0001
1666 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1668 +#define INTENT_MAGIC 0x19620323
1671 +struct lustre_intent_data {
1672 + int it_disposition;
1674 + __u64 it_lock_handle;
1679 +struct lookup_intent {
1681 + void (*it_op_release)(struct lookup_intent *);
1684 + int it_create_mode;
1686 + struct lustre_intent_data lustre;
1690 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1692 + memset(it, 0, sizeof(*it));
1693 + it->it_magic = INTENT_MAGIC;
1695 + it->it_flags = flags;
1700 * linux/include/linux/dcache.h
1702 int (*d_delete)(struct dentry *);
1703 void (*d_release)(struct dentry *);
1704 void (*d_iput)(struct dentry *, struct inode *);
1705 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1706 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1707 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1710 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1711 + de->d_op->d_pin(de, mnt, flag);
1712 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1713 + de->d_op->d_unpin(de, mnt, flag);
1716 +/* defined in fs/namei.c */
1717 +extern void intent_release(struct lookup_intent *it);
1718 +/* defined in fs/dcache.c */
1719 +extern void __d_rehash(struct dentry * entry, int lock);
1721 /* the dentry parameter passed to d_hash and d_compare is the parent
1722 * directory of the entries to be compared. It is used in case these
1723 * functions need any directory specific information for determining
1725 * s_nfsd_free_path semaphore will be down
1727 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1728 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1730 extern spinlock_t dcache_lock;
1732 Index: linux/include/linux/fs.h
1733 ===================================================================
1734 --- linux.orig/include/linux/fs.h Wed Mar 17 13:11:23 2004
1735 +++ linux/include/linux/fs.h Wed Mar 17 13:11:31 2004
1738 #define FMODE_READ 1
1739 #define FMODE_WRITE 2
1740 +#define FMODE_EXEC 4
1745 #define ATTR_MTIME_SET 256
1746 #define ATTR_FORCE 512 /* Not a change, but a change it */
1747 #define ATTR_ATTR_FLAG 1024
1748 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1749 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1750 +#define ATTR_CTIME_SET 0x2000
1753 * This is the Inode Attributes structure, used for notify_change(). It
1755 struct pipe_inode_info *i_pipe;
1756 struct block_device *i_bdev;
1757 struct char_device *i_cdev;
1758 + void *i_filterdata;
1760 unsigned long i_dnotify_mask; /* Directory notify events */
1761 struct dnotify_struct *i_dnotify; /* for directory notifications */
1764 /* needed for tty driver, and maybe others */
1766 + struct lookup_intent *f_it;
1768 /* preallocated helper kiobuf to speedup O_DIRECT */
1769 struct kiobuf *f_iobuf;
1774 + struct lookup_intent *intent;
1779 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1780 extern int vfs_rmdir(struct inode *, struct dentry *);
1781 extern int vfs_unlink(struct inode *, struct dentry *);
1782 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1783 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1784 + struct inode *new_dir, struct dentry *new_dentry);
1788 @@ -877,21 +885,32 @@
1790 struct inode_operations {
1791 int (*create) (struct inode *,struct dentry *,int);
1792 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1793 struct dentry * (*lookup) (struct inode *,struct dentry *);
1794 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1795 int (*link) (struct dentry *,struct inode *,struct dentry *);
1796 + int (*link_raw) (struct nameidata *,struct nameidata *);
1797 int (*unlink) (struct inode *,struct dentry *);
1798 + int (*unlink_raw) (struct nameidata *);
1799 int (*symlink) (struct inode *,struct dentry *,const char *);
1800 + int (*symlink_raw) (struct nameidata *,const char *);
1801 int (*mkdir) (struct inode *,struct dentry *,int);
1802 + int (*mkdir_raw) (struct nameidata *,int);
1803 int (*rmdir) (struct inode *,struct dentry *);
1804 + int (*rmdir_raw) (struct nameidata *);
1805 int (*mknod) (struct inode *,struct dentry *,int,int);
1806 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1807 int (*rename) (struct inode *, struct dentry *,
1808 struct inode *, struct dentry *);
1809 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1810 int (*readlink) (struct dentry *, char *,int);
1811 int (*follow_link) (struct dentry *, struct nameidata *);
1812 void (*truncate) (struct inode *);
1813 int (*permission) (struct inode *, int);
1814 int (*revalidate) (struct dentry *);
1815 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1816 int (*setattr) (struct dentry *, struct iattr *);
1817 + int (*setattr_raw) (struct inode *, struct iattr *);
1818 int (*getattr) (struct dentry *, struct iattr *);
1819 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
1820 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1821 @@ -1088,10 +1107,14 @@
1823 asmlinkage long sys_open(const char *, int, int);
1824 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1825 -extern int do_truncate(struct dentry *, loff_t start);
1826 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1828 extern struct file *filp_open(const char *, int, int);
1829 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1830 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1831 + struct nameidata *nd, struct lookup_intent *it);
1832 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1833 + int flags, struct lookup_intent *it);
1834 extern int filp_close(struct file *, fl_owner_t id);
1835 extern char * getname(const char *);
1837 @@ -1354,6 +1377,7 @@
1838 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1840 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1841 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1842 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1843 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1844 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1845 @@ -1365,6 +1389,8 @@
1846 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1847 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1848 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1849 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1850 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1852 extern void inode_init_once(struct inode *);
1853 extern void _inode_init_once(struct inode *);
1854 @@ -1503,6 +1529,8 @@
1856 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1857 extern int vfs_follow_link(struct nameidata *, const char *);
1858 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1859 + struct lookup_intent *it);
1860 extern int page_readlink(struct dentry *, char *, int);
1861 extern int page_follow_link(struct dentry *, struct nameidata *);
1862 extern struct inode_operations page_symlink_inode_operations;
1863 Index: linux/include/linux/fs_struct.h
1864 ===================================================================
1865 --- linux.orig/include/linux/fs_struct.h Fri Jul 13 18:10:44 2001
1866 +++ linux/include/linux/fs_struct.h Wed Mar 17 13:11:25 2004
1868 write_lock(&fs->lock);
1869 old_root = fs->root;
1870 old_rootmnt = fs->rootmnt;
1871 + PIN(dentry, mnt, 1);
1872 fs->rootmnt = mntget(mnt);
1873 fs->root = dget(dentry);
1874 write_unlock(&fs->lock);
1876 + UNPIN(old_root, old_rootmnt, 1);
1878 mntput(old_rootmnt);
1881 write_lock(&fs->lock);
1883 old_pwdmnt = fs->pwdmnt;
1884 + PIN(dentry, mnt, 0);
1885 fs->pwdmnt = mntget(mnt);
1886 fs->pwd = dget(dentry);
1887 write_unlock(&fs->lock);
1889 + UNPIN(old_pwd, old_pwdmnt, 0);
1893 Index: linux/kernel/exit.c
1894 ===================================================================
1895 --- linux.orig/kernel/exit.c Wed Mar 17 13:00:38 2004
1896 +++ linux/kernel/exit.c Wed Mar 17 13:11:25 2004
1897 @@ -239,11 +239,14 @@
1899 /* No need to hold fs->lock if we are killing it */
1900 if (atomic_dec_and_test(&fs->count)) {
1901 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1902 + UNPIN(fs->root, fs->rootmnt, 1);
1904 mntput(fs->rootmnt);
1908 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1910 mntput(fs->altrootmnt);
1912 Index: linux/kernel/fork.c
1913 ===================================================================
1914 --- linux.orig/kernel/fork.c Wed Mar 17 13:00:38 2004
1915 +++ linux/kernel/fork.c Wed Mar 17 13:11:25 2004
1916 @@ -387,10 +387,13 @@
1917 fs->umask = old->umask;
1918 read_lock(&old->lock);
1919 fs->rootmnt = mntget(old->rootmnt);
1920 + PIN(old->pwd, old->pwdmnt, 0);
1921 + PIN(old->root, old->rootmnt, 1);
1922 fs->root = dget(old->root);
1923 fs->pwdmnt = mntget(old->pwdmnt);
1924 fs->pwd = dget(old->pwd);
1926 + PIN(old->altroot, old->altrootmnt, 1);
1927 fs->altrootmnt = mntget(old->altrootmnt);
1928 fs->altroot = dget(old->altroot);
1930 Index: linux/kernel/ksyms.c
1931 ===================================================================
1932 --- linux.orig/kernel/ksyms.c Wed Mar 17 13:11:23 2004
1933 +++ linux/kernel/ksyms.c Wed Mar 17 13:11:25 2004
1935 EXPORT_SYMBOL(set_page_dirty);
1936 EXPORT_SYMBOL(vfs_readlink);
1937 EXPORT_SYMBOL(vfs_follow_link);
1938 +EXPORT_SYMBOL(vfs_follow_link_it);
1939 EXPORT_SYMBOL(page_readlink);
1940 EXPORT_SYMBOL(page_follow_link);
1941 EXPORT_SYMBOL(page_symlink_inode_operations);