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);
375 + err = PTR_ERR(new);
378 + d_invalidate(dentry);
382 + if (!nd->dentry->d_inode)
384 + if (lookup_flags & LOOKUP_DIRECTORY) {
386 + if (!nd->dentry->d_inode->i_op ||
387 + (!nd->dentry->d_inode->i_op->lookup &&
388 + !nd->dentry->d_inode->i_op->lookup_it))
392 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
394 if (!dentry->d_op->d_revalidate(dentry, 0)) {
395 @@ -646,15 +721,28 @@
400 + intent_release(it);
406 +int link_path_walk(const char * name, struct nameidata *nd)
408 + return link_path_walk_it(name, nd, NULL);
411 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
413 + current->total_link_count = 0;
414 + return link_path_walk_it(name, nd, it);
417 int path_walk(const char * name, struct nameidata *nd)
419 current->total_link_count = 0;
420 - return link_path_walk(name, nd);
421 + return link_path_walk_it(name, nd, NULL);
429 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
430 + struct lookup_intent *it)
433 + if (path_init(path, flags, nd))
434 + error = path_walk_it(path, nd, it);
440 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
445 nd->last_type = LAST_ROOT; /* if there are only slashes... */
449 return walk_init_root(name,nd);
450 read_lock(¤t->fs->lock);
452 * needs parent already locked. Doesn't follow mounts.
455 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
456 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
457 + struct lookup_intent *it)
459 struct dentry * dentry;
461 @@ -790,13 +891,16 @@
465 - dentry = cached_lookup(base, name, 0);
466 + dentry = cached_lookup(base, name, 0, it);
468 struct dentry *new = d_alloc(base, name);
469 dentry = ERR_PTR(-ENOMEM);
473 + if (inode->i_op->lookup_it)
474 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
476 dentry = inode->i_op->lookup(inode, new);
483 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
485 + return lookup_hash_it(name, base, NULL);
490 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
494 this.hash = end_name_hash(hash);
496 - return lookup_hash(&this, base);
497 + return lookup_hash_it(&this, base, NULL);
499 return ERR_PTR(-EACCES);
505 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
506 + struct lookup_intent *it)
511 + tmp = getname(name);
512 + err = PTR_ERR(tmp);
513 + if (!IS_ERR(tmp)) {
515 + if (path_init(tmp, flags, nd))
516 + err = path_walk_it(tmp, nd, it);
523 * It's inline, so penalty for filesystems that don't use sticky bit is
529 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
530 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
531 + struct lookup_intent *it)
535 @@ -968,12 +1096,15 @@
538 error = -EACCES; /* shouldn't it be ENOSYS? */
539 - if (!dir->i_op || !dir->i_op->create)
540 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
545 - error = dir->i_op->create(dir, dentry, mode);
546 + if (dir->i_op->create_it)
547 + error = dir->i_op->create_it(dir, dentry, mode, it);
549 + error = dir->i_op->create(dir, dentry, mode);
553 @@ -982,6 +1113,11 @@
557 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
559 + return vfs_create_it(dir, dentry, mode, NULL);
566 * for symlinks (where the permissions are checked later).
569 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
570 +int open_namei_it(const char *pathname, int flag, int mode,
571 + struct nameidata *nd, struct lookup_intent *it)
573 int acc_mode, error = 0;
575 @@ -1006,11 +1143,14 @@
577 acc_mode = ACC_MODE(flag);
580 + it->it_flags = flag;
583 * The simplest case - just a plain lookup.
585 if (!(flag & O_CREAT)) {
586 - error = path_lookup(pathname, lookup_flags(flag), nd);
587 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
591 @@ -1020,6 +1160,10 @@
593 * Create - we need to know the parent.
596 + it->it_create_mode = mode;
597 + it->it_op |= IT_CREAT;
599 error = path_lookup(pathname, LOOKUP_PARENT, nd);
602 @@ -1035,7 +1179,7 @@
605 down(&dir->d_inode->i_sem);
606 - dentry = lookup_hash(&nd->last, nd->dentry);
607 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
610 error = PTR_ERR(dentry);
611 @@ -1044,11 +1188,12 @@
615 + it->it_create_mode = mode;
616 /* Negative dentry, just create the file */
617 if (!dentry->d_inode) {
618 if (!IS_POSIXACL(dir->d_inode))
619 mode &= ~current->fs->umask;
620 - error = vfs_create(dir->d_inode, dentry, mode);
621 + error = vfs_create_it(dir->d_inode, dentry, mode, it);
622 up(&dir->d_inode->i_sem);
625 @@ -1073,7 +1218,7 @@
627 if (flag & O_NOFOLLOW)
629 - while (__follow_down(&nd->mnt,&dentry) && d_mountpoint(dentry));
630 + while (__follow_down(&nd->mnt,&dentry,it) && d_mountpoint(dentry));
633 if (!dentry->d_inode)
634 @@ -1152,7 +1297,7 @@
638 - error = do_truncate(dentry, 0);
639 + error = do_truncate(dentry, 0, 1);
641 put_write_access(inode);
643 @@ -1164,8 +1309,10 @@
647 + intent_release(it);
650 + intent_release(it);
654 @@ -1184,7 +1331,16 @@
655 * are done. Procfs-like symlinks just set LAST_BIND.
657 UPDATE_ATIME(dentry->d_inode);
659 error = dentry->d_inode->i_op->follow_link(dentry, nd);
661 + intent_release(it);
662 + } else if (it != NULL && !(it->d.lustre.it_int_flags & IT_FL_FOLLOWED)) {
663 + /* vfs_follow_link was never called */
664 + intent_release(it);
671 @@ -1206,13 +1362,20 @@
674 down(&dir->d_inode->i_sem);
675 - dentry = lookup_hash(&nd->last, nd->dentry);
676 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
677 putname(nd->last.name);
681 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
683 + return open_namei_it(pathname, flag, mode, nd, NULL);
688 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
689 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
690 + struct lookup_intent *it)
692 struct dentry *dentry;
694 @@ -1220,7 +1383,7 @@
695 dentry = ERR_PTR(-EEXIST);
696 if (nd->last_type != LAST_NORM)
698 - dentry = lookup_hash(&nd->last, nd->dentry);
699 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
702 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
703 @@ -1276,7 +1439,20 @@
704 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
707 - dentry = lookup_create(&nd, 0);
709 + if (nd.last_type != LAST_NORM) {
713 + if (nd.dentry->d_inode->i_op->mknod_raw) {
714 + struct inode_operations *op = nd.dentry->d_inode->i_op;
715 + error = op->mknod_raw(&nd, mode, dev);
716 + /* the file system wants to use normal vfs path now */
717 + if (error != -EOPNOTSUPP)
721 + dentry = lookup_create(&nd, 0, NULL);
722 error = PTR_ERR(dentry);
724 if (!IS_POSIXACL(nd.dentry->d_inode))
725 @@ -1298,6 +1474,7 @@
728 up(&nd.dentry->d_inode->i_sem);
733 @@ -1345,7 +1522,18 @@
734 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
737 - dentry = lookup_create(&nd, 1);
738 + if (nd.last_type != LAST_NORM) {
742 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
743 + struct inode_operations *op = nd.dentry->d_inode->i_op;
744 + error = op->mkdir_raw(&nd, mode);
745 + /* the file system wants to use normal vfs path now */
746 + if (error != -EOPNOTSUPP)
749 + dentry = lookup_create(&nd, 1, NULL);
750 error = PTR_ERR(dentry);
751 if (!IS_ERR(dentry)) {
752 if (!IS_POSIXACL(nd.dentry->d_inode))
753 @@ -1354,6 +1542,7 @@
756 up(&nd.dentry->d_inode->i_sem);
761 @@ -1454,8 +1643,16 @@
765 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
766 + struct inode_operations *op = nd.dentry->d_inode->i_op;
768 + error = op->rmdir_raw(&nd);
769 + /* the file system wants to use normal vfs path now */
770 + if (error != -EOPNOTSUPP)
773 down(&nd.dentry->d_inode->i_sem);
774 - dentry = lookup_hash(&nd.last, nd.dentry);
775 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
776 error = PTR_ERR(dentry);
777 if (!IS_ERR(dentry)) {
778 error = vfs_rmdir(nd.dentry->d_inode, dentry);
779 @@ -1513,8 +1710,15 @@
781 if (nd.last_type != LAST_NORM)
783 + if (nd.dentry->d_inode->i_op->unlink_raw) {
784 + struct inode_operations *op = nd.dentry->d_inode->i_op;
785 + error = op->unlink_raw(&nd);
786 + /* the file system wants to use normal vfs path now */
787 + if (error != -EOPNOTSUPP)
790 down(&nd.dentry->d_inode->i_sem);
791 - dentry = lookup_hash(&nd.last, nd.dentry);
792 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
793 error = PTR_ERR(dentry);
794 if (!IS_ERR(dentry)) {
795 /* Why not before? Because we want correct error value */
796 @@ -1581,15 +1785,27 @@
797 error = path_lookup(to, LOOKUP_PARENT, &nd);
800 - dentry = lookup_create(&nd, 0);
801 + if (nd.last_type != LAST_NORM) {
805 + if (nd.dentry->d_inode->i_op->symlink_raw) {
806 + struct inode_operations *op = nd.dentry->d_inode->i_op;
807 + error = op->symlink_raw(&nd, from);
808 + /* the file system wants to use normal vfs path now */
809 + if (error != -EOPNOTSUPP)
812 + dentry = lookup_create(&nd, 0, NULL);
813 error = PTR_ERR(dentry);
814 if (!IS_ERR(dentry)) {
815 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
818 up(&nd.dentry->d_inode->i_sem);
826 @@ -1665,7 +1881,18 @@
828 if (old_nd.mnt != nd.mnt)
830 - new_dentry = lookup_create(&nd, 0);
831 + if (nd.last_type != LAST_NORM) {
835 + if (nd.dentry->d_inode->i_op->link_raw) {
836 + struct inode_operations *op = nd.dentry->d_inode->i_op;
837 + error = op->link_raw(&old_nd, &nd);
838 + /* the file system wants to use normal vfs path now */
839 + if (error != -EOPNOTSUPP)
842 + new_dentry = lookup_create(&nd, 0, NULL);
843 error = PTR_ERR(new_dentry);
844 if (!IS_ERR(new_dentry)) {
845 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
846 @@ -1709,7 +1936,7 @@
849 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
850 - struct inode *new_dir, struct dentry *new_dentry)
851 + struct inode *new_dir, struct dentry *new_dentry)
854 struct inode *target;
855 @@ -1788,7 +2015,7 @@
858 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
859 - struct inode *new_dir, struct dentry *new_dentry)
860 + struct inode *new_dir, struct dentry *new_dentry)
864 @@ -1876,9 +2103,18 @@
865 if (newnd.last_type != LAST_NORM)
868 + if (old_dir->d_inode->i_op->rename_raw) {
870 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
872 + /* the file system wants to use normal vfs path now */
873 + if (error != -EOPNOTSUPP)
877 double_lock(new_dir, old_dir);
879 - old_dentry = lookup_hash(&oldnd.last, old_dir);
880 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
881 error = PTR_ERR(old_dentry);
882 if (IS_ERR(old_dentry))
884 @@ -1894,16 +2130,16 @@
885 if (newnd.last.name[newnd.last.len])
888 - new_dentry = lookup_hash(&newnd.last, new_dir);
889 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
890 error = PTR_ERR(new_dentry);
891 if (IS_ERR(new_dentry))
896 error = vfs_rename(old_dir->d_inode, old_dentry,
897 new_dir->d_inode, new_dentry);
903 @@ -1954,20 +2190,28 @@
907 -__vfs_follow_link(struct nameidata *nd, const char *link)
908 +__vfs_follow_link(struct nameidata *nd, const char *link,
909 + struct lookup_intent *it)
918 + else if (it != nd->intent)
919 + printk("it != nd->intent: tell phil@clusterfs.com\n");
921 + it->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
925 if (!walk_init_root(link, nd))
926 /* weird __emul_prefix() stuff did it */
929 - res = link_path_walk(link, nd);
930 + res = link_path_walk_it(link, nd, it);
932 if (current->link_count || res || nd->last_type!=LAST_NORM)
934 @@ -1989,7 +2233,13 @@
936 int vfs_follow_link(struct nameidata *nd, const char *link)
938 - return __vfs_follow_link(nd, link);
939 + return __vfs_follow_link(nd, link, NULL);
942 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
943 + struct lookup_intent *it)
945 + return __vfs_follow_link(nd, link, it);
948 /* get the link contents into pagecache */
949 @@ -2031,7 +2281,7 @@
951 struct page *page = NULL;
952 char *s = page_getlink(dentry, &page);
953 - int res = __vfs_follow_link(nd, s);
954 + int res = __vfs_follow_link(nd, s, NULL);
957 page_cache_release(page);
958 Index: linux/fs/namespace.c
959 ===================================================================
960 --- linux.orig/fs/namespace.c Thu Nov 28 18:53:15 2002
961 +++ linux/fs/namespace.c Wed Mar 17 13:11:25 2004
964 old_nd->dentry = mnt->mnt_mountpoint;
965 old_nd->mnt = mnt->mnt_parent;
966 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
967 mnt->mnt_parent = mnt;
968 mnt->mnt_mountpoint = mnt->mnt_root;
969 list_del_init(&mnt->mnt_child);
972 mnt->mnt_parent = mntget(nd->mnt);
973 mnt->mnt_mountpoint = dget(nd->dentry);
974 + PIN(nd->dentry, nd->mnt, 1);
975 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
976 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
977 nd->dentry->d_mounted++;
978 @@ -485,14 +487,17 @@
980 struct nameidata old_nd;
981 struct vfsmount *mnt = NULL;
982 + struct lookup_intent it = { .it_op = IT_GETATTR };
983 int err = mount_is_safe(nd);
986 if (!old_name || !*old_name)
988 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
990 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
992 + intent_release(&it);
996 down_write(¤t->namespace->sem);
1001 up_write(¤t->namespace->sem);
1002 + intent_release(&it);
1003 path_release(&old_nd);
1007 unsigned long flags, void *data_page)
1009 struct nameidata nd;
1010 + struct lookup_intent it = { .it_op = IT_GETATTR };
1014 @@ -722,10 +729,11 @@
1015 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
1017 /* ... and get the mountpoint */
1018 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
1020 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
1022 + intent_release(&it);
1026 if (flags & MS_REMOUNT)
1027 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
1031 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
1032 dev_name, data_page);
1034 + intent_release(&it);
1040 struct vfsmount *tmp;
1041 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
1042 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
1043 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
1046 if (!capable(CAP_SYS_ADMIN))
1047 @@ -908,14 +920,14 @@
1051 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
1052 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
1056 if (!check_mnt(new_nd.mnt))
1059 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
1060 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
1064 @@ -970,8 +982,10 @@
1065 up(&old_nd.dentry->d_inode->i_zombie);
1066 up_write(¤t->namespace->sem);
1067 path_release(&user_nd);
1068 + intent_release(&old_it);
1069 path_release(&old_nd);
1071 + intent_release(&new_it);
1072 path_release(&new_nd);
1075 Index: linux/fs/open.c
1076 ===================================================================
1077 --- linux.orig/fs/open.c Thu Nov 28 18:53:15 2002
1078 +++ linux/fs/open.c Wed Mar 17 13:11:25 2004
1080 #include <asm/uaccess.h>
1082 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1083 +extern int path_walk_it(const char *name, struct nameidata *nd,
1084 + struct lookup_intent *it);
1086 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1089 write_unlock(&files->file_lock);
1092 -int do_truncate(struct dentry *dentry, loff_t length)
1093 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1095 struct inode *inode = dentry->d_inode;
1096 + struct inode_operations *op = dentry->d_inode->i_op;
1098 struct iattr newattrs;
1100 @@ -108,7 +111,13 @@
1101 down(&inode->i_sem);
1102 newattrs.ia_size = length;
1103 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1104 - error = notify_change(dentry, &newattrs);
1105 + if (called_from_open)
1106 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1107 + if (op->setattr_raw) {
1108 + newattrs.ia_valid |= ATTR_RAW;
1109 + error = op->setattr_raw(inode, &newattrs);
1111 + error = notify_change(dentry, &newattrs);
1115 @@ -118,12 +127,13 @@
1116 struct nameidata nd;
1117 struct inode * inode;
1119 + struct lookup_intent it = { .it_op = IT_GETATTR };
1122 if (length < 0) /* sorry, but loff_t says... */
1125 - error = user_path_walk(path, &nd);
1126 + error = user_path_walk_it(path, &nd, &it);
1129 inode = nd.dentry->d_inode;
1130 @@ -163,11 +173,13 @@
1131 error = locks_verify_truncate(inode, NULL, length);
1134 - error = do_truncate(nd.dentry, length);
1135 + intent_release(&it);
1136 + error = do_truncate(nd.dentry, length, 0);
1138 put_write_access(inode);
1141 + intent_release(&it);
1147 error = locks_verify_truncate(inode, file, length);
1149 - error = do_truncate(dentry, length);
1150 + error = do_truncate(dentry, length, 0);
1154 @@ -260,11 +272,13 @@
1155 struct inode * inode;
1156 struct iattr newattrs;
1158 - error = user_path_walk(filename, &nd);
1159 + error = user_path_walk_it(filename, &nd, NULL);
1162 inode = nd.dentry->d_inode;
1164 + /* this is safe without a Lustre lock because it only depends
1165 + on the super block */
1167 if (IS_RDONLY(inode))
1169 @@ -279,11 +293,25 @@
1172 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1176 + if (inode->i_op->setattr_raw) {
1177 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1179 + newattrs.ia_valid |= ATTR_RAW;
1180 + error = op->setattr_raw(inode, &newattrs);
1181 + /* the file system wants to use normal vfs path now */
1182 + if (error != -EOPNOTSUPP)
1183 + goto dput_and_out;
1188 if (current->fsuid != inode->i_uid &&
1189 (error = permission(inode,MAY_WRITE)) != 0)
1193 error = notify_change(nd.dentry, &newattrs);
1196 @@ -304,12 +332,14 @@
1197 struct inode * inode;
1198 struct iattr newattrs;
1200 - error = user_path_walk(filename, &nd);
1201 + error = user_path_walk_it(filename, &nd, NULL);
1205 inode = nd.dentry->d_inode;
1207 + /* this is safe without a Lustre lock because it only depends
1208 + on the super block */
1210 if (IS_RDONLY(inode))
1212 @@ -324,7 +354,20 @@
1213 newattrs.ia_atime = times[0].tv_sec;
1214 newattrs.ia_mtime = times[1].tv_sec;
1215 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1219 + if (inode->i_op->setattr_raw) {
1220 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1222 + newattrs.ia_valid |= ATTR_RAW;
1223 + error = op->setattr_raw(inode, &newattrs);
1224 + /* the file system wants to use normal vfs path now */
1225 + if (error != -EOPNOTSUPP)
1226 + goto dput_and_out;
1231 if (current->fsuid != inode->i_uid &&
1232 (error = permission(inode,MAY_WRITE)) != 0)
1235 int old_fsuid, old_fsgid;
1236 kernel_cap_t old_cap;
1238 + struct lookup_intent it = { .it_op = IT_GETATTR };
1240 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1242 @@ -364,13 +408,14 @@
1244 current->cap_effective = current->cap_permitted;
1246 - res = user_path_walk(filename, &nd);
1247 + res = user_path_walk_it(filename, &nd, &it);
1249 res = permission(nd.dentry->d_inode, mode);
1250 /* SuS v2 requires we report a read only fs too */
1251 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1252 && !special_file(nd.dentry->d_inode->i_mode))
1254 + intent_release(&it);
1261 struct nameidata nd;
1262 + struct lookup_intent it = { .it_op = IT_GETATTR };
1264 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1265 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1270 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1273 + intent_release(&it);
1277 @@ -436,9 +483,10 @@
1280 struct nameidata nd;
1281 + struct lookup_intent it = { .it_op = IT_GETATTR };
1283 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1284 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1285 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1286 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1290 @@ -454,39 +502,56 @@
1294 + intent_release(&it);
1300 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1301 +int chmod_common(struct dentry *dentry, mode_t mode)
1303 - struct inode * inode;
1304 - struct dentry * dentry;
1305 - struct file * file;
1307 + struct inode *inode = dentry->d_inode;
1308 struct iattr newattrs;
1313 + if (IS_RDONLY(inode))
1316 - dentry = file->f_dentry;
1317 - inode = dentry->d_inode;
1318 + if (inode->i_op->setattr_raw) {
1319 + newattrs.ia_mode = mode;
1320 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1321 + newattrs.ia_valid |= ATTR_RAW;
1322 + err = inode->i_op->setattr_raw(inode, &newattrs);
1323 + /* the file system wants to use normal vfs path now */
1324 + if (err != -EOPNOTSUPP)
1329 - if (IS_RDONLY(inode))
1332 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1336 if (mode == (mode_t) -1)
1337 mode = inode->i_mode;
1338 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1339 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1340 err = notify_change(dentry, &newattrs);
1347 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1349 + struct file * file;
1356 + err = chmod_common(file->f_dentry, mode);
1361 @@ -495,30 +560,14 @@
1362 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1364 struct nameidata nd;
1365 - struct inode * inode;
1367 - struct iattr newattrs;
1369 error = user_path_walk(filename, &nd);
1372 - inode = nd.dentry->d_inode;
1375 - if (IS_RDONLY(inode))
1376 - goto dput_and_out;
1379 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1380 - goto dput_and_out;
1381 + error = chmod_common(nd.dentry, mode);
1383 - if (mode == (mode_t) -1)
1384 - mode = inode->i_mode;
1385 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1386 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1387 - error = notify_change(nd.dentry, &newattrs);
1393 @@ -538,6 +587,20 @@
1395 if (IS_RDONLY(inode))
1398 + if (inode->i_op->setattr_raw) {
1399 + struct inode_operations *op = dentry->d_inode->i_op;
1401 + newattrs.ia_uid = user;
1402 + newattrs.ia_gid = group;
1403 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1404 + newattrs.ia_valid |= ATTR_RAW;
1405 + error = op->setattr_raw(inode, &newattrs);
1406 + /* the file system wants to use normal vfs path now */
1407 + if (error != -EOPNOTSUPP)
1412 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1416 int namei_flags, error;
1417 struct nameidata nd;
1418 + struct lookup_intent it = { .it_op = IT_OPEN };
1420 namei_flags = flags;
1421 if ((namei_flags+1) & O_ACCMODE)
1422 @@ -649,14 +713,15 @@
1423 if (namei_flags & O_TRUNC)
1426 - error = open_namei(filename, namei_flags, mode, &nd);
1428 - return dentry_open(nd.dentry, nd.mnt, flags);
1429 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1431 + return ERR_PTR(error);
1433 - return ERR_PTR(error);
1434 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1437 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1438 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1439 + int flags, struct lookup_intent *it)
1442 struct inode *inode;
1443 @@ -693,12 +758,15 @@
1446 if (f->f_op && f->f_op->open) {
1448 error = f->f_op->open(inode,f);
1453 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1455 + intent_release(it);
1459 @@ -713,11 +781,17 @@
1463 + intent_release(it);
1466 return ERR_PTR(error);
1469 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1471 + return dentry_open_it(dentry, mnt, flags, NULL);
1475 * Find an empty file descriptor entry, and mark it busy.
1477 Index: linux/fs/proc/base.c
1478 ===================================================================
1479 --- linux.orig/fs/proc/base.c Wed Mar 17 13:00:35 2004
1480 +++ linux/fs/proc/base.c Wed Mar 17 13:11:25 2004
1483 error = inode->u.proc_i.op.proc_get_link(inode, &nd->dentry, &nd->mnt);
1484 nd->last_type = LAST_BIND;
1486 + if (nd->intent != NULL)
1487 + nd->intent->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
1491 Index: linux/fs/stat.c
1492 ===================================================================
1493 --- linux.orig/fs/stat.c Thu Sep 13 19:04:43 2001
1494 +++ linux/fs/stat.c Wed Mar 17 13:12:31 2004
1496 * Revalidate the inode. This is required for proper NFS attribute caching.
1498 static __inline__ int
1499 -do_revalidate(struct dentry *dentry)
1500 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1502 struct inode * inode = dentry->d_inode;
1503 - if (inode->i_op && inode->i_op->revalidate)
1504 + if (inode->i_op && inode->i_op->revalidate_it)
1505 + return inode->i_op->revalidate_it(dentry, it);
1506 + else if (inode->i_op && inode->i_op->revalidate)
1507 return inode->i_op->revalidate(dentry);
1510 @@ -135,13 +137,15 @@
1511 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1513 struct nameidata nd;
1514 + struct lookup_intent it = { .it_op = IT_GETATTR };
1517 - error = user_path_walk(filename, &nd);
1518 + error = user_path_walk_it(filename, &nd, &it);
1520 - error = do_revalidate(nd.dentry);
1521 + error = do_revalidate(nd.dentry, &it);
1523 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1524 + intent_release(&it);
1528 @@ -151,13 +155,15 @@
1529 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1531 struct nameidata nd;
1532 + struct lookup_intent it = { .it_op = IT_GETATTR };
1535 - error = user_path_walk(filename, &nd);
1536 + error = user_path_walk_it(filename, &nd, &it);
1538 - error = do_revalidate(nd.dentry);
1539 + error = do_revalidate(nd.dentry, &it);
1541 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1542 + intent_release(&it);
1546 @@ -172,13 +178,15 @@
1547 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1549 struct nameidata nd;
1550 + struct lookup_intent it = { .it_op = IT_GETATTR };
1553 - error = user_path_walk_link(filename, &nd);
1554 + error = user_path_walk_link_it(filename, &nd, &it);
1556 - error = do_revalidate(nd.dentry);
1557 + error = do_revalidate(nd.dentry, &it);
1559 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1560 + intent_release(&it);
1564 @@ -189,13 +197,15 @@
1565 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1567 struct nameidata nd;
1568 + struct lookup_intent it = { .it_op = IT_GETATTR };
1571 - error = user_path_walk_link(filename, &nd);
1572 + error = user_path_walk_link_it(filename, &nd, &it);
1574 - error = do_revalidate(nd.dentry);
1575 + error = do_revalidate(nd.dentry, &it);
1577 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1578 + intent_release(&it);
1584 struct dentry * dentry = f->f_dentry;
1586 - err = do_revalidate(dentry);
1587 + err = do_revalidate(dentry, NULL);
1589 err = cp_old_stat(dentry->d_inode, statbuf);
1593 struct dentry * dentry = f->f_dentry;
1595 - err = do_revalidate(dentry);
1596 + err = do_revalidate(dentry, NULL);
1598 err = cp_new_stat(dentry->d_inode, statbuf);
1603 if (inode->i_op && inode->i_op->readlink &&
1604 - !(error = do_revalidate(nd.dentry))) {
1605 + !(error = do_revalidate(nd.dentry, NULL))) {
1606 UPDATE_ATIME(inode);
1607 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1609 @@ -333,12 +343,14 @@
1611 struct nameidata nd;
1613 + struct lookup_intent it = { .it_op = IT_GETATTR };
1615 - error = user_path_walk(filename, &nd);
1616 + error = user_path_walk_it(filename, &nd, &it);
1618 - error = do_revalidate(nd.dentry);
1619 + error = do_revalidate(nd.dentry, &it);
1621 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1622 + intent_release(&it);
1626 @@ -348,12 +360,14 @@
1628 struct nameidata nd;
1630 + struct lookup_intent it = { .it_op = IT_GETATTR };
1632 - error = user_path_walk_link(filename, &nd);
1633 + error = user_path_walk_link_it(filename, &nd, &it);
1635 - error = do_revalidate(nd.dentry);
1636 + error = do_revalidate(nd.dentry, &it);
1638 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1639 + intent_release(&it);
1645 struct dentry * dentry = f->f_dentry;
1647 - err = do_revalidate(dentry);
1648 + err = do_revalidate(dentry, NULL);
1650 err = cp_new_stat64(dentry->d_inode, statbuf);
1652 Index: linux/include/linux/dcache.h
1653 ===================================================================
1654 --- linux.orig/include/linux/dcache.h Thu Nov 28 18:53:15 2002
1655 +++ linux/include/linux/dcache.h Wed Mar 17 13:11:25 2004
1657 #include <asm/atomic.h>
1658 #include <linux/mount.h>
1659 #include <linux/kernel.h>
1660 +#include <linux/string.h>
1662 +#define IT_OPEN 0x0001
1663 +#define IT_CREAT 0x0002
1664 +#define IT_READDIR 0x0004
1665 +#define IT_GETATTR 0x0008
1666 +#define IT_LOOKUP 0x0010
1667 +#define IT_UNLINK 0x0020
1668 +#define IT_GETXATTR 0x0040
1669 +#define IT_EXEC 0x0080
1670 +#define IT_PIN 0x0100
1672 +#define IT_FL_LOCKED 0x0001
1673 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1675 +#define INTENT_MAGIC 0x19620323
1678 +struct lustre_intent_data {
1679 + int it_disposition;
1681 + __u64 it_lock_handle;
1686 +struct lookup_intent {
1688 + void (*it_op_release)(struct lookup_intent *);
1691 + int it_create_mode;
1693 + struct lustre_intent_data lustre;
1697 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1699 + memset(it, 0, sizeof(*it));
1700 + it->it_magic = INTENT_MAGIC;
1702 + it->it_flags = flags;
1707 * linux/include/linux/dcache.h
1709 int (*d_delete)(struct dentry *);
1710 void (*d_release)(struct dentry *);
1711 void (*d_iput)(struct dentry *, struct inode *);
1712 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1713 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1714 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1717 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1718 + de->d_op->d_pin(de, mnt, flag);
1719 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1720 + de->d_op->d_unpin(de, mnt, flag);
1723 +/* defined in fs/namei.c */
1724 +extern void intent_release(struct lookup_intent *it);
1725 +/* defined in fs/dcache.c */
1726 +extern void __d_rehash(struct dentry * entry, int lock);
1728 /* the dentry parameter passed to d_hash and d_compare is the parent
1729 * directory of the entries to be compared. It is used in case these
1730 * functions need any directory specific information for determining
1732 * s_nfsd_free_path semaphore will be down
1734 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1735 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1737 extern spinlock_t dcache_lock;
1739 Index: linux/include/linux/fs.h
1740 ===================================================================
1741 --- linux.orig/include/linux/fs.h Wed Mar 17 13:11:23 2004
1742 +++ linux/include/linux/fs.h Wed Mar 17 13:11:31 2004
1745 #define FMODE_READ 1
1746 #define FMODE_WRITE 2
1747 +#define FMODE_EXEC 4
1752 #define ATTR_MTIME_SET 256
1753 #define ATTR_FORCE 512 /* Not a change, but a change it */
1754 #define ATTR_ATTR_FLAG 1024
1755 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1756 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1757 +#define ATTR_CTIME_SET 0x2000
1760 * This is the Inode Attributes structure, used for notify_change(). It
1762 struct pipe_inode_info *i_pipe;
1763 struct block_device *i_bdev;
1764 struct char_device *i_cdev;
1765 + void *i_filterdata;
1767 unsigned long i_dnotify_mask; /* Directory notify events */
1768 struct dnotify_struct *i_dnotify; /* for directory notifications */
1771 /* needed for tty driver, and maybe others */
1773 + struct lookup_intent *f_it;
1775 /* preallocated helper kiobuf to speedup O_DIRECT */
1776 struct kiobuf *f_iobuf;
1781 + struct lookup_intent *intent;
1786 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1787 extern int vfs_rmdir(struct inode *, struct dentry *);
1788 extern int vfs_unlink(struct inode *, struct dentry *);
1789 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1790 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1791 + struct inode *new_dir, struct dentry *new_dentry);
1795 @@ -877,21 +885,32 @@
1797 struct inode_operations {
1798 int (*create) (struct inode *,struct dentry *,int);
1799 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1800 struct dentry * (*lookup) (struct inode *,struct dentry *);
1801 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1802 int (*link) (struct dentry *,struct inode *,struct dentry *);
1803 + int (*link_raw) (struct nameidata *,struct nameidata *);
1804 int (*unlink) (struct inode *,struct dentry *);
1805 + int (*unlink_raw) (struct nameidata *);
1806 int (*symlink) (struct inode *,struct dentry *,const char *);
1807 + int (*symlink_raw) (struct nameidata *,const char *);
1808 int (*mkdir) (struct inode *,struct dentry *,int);
1809 + int (*mkdir_raw) (struct nameidata *,int);
1810 int (*rmdir) (struct inode *,struct dentry *);
1811 + int (*rmdir_raw) (struct nameidata *);
1812 int (*mknod) (struct inode *,struct dentry *,int,int);
1813 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1814 int (*rename) (struct inode *, struct dentry *,
1815 struct inode *, struct dentry *);
1816 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1817 int (*readlink) (struct dentry *, char *,int);
1818 int (*follow_link) (struct dentry *, struct nameidata *);
1819 void (*truncate) (struct inode *);
1820 int (*permission) (struct inode *, int);
1821 int (*revalidate) (struct dentry *);
1822 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1823 int (*setattr) (struct dentry *, struct iattr *);
1824 + int (*setattr_raw) (struct inode *, struct iattr *);
1825 int (*getattr) (struct dentry *, struct iattr *);
1826 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
1827 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1828 @@ -1088,10 +1107,14 @@
1830 asmlinkage long sys_open(const char *, int, int);
1831 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1832 -extern int do_truncate(struct dentry *, loff_t start);
1833 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1835 extern struct file *filp_open(const char *, int, int);
1836 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1837 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1838 + struct nameidata *nd, struct lookup_intent *it);
1839 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1840 + int flags, struct lookup_intent *it);
1841 extern int filp_close(struct file *, fl_owner_t id);
1842 extern char * getname(const char *);
1844 @@ -1354,6 +1377,7 @@
1845 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1847 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1848 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1849 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1850 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1851 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1852 @@ -1365,6 +1389,8 @@
1853 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1854 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1855 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1856 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1857 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1859 extern void inode_init_once(struct inode *);
1860 extern void _inode_init_once(struct inode *);
1861 @@ -1503,6 +1529,8 @@
1863 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1864 extern int vfs_follow_link(struct nameidata *, const char *);
1865 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1866 + struct lookup_intent *it);
1867 extern int page_readlink(struct dentry *, char *, int);
1868 extern int page_follow_link(struct dentry *, struct nameidata *);
1869 extern struct inode_operations page_symlink_inode_operations;
1870 Index: linux/include/linux/fs_struct.h
1871 ===================================================================
1872 --- linux.orig/include/linux/fs_struct.h Fri Jul 13 18:10:44 2001
1873 +++ linux/include/linux/fs_struct.h Wed Mar 17 13:11:25 2004
1875 write_lock(&fs->lock);
1876 old_root = fs->root;
1877 old_rootmnt = fs->rootmnt;
1878 + PIN(dentry, mnt, 1);
1879 fs->rootmnt = mntget(mnt);
1880 fs->root = dget(dentry);
1881 write_unlock(&fs->lock);
1883 + UNPIN(old_root, old_rootmnt, 1);
1885 mntput(old_rootmnt);
1888 write_lock(&fs->lock);
1890 old_pwdmnt = fs->pwdmnt;
1891 + PIN(dentry, mnt, 0);
1892 fs->pwdmnt = mntget(mnt);
1893 fs->pwd = dget(dentry);
1894 write_unlock(&fs->lock);
1896 + UNPIN(old_pwd, old_pwdmnt, 0);
1900 Index: linux/kernel/exit.c
1901 ===================================================================
1902 --- linux.orig/kernel/exit.c Wed Mar 17 13:00:38 2004
1903 +++ linux/kernel/exit.c Wed Mar 17 13:11:25 2004
1904 @@ -239,11 +239,14 @@
1906 /* No need to hold fs->lock if we are killing it */
1907 if (atomic_dec_and_test(&fs->count)) {
1908 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1909 + UNPIN(fs->root, fs->rootmnt, 1);
1911 mntput(fs->rootmnt);
1915 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1917 mntput(fs->altrootmnt);
1919 Index: linux/kernel/fork.c
1920 ===================================================================
1921 --- linux.orig/kernel/fork.c Wed Mar 17 13:00:38 2004
1922 +++ linux/kernel/fork.c Wed Mar 17 13:11:25 2004
1923 @@ -387,10 +387,13 @@
1924 fs->umask = old->umask;
1925 read_lock(&old->lock);
1926 fs->rootmnt = mntget(old->rootmnt);
1927 + PIN(old->pwd, old->pwdmnt, 0);
1928 + PIN(old->root, old->rootmnt, 1);
1929 fs->root = dget(old->root);
1930 fs->pwdmnt = mntget(old->pwdmnt);
1931 fs->pwd = dget(old->pwd);
1933 + PIN(old->altroot, old->altrootmnt, 1);
1934 fs->altrootmnt = mntget(old->altrootmnt);
1935 fs->altroot = dget(old->altroot);
1937 Index: linux/kernel/ksyms.c
1938 ===================================================================
1939 --- linux.orig/kernel/ksyms.c Wed Mar 17 13:11:23 2004
1940 +++ linux/kernel/ksyms.c Wed Mar 17 13:11:25 2004
1942 EXPORT_SYMBOL(set_page_dirty);
1943 EXPORT_SYMBOL(vfs_readlink);
1944 EXPORT_SYMBOL(vfs_follow_link);
1945 +EXPORT_SYMBOL(vfs_follow_link_it);
1946 EXPORT_SYMBOL(page_readlink);
1947 EXPORT_SYMBOL(page_follow_link);
1948 EXPORT_SYMBOL(page_symlink_inode_operations);