3 fs/namei.c | 295 +++++++++++++++++++++++++++++++++++++++-------
4 fs/namespace.c | 28 +++-
5 fs/open.c | 172 +++++++++++++++++++-------
6 fs/stat.c | 52 +++++---
7 include/linux/dcache.h | 60 +++++++++
8 include/linux/fs.h | 32 ++++
9 include/linux/fs_struct.h | 4
13 12 files changed, 558 insertions(+), 128 deletions(-)
15 Index: linux-ia64/fs/dcache.c
16 ===================================================================
17 --- linux-ia64.orig/fs/dcache.c 2004-03-17 15:47:15.000000000 -0800
18 +++ linux-ia64/fs/dcache.c 2004-03-17 16:05:28.000000000 -0800
19 @@ -186,6 +186,13 @@ int d_invalidate(struct dentry * dentry)
20 spin_unlock(&dcache_lock);
24 + /* network invalidation by Lustre */
25 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
26 + spin_unlock(&dcache_lock);
31 * Check whether to do a partial shrink_dcache
32 * to get rid of unused child entries.
33 @@ -850,13 +857,19 @@ void d_delete(struct dentry * dentry)
34 * Adds a dentry to the hash according to its name.
37 -void d_rehash(struct dentry * entry)
38 +void __d_rehash(struct dentry * entry, int lock)
40 struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
41 if (!list_empty(&entry->d_hash)) BUG();
42 - spin_lock(&dcache_lock);
43 + if (lock) spin_lock(&dcache_lock);
44 list_add(&entry->d_hash, list);
45 - spin_unlock(&dcache_lock);
46 + if (lock) spin_unlock(&dcache_lock);
48 +EXPORT_SYMBOL(__d_rehash);
50 +void d_rehash(struct dentry * entry)
52 + __d_rehash(entry, 1);
55 #define do_switch(x,y) do { \
56 Index: linux-ia64/fs/exec.c
57 ===================================================================
58 --- linux-ia64.orig/fs/exec.c 2004-03-17 15:47:15.000000000 -0800
59 +++ linux-ia64/fs/exec.c 2004-03-17 16:05:28.000000000 -0800
60 @@ -119,8 +119,10 @@ asmlinkage long sys_uselib(const char *
64 + struct lookup_intent it = { .it_op = IT_OPEN,
65 + .it_flags = FMODE_READ|FMODE_EXEC };
67 - error = user_path_walk(library, &nd);
68 + error = user_path_walk_it(library, &nd, &it);
72 @@ -132,7 +134,8 @@ asmlinkage long sys_uselib(const char *
76 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
77 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
78 + intent_release(&it);
79 error = PTR_ERR(file);
82 @@ -400,8 +403,10 @@ struct file *open_exec(const char *name)
86 + struct lookup_intent it = { .it_op = IT_OPEN,
87 + .it_flags = FMODE_READ|FMODE_EXEC };
89 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
90 + err = path_lookup_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
93 inode = nd.dentry->d_inode;
94 @@ -413,7 +418,8 @@ struct file *open_exec(const char *name)
98 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
99 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
100 + intent_release(&it);
102 err = deny_write_access(file);
104 @@ -425,6 +431,7 @@ out:
108 + intent_release(&it);
112 @@ -1348,7 +1355,7 @@ int do_coredump(long signr, int exit_cod
114 if (!file->f_op->write)
116 - if (do_truncate(file->f_dentry, 0) != 0)
117 + if (do_truncate(file->f_dentry, 0, 0) != 0)
120 retval = binfmt->core_dump(signr, regs, file);
121 Index: linux-ia64/fs/namei.c
122 ===================================================================
123 --- linux-ia64.orig/fs/namei.c 2004-03-17 15:47:15.000000000 -0800
124 +++ linux-ia64/fs/namei.c 2004-03-17 16:06:13.000000000 -0800
126 * XEmacs seems to be relying on it...
129 +void intent_release(struct lookup_intent *it)
131 + if (it && it->it_op_release)
132 + it->it_op_release(it);
136 /* In order to reduce some races, while at the same time doing additional
137 * checking and hopefully speeding things up, we copy filenames to the
138 * kernel data space before using them..
139 @@ -260,10 +267,19 @@ void path_release(struct nameidata *nd)
140 * Internal lookup() using the new generic dcache.
143 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
144 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
145 + int flags, struct lookup_intent *it)
147 struct dentry * dentry = d_lookup(parent, name);
149 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
150 + if (!dentry->d_op->d_revalidate_it(dentry, flags, it) &&
151 + !d_invalidate(dentry)) {
157 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
158 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
160 @@ -281,11 +297,15 @@ static struct dentry * cached_lookup(str
161 * make sure that nobody added the entry to the dcache in the meantime..
164 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
165 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
166 + int flags, struct lookup_intent *it)
168 struct dentry * result;
169 struct inode *dir = parent->d_inode;
176 * First re-do the cached lookup just in case it was created
177 @@ -300,6 +320,9 @@ static struct dentry * real_lookup(struc
178 result = ERR_PTR(-ENOMEM);
181 + if (dir->i_op->lookup_it)
182 + result = dir->i_op->lookup_it(dir, dentry, it, flags);
184 result = dir->i_op->lookup(dir, dentry);
187 @@ -321,6 +344,15 @@ static struct dentry * real_lookup(struc
189 result = ERR_PTR(-ENOENT);
191 + } else if (result->d_op && result->d_op->d_revalidate_it) {
192 + if (!result->d_op->d_revalidate_it(result, flags, it) &&
193 + !d_invalidate(result)) {
196 + result = ERR_PTR(-ESTALE);
197 + if (!IS_ERR(result))
203 @@ -332,7 +364,8 @@ static struct dentry * real_lookup(struc
204 * Without that kind of total limit, nasty chains of consecutive
205 * symlinks can cause almost arbitrarily long lookups.
207 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
208 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
209 + struct lookup_intent *it)
212 if (current->link_count >= 8)
213 @@ -346,10 +379,12 @@ static inline int do_follow_link(struct
214 current->link_count++;
215 current->total_link_count++;
216 UPDATE_ATIME(dentry->d_inode);
218 err = dentry->d_inode->i_op->follow_link(dentry, nd);
219 current->link_count--;
222 + intent_release(it);
226 @@ -447,7 +482,8 @@ static inline void follow_dotdot(struct
228 * We expect 'base' to be positive and a directory.
230 -int link_path_walk(const char * name, struct nameidata *nd)
231 +int link_path_walk_it(const char *name, struct nameidata *nd,
232 + struct lookup_intent *it)
234 struct dentry *dentry;
236 @@ -524,12 +560,12 @@ int link_path_walk(const char * name, st
239 /* This does the actual lookups.. */
240 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
241 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
243 err = -EWOULDBLOCKIO;
246 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
247 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
248 err = PTR_ERR(dentry);
251 @@ -547,7 +583,7 @@ int link_path_walk(const char * name, st
254 if (inode->i_op->follow_link) {
255 - err = do_follow_link(dentry, nd);
256 + err = do_follow_link(dentry, nd, NULL);
260 @@ -563,7 +599,7 @@ int link_path_walk(const char * name, st
264 - if (!inode->i_op->lookup)
265 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
268 /* here ends the main loop */
269 @@ -590,12 +626,12 @@ last_component:
273 - dentry = cached_lookup(nd->dentry, &this, 0);
274 + dentry = cached_lookup(nd->dentry, &this, 0, it);
276 err = -EWOULDBLOCKIO;
279 - dentry = real_lookup(nd->dentry, &this, 0);
280 + dentry = real_lookup(nd->dentry, &this, 0, it);
281 err = PTR_ERR(dentry);
284 @@ -605,7 +641,7 @@ last_component:
285 inode = dentry->d_inode;
286 if ((lookup_flags & LOOKUP_FOLLOW)
287 && inode && inode->i_op && inode->i_op->follow_link) {
288 - err = do_follow_link(dentry, nd);
289 + err = do_follow_link(dentry, nd, it);
293 @@ -619,7 +655,8 @@ last_component:
295 if (lookup_flags & LOOKUP_DIRECTORY) {
297 - if (!inode->i_op || !inode->i_op->lookup)
298 + if (!inode->i_op ||
299 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
303 @@ -637,12 +672,42 @@ return_reval:
304 nd->last_type = LAST_DOT;
305 else if (this.len == 2 && this.name[1] == '.')
306 nd->last_type = LAST_DOTDOT;
311 * We bypassed the ordinary revalidation routines.
312 * Check the cached dentry for staleness.
315 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
317 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
318 + struct dentry *new;
319 + err = permission(dentry->d_parent->d_inode,
323 + new = real_lookup(dentry->d_parent,
324 + &dentry->d_name, 0, it);
326 + err = PTR_ERR(new);
329 + d_invalidate(dentry);
333 + if (!nd->dentry->d_inode)
335 + if (lookup_flags & LOOKUP_DIRECTORY) {
337 + if (!nd->dentry->d_inode->i_op ||
338 + (!nd->dentry->d_inode->i_op->lookup &&
339 + !nd->dentry->d_inode->i_op->lookup_it))
343 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
345 if (!dentry->d_op->d_revalidate(dentry, 0)) {
346 @@ -656,15 +714,28 @@ out_dput:
351 + intent_release(it);
357 +int link_path_walk(const char * name, struct nameidata *nd)
359 + return link_path_walk_it(name, nd, NULL);
362 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
364 + current->total_link_count = 0;
365 + return link_path_walk_it(name, nd, it);
368 int path_walk(const char * name, struct nameidata *nd)
370 current->total_link_count = 0;
371 - return link_path_walk(name, nd);
372 + return link_path_walk_it(name, nd, NULL);
376 @@ -749,6 +820,17 @@ walk_init_root(const char *name, struct
380 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
381 + struct lookup_intent *it)
384 + if (path_init(path, flags, nd))
385 + error = path_walk_it(path, nd, it);
391 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
394 @@ -763,6 +845,7 @@ int path_init(const char *name, unsigned
396 nd->last_type = LAST_ROOT; /* if there are only slashes... */
400 return walk_init_root(name,nd);
401 read_lock(¤t->fs->lock);
402 @@ -777,7 +860,8 @@ int path_init(const char *name, unsigned
403 * needs parent already locked. Doesn't follow mounts.
406 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
407 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
408 + struct lookup_intent *it)
410 struct dentry * dentry;
412 @@ -800,13 +884,16 @@ struct dentry * lookup_hash(struct qstr
416 - dentry = cached_lookup(base, name, 0);
417 + dentry = cached_lookup(base, name, 0, it);
419 struct dentry *new = d_alloc(base, name);
420 dentry = ERR_PTR(-ENOMEM);
424 + if (inode->i_op->lookup_it)
425 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
427 dentry = inode->i_op->lookup(inode, new);
430 @@ -818,6 +905,12 @@ out:
434 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
436 + return lookup_hash_it(name, base, NULL);
441 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
443 @@ -839,7 +932,7 @@ struct dentry * lookup_one_len(const cha
445 this.hash = end_name_hash(hash);
447 - return lookup_hash(&this, base);
448 + return lookup_hash_it(&this, base, NULL);
450 return ERR_PTR(-EACCES);
452 @@ -870,6 +963,23 @@ int __user_walk(const char *name, unsign
456 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
457 + struct lookup_intent *it)
462 + tmp = getname(name);
463 + err = PTR_ERR(tmp);
464 + if (!IS_ERR(tmp)) {
466 + if (path_init(tmp, flags, nd))
467 + err = path_walk_it(tmp, nd, it);
474 * It's inline, so penalty for filesystems that don't use sticky bit is
476 @@ -967,7 +1077,8 @@ static inline int lookup_flags(unsigned
480 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
481 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
482 + struct lookup_intent *it)
486 @@ -980,12 +1091,15 @@ int vfs_create(struct inode *dir, struct
489 error = -EACCES; /* shouldn't it be ENOSYS? */
490 - if (!dir->i_op || !dir->i_op->create)
491 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
496 - error = dir->i_op->create(dir, dentry, mode);
497 + if (dir->i_op->create_it)
498 + error = dir->i_op->create_it(dir, dentry, mode, it);
500 + error = dir->i_op->create(dir, dentry, mode);
504 @@ -994,6 +1108,11 @@ exit_lock:
508 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
510 + return vfs_create_it(dir, dentry, mode, NULL);
516 @@ -1008,7 +1127,8 @@ exit_lock:
517 * for symlinks (where the permissions are checked later).
520 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
521 +int open_namei_it(const char *pathname, int flag, int mode,
522 + struct nameidata *nd, struct lookup_intent *it)
524 int acc_mode, error = 0;
526 @@ -1018,11 +1138,14 @@ int open_namei(const char * pathname, in
528 acc_mode = ACC_MODE(flag);
531 + it->it_flags = flag;
534 * The simplest case - just a plain lookup.
536 if (!(flag & O_CREAT)) {
537 - error = path_lookup(pathname, lookup_flags(flag), nd);
538 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
542 @@ -1032,6 +1155,10 @@ int open_namei(const char * pathname, in
544 * Create - we need to know the parent.
547 + it->it_create_mode = mode;
548 + it->it_op |= IT_CREAT;
550 error = path_lookup(pathname, LOOKUP_PARENT, nd);
553 @@ -1047,7 +1174,7 @@ int open_namei(const char * pathname, in
556 down(&dir->d_inode->i_sem);
557 - dentry = lookup_hash(&nd->last, nd->dentry);
558 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
561 error = PTR_ERR(dentry);
562 @@ -1056,11 +1183,12 @@ do_last:
566 + it->it_create_mode = mode;
567 /* Negative dentry, just create the file */
568 if (!dentry->d_inode) {
569 if (!IS_POSIXACL(dir->d_inode))
570 mode &= ~current->fs->umask;
571 - error = vfs_create(dir->d_inode, dentry, mode);
572 + error = vfs_create_it(dir->d_inode, dentry, mode, it);
573 up(&dir->d_inode->i_sem);
576 @@ -1164,7 +1292,7 @@ ok:
580 - error = do_truncate(dentry, 0);
581 + error = do_truncate(dentry, 0, 1);
583 put_write_access(inode);
585 @@ -1176,8 +1304,10 @@ ok:
589 + intent_release(it);
592 + intent_release(it);
596 @@ -1196,7 +1326,10 @@ do_link:
597 * are done. Procfs-like symlinks just set LAST_BIND.
599 UPDATE_ATIME(dentry->d_inode);
601 error = dentry->d_inode->i_op->follow_link(dentry, nd);
603 + intent_release(it);
607 @@ -1218,13 +1351,20 @@ do_link:
610 down(&dir->d_inode->i_sem);
611 - dentry = lookup_hash(&nd->last, nd->dentry);
612 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
613 putname(nd->last.name);
617 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
619 + return open_namei_it(pathname, flag, mode, nd, NULL);
624 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
625 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
626 + struct lookup_intent *it)
628 struct dentry *dentry;
630 @@ -1232,7 +1372,7 @@ static struct dentry *lookup_create(stru
631 dentry = ERR_PTR(-EEXIST);
632 if (nd->last_type != LAST_NORM)
634 - dentry = lookup_hash(&nd->last, nd->dentry);
635 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
638 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
639 @@ -1288,7 +1428,20 @@ asmlinkage long sys_mknod(const char * f
640 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
643 - dentry = lookup_create(&nd, 0);
645 + if (nd.last_type != LAST_NORM) {
649 + if (nd.dentry->d_inode->i_op->mknod_raw) {
650 + struct inode_operations *op = nd.dentry->d_inode->i_op;
651 + error = op->mknod_raw(&nd, mode, dev);
652 + /* the file system wants to use normal vfs path now */
653 + if (error != -EOPNOTSUPP)
657 + dentry = lookup_create(&nd, 0, NULL);
658 error = PTR_ERR(dentry);
660 if (!IS_POSIXACL(nd.dentry->d_inode))
661 @@ -1310,6 +1463,7 @@ asmlinkage long sys_mknod(const char * f
664 up(&nd.dentry->d_inode->i_sem);
669 @@ -1357,7 +1511,18 @@ asmlinkage long sys_mkdir(const char * p
670 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
673 - dentry = lookup_create(&nd, 1);
674 + if (nd.last_type != LAST_NORM) {
678 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
679 + struct inode_operations *op = nd.dentry->d_inode->i_op;
680 + error = op->mkdir_raw(&nd, mode);
681 + /* the file system wants to use normal vfs path now */
682 + if (error != -EOPNOTSUPP)
685 + dentry = lookup_create(&nd, 1, NULL);
686 error = PTR_ERR(dentry);
687 if (!IS_ERR(dentry)) {
688 if (!IS_POSIXACL(nd.dentry->d_inode))
689 @@ -1366,6 +1531,7 @@ asmlinkage long sys_mkdir(const char * p
692 up(&nd.dentry->d_inode->i_sem);
697 @@ -1466,8 +1632,16 @@ asmlinkage long sys_rmdir(const char * p
701 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
702 + struct inode_operations *op = nd.dentry->d_inode->i_op;
704 + error = op->rmdir_raw(&nd);
705 + /* the file system wants to use normal vfs path now */
706 + if (error != -EOPNOTSUPP)
709 down(&nd.dentry->d_inode->i_sem);
710 - dentry = lookup_hash(&nd.last, nd.dentry);
711 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
712 error = PTR_ERR(dentry);
713 if (!IS_ERR(dentry)) {
714 error = vfs_rmdir(nd.dentry->d_inode, dentry);
715 @@ -1525,8 +1699,15 @@ asmlinkage long sys_unlink(const char *
717 if (nd.last_type != LAST_NORM)
719 + if (nd.dentry->d_inode->i_op->unlink_raw) {
720 + struct inode_operations *op = nd.dentry->d_inode->i_op;
721 + error = op->unlink_raw(&nd);
722 + /* the file system wants to use normal vfs path now */
723 + if (error != -EOPNOTSUPP)
726 down(&nd.dentry->d_inode->i_sem);
727 - dentry = lookup_hash(&nd.last, nd.dentry);
728 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
729 error = PTR_ERR(dentry);
730 if (!IS_ERR(dentry)) {
731 /* Why not before? Because we want correct error value */
732 @@ -1593,15 +1774,27 @@ asmlinkage long sys_symlink(const char *
733 error = path_lookup(to, LOOKUP_PARENT, &nd);
736 - dentry = lookup_create(&nd, 0);
737 + if (nd.last_type != LAST_NORM) {
741 + if (nd.dentry->d_inode->i_op->symlink_raw) {
742 + struct inode_operations *op = nd.dentry->d_inode->i_op;
743 + error = op->symlink_raw(&nd, from);
744 + /* the file system wants to use normal vfs path now */
745 + if (error != -EOPNOTSUPP)
748 + dentry = lookup_create(&nd, 0, NULL);
749 error = PTR_ERR(dentry);
750 if (!IS_ERR(dentry)) {
751 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
754 up(&nd.dentry->d_inode->i_sem);
762 @@ -1677,7 +1870,18 @@ asmlinkage long sys_link(const char * ol
764 if (old_nd.mnt != nd.mnt)
766 - new_dentry = lookup_create(&nd, 0);
767 + if (nd.last_type != LAST_NORM) {
771 + if (nd.dentry->d_inode->i_op->link_raw) {
772 + struct inode_operations *op = nd.dentry->d_inode->i_op;
773 + error = op->link_raw(&old_nd, &nd);
774 + /* the file system wants to use normal vfs path now */
775 + if (error != -EOPNOTSUPP)
778 + new_dentry = lookup_create(&nd, 0, NULL);
779 error = PTR_ERR(new_dentry);
780 if (!IS_ERR(new_dentry)) {
781 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
782 @@ -1721,7 +1925,7 @@ exit:
785 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
786 - struct inode *new_dir, struct dentry *new_dentry)
787 + struct inode *new_dir, struct dentry *new_dentry)
790 struct inode *target;
791 @@ -1800,7 +2004,7 @@ out_unlock:
794 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
795 - struct inode *new_dir, struct dentry *new_dentry)
796 + struct inode *new_dir, struct dentry *new_dentry)
800 @@ -1888,9 +2092,18 @@ static inline int do_rename(const char *
801 if (newnd.last_type != LAST_NORM)
804 + if (old_dir->d_inode->i_op->rename_raw) {
806 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
808 + /* the file system wants to use normal vfs path now */
809 + if (error != -EOPNOTSUPP)
813 double_lock(new_dir, old_dir);
815 - old_dentry = lookup_hash(&oldnd.last, old_dir);
816 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
817 error = PTR_ERR(old_dentry);
818 if (IS_ERR(old_dentry))
820 @@ -1906,16 +2119,16 @@ static inline int do_rename(const char *
821 if (newnd.last.name[newnd.last.len])
824 - new_dentry = lookup_hash(&newnd.last, new_dir);
825 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
826 error = PTR_ERR(new_dentry);
827 if (IS_ERR(new_dentry))
832 error = vfs_rename(old_dir->d_inode, old_dentry,
833 new_dir->d_inode, new_dentry);
839 @@ -1966,20 +2179,26 @@ out:
843 -__vfs_follow_link(struct nameidata *nd, const char *link)
844 +__vfs_follow_link(struct nameidata *nd, const char *link,
845 + struct lookup_intent *it)
854 + else if (it != nd->intent)
855 + printk("it != nd->intent: tell phil@clusterfs.com\n");
859 if (!walk_init_root(link, nd))
860 /* weird __emul_prefix() stuff did it */
863 - res = link_path_walk(link, nd);
864 + res = link_path_walk_it(link, nd, it);
866 if (current->link_count || res || nd->last_type!=LAST_NORM)
868 @@ -2003,7 +2222,13 @@ fail:
870 int vfs_follow_link(struct nameidata *nd, const char *link)
872 - return __vfs_follow_link(nd, link);
873 + return __vfs_follow_link(nd, link, NULL);
876 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
877 + struct lookup_intent *it)
879 + return __vfs_follow_link(nd, link, it);
882 /* get the link contents into pagecache */
883 @@ -2045,7 +2270,7 @@ int page_follow_link(struct dentry *dent
885 struct page *page = NULL;
886 char *s = page_getlink(dentry, &page);
887 - int res = __vfs_follow_link(nd, s);
888 + int res = __vfs_follow_link(nd, s, NULL);
891 page_cache_release(page);
892 Index: linux-ia64/fs/namespace.c
893 ===================================================================
894 --- linux-ia64.orig/fs/namespace.c 2004-03-17 15:47:15.000000000 -0800
895 +++ linux-ia64/fs/namespace.c 2004-03-17 16:05:28.000000000 -0800
896 @@ -98,6 +98,7 @@ static void detach_mnt(struct vfsmount *
898 old_nd->dentry = mnt->mnt_mountpoint;
899 old_nd->mnt = mnt->mnt_parent;
900 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
901 mnt->mnt_parent = mnt;
902 mnt->mnt_mountpoint = mnt->mnt_root;
903 list_del_init(&mnt->mnt_child);
904 @@ -109,6 +110,7 @@ static void attach_mnt(struct vfsmount *
906 mnt->mnt_parent = mntget(nd->mnt);
907 mnt->mnt_mountpoint = dget(nd->dentry);
908 + PIN(nd->dentry, nd->mnt, 1);
909 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
910 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
911 nd->dentry->d_mounted++;
912 @@ -488,14 +490,17 @@ static int do_loopback(struct nameidata
914 struct nameidata old_nd;
915 struct vfsmount *mnt = NULL;
916 + struct lookup_intent it = { .it_op = IT_GETATTR };
917 int err = mount_is_safe(nd);
920 if (!old_name || !*old_name)
922 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
924 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
926 + intent_release(&it);
930 down_write(¤t->namespace->sem);
932 @@ -518,6 +523,7 @@ static int do_loopback(struct nameidata
935 up_write(¤t->namespace->sem);
936 + intent_release(&it);
937 path_release(&old_nd);
940 @@ -701,6 +707,7 @@ long do_mount(char * dev_name, char * di
941 unsigned long flags, void *data_page)
944 + struct lookup_intent it = { .it_op = IT_GETATTR };
948 @@ -725,10 +732,11 @@ long do_mount(char * dev_name, char * di
949 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
951 /* ... and get the mountpoint */
952 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
954 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
956 + intent_release(&it);
960 if (flags & MS_REMOUNT)
961 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
963 @@ -739,6 +747,8 @@ long do_mount(char * dev_name, char * di
965 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
966 dev_name, data_page);
968 + intent_release(&it);
972 @@ -904,6 +914,8 @@ asmlinkage long sys_pivot_root(const cha
974 struct vfsmount *tmp;
975 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
976 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
977 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
980 if (!capable(CAP_SYS_ADMIN))
981 @@ -911,14 +923,14 @@ asmlinkage long sys_pivot_root(const cha
985 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
986 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
990 if (!check_mnt(new_nd.mnt))
993 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
994 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
998 @@ -973,8 +985,10 @@ out2:
999 up(&old_nd.dentry->d_inode->i_zombie);
1000 up_write(¤t->namespace->sem);
1001 path_release(&user_nd);
1002 + intent_release(&old_it);
1003 path_release(&old_nd);
1005 + intent_release(&new_it);
1006 path_release(&new_nd);
1009 Index: linux-ia64/fs/open.c
1010 ===================================================================
1011 --- linux-ia64.orig/fs/open.c 2004-03-17 15:47:15.000000000 -0800
1012 +++ linux-ia64/fs/open.c 2004-03-17 16:05:28.000000000 -0800
1014 #include <asm/uaccess.h>
1016 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1017 +extern int path_walk_it(const char *name, struct nameidata *nd,
1018 + struct lookup_intent *it);
1020 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1022 @@ -95,9 +97,10 @@ void fd_install(unsigned int fd, struct
1023 write_unlock(&files->file_lock);
1026 -int do_truncate(struct dentry *dentry, loff_t length)
1027 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1029 struct inode *inode = dentry->d_inode;
1030 + struct inode_operations *op = dentry->d_inode->i_op;
1032 struct iattr newattrs;
1034 @@ -109,7 +112,13 @@ int do_truncate(struct dentry *dentry, l
1035 down(&inode->i_sem);
1036 newattrs.ia_size = length;
1037 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1038 - error = notify_change(dentry, &newattrs);
1039 + if (called_from_open)
1040 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1041 + if (op->setattr_raw) {
1042 + newattrs.ia_valid |= ATTR_RAW;
1043 + error = op->setattr_raw(inode, &newattrs);
1045 + error = notify_change(dentry, &newattrs);
1047 up_write(&inode->i_alloc_sem);
1049 @@ -120,12 +129,13 @@ static inline long do_sys_truncate(const
1050 struct nameidata nd;
1051 struct inode * inode;
1053 + struct lookup_intent it = { .it_op = IT_GETATTR };
1056 if (length < 0) /* sorry, but loff_t says... */
1059 - error = user_path_walk(path, &nd);
1060 + error = user_path_walk_it(path, &nd, &it);
1063 inode = nd.dentry->d_inode;
1064 @@ -165,11 +175,13 @@ static inline long do_sys_truncate(const
1065 error = locks_verify_truncate(inode, NULL, length);
1068 - error = do_truncate(nd.dentry, length);
1069 + intent_release(&it);
1070 + error = do_truncate(nd.dentry, length, 0);
1072 put_write_access(inode);
1075 + intent_release(&it);
1079 @@ -217,7 +229,7 @@ static inline long do_sys_ftruncate(unsi
1081 error = locks_verify_truncate(inode, file, length);
1083 - error = do_truncate(dentry, length);
1084 + error = do_truncate(dentry, length, 0);
1088 @@ -262,11 +274,13 @@ asmlinkage long sys_utime(char * filenam
1089 struct inode * inode;
1090 struct iattr newattrs;
1092 - error = user_path_walk(filename, &nd);
1093 + error = user_path_walk_it(filename, &nd, NULL);
1096 inode = nd.dentry->d_inode;
1098 + /* this is safe without a Lustre lock because it only depends
1099 + on the super block */
1101 if (IS_RDONLY(inode))
1103 @@ -281,11 +295,25 @@ asmlinkage long sys_utime(char * filenam
1106 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1110 + if (inode->i_op->setattr_raw) {
1111 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1113 + newattrs.ia_valid |= ATTR_RAW;
1114 + error = op->setattr_raw(inode, &newattrs);
1115 + /* the file system wants to use normal vfs path now */
1116 + if (error != -EOPNOTSUPP)
1117 + goto dput_and_out;
1122 if (current->fsuid != inode->i_uid &&
1123 (error = permission(inode,MAY_WRITE)) != 0)
1127 error = notify_change(nd.dentry, &newattrs);
1130 @@ -306,12 +334,14 @@ asmlinkage long sys_utimes(char * filena
1131 struct inode * inode;
1132 struct iattr newattrs;
1134 - error = user_path_walk(filename, &nd);
1135 + error = user_path_walk_it(filename, &nd, NULL);
1139 inode = nd.dentry->d_inode;
1141 + /* this is safe without a Lustre lock because it only depends
1142 + on the super block */
1144 if (IS_RDONLY(inode))
1146 @@ -326,7 +356,20 @@ asmlinkage long sys_utimes(char * filena
1147 newattrs.ia_atime = times[0].tv_sec;
1148 newattrs.ia_mtime = times[1].tv_sec;
1149 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1153 + if (inode->i_op->setattr_raw) {
1154 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1156 + newattrs.ia_valid |= ATTR_RAW;
1157 + error = op->setattr_raw(inode, &newattrs);
1158 + /* the file system wants to use normal vfs path now */
1159 + if (error != -EOPNOTSUPP)
1160 + goto dput_and_out;
1165 if (current->fsuid != inode->i_uid &&
1166 (error = permission(inode,MAY_WRITE)) != 0)
1168 @@ -349,6 +392,7 @@ asmlinkage long sys_access(const char *
1169 int old_fsuid, old_fsgid;
1170 kernel_cap_t old_cap;
1172 + struct lookup_intent it = { .it_op = IT_GETATTR };
1174 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1176 @@ -366,13 +410,14 @@ asmlinkage long sys_access(const char *
1178 current->cap_effective = current->cap_permitted;
1180 - res = user_path_walk(filename, &nd);
1181 + res = user_path_walk_it(filename, &nd, &it);
1183 res = permission(nd.dentry->d_inode, mode);
1184 /* SuS v2 requires we report a read only fs too */
1185 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1186 && !special_file(nd.dentry->d_inode->i_mode))
1188 + intent_release(&it);
1192 @@ -387,8 +432,9 @@ asmlinkage long sys_chdir(const char * f
1195 struct nameidata nd;
1196 + struct lookup_intent it = { .it_op = IT_GETATTR };
1198 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1199 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1203 @@ -399,6 +445,7 @@ asmlinkage long sys_chdir(const char * f
1204 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1207 + intent_release(&it);
1211 @@ -438,9 +485,10 @@ asmlinkage long sys_chroot(const char *
1214 struct nameidata nd;
1215 + struct lookup_intent it = { .it_op = IT_GETATTR };
1217 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1218 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1219 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1220 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1224 @@ -456,39 +504,56 @@ asmlinkage long sys_chroot(const char *
1228 + intent_release(&it);
1234 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1235 +int chmod_common(struct dentry *dentry, mode_t mode)
1237 - struct inode * inode;
1238 - struct dentry * dentry;
1239 - struct file * file;
1241 + struct inode *inode = dentry->d_inode;
1242 struct iattr newattrs;
1247 + if (IS_RDONLY(inode))
1250 - dentry = file->f_dentry;
1251 - inode = dentry->d_inode;
1252 + if (inode->i_op->setattr_raw) {
1253 + newattrs.ia_mode = mode;
1254 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1255 + newattrs.ia_valid |= ATTR_RAW;
1256 + err = inode->i_op->setattr_raw(inode, &newattrs);
1257 + /* the file system wants to use normal vfs path now */
1258 + if (err != -EOPNOTSUPP)
1263 - if (IS_RDONLY(inode))
1266 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1270 if (mode == (mode_t) -1)
1271 mode = inode->i_mode;
1272 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1273 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1274 err = notify_change(dentry, &newattrs);
1281 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1283 + struct file * file;
1290 + err = chmod_common(file->f_dentry, mode);
1295 @@ -497,30 +562,14 @@ out:
1296 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1298 struct nameidata nd;
1299 - struct inode * inode;
1301 - struct iattr newattrs;
1303 error = user_path_walk(filename, &nd);
1306 - inode = nd.dentry->d_inode;
1309 - if (IS_RDONLY(inode))
1310 - goto dput_and_out;
1313 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1314 - goto dput_and_out;
1315 + error = chmod_common(nd.dentry, mode);
1317 - if (mode == (mode_t) -1)
1318 - mode = inode->i_mode;
1319 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1320 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1321 - error = notify_change(nd.dentry, &newattrs);
1327 @@ -540,6 +589,20 @@ static int chown_common(struct dentry *
1329 if (IS_RDONLY(inode))
1332 + if (inode->i_op->setattr_raw) {
1333 + struct inode_operations *op = dentry->d_inode->i_op;
1335 + newattrs.ia_uid = user;
1336 + newattrs.ia_gid = group;
1337 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1338 + newattrs.ia_valid |= ATTR_RAW;
1339 + error = op->setattr_raw(inode, &newattrs);
1340 + /* the file system wants to use normal vfs path now */
1341 + if (error != -EOPNOTSUPP)
1346 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1348 @@ -644,6 +707,7 @@ struct file *filp_open(const char * file
1350 int namei_flags, error;
1351 struct nameidata nd;
1352 + struct lookup_intent it = { .it_op = IT_OPEN };
1354 namei_flags = flags;
1355 if ((namei_flags+1) & O_ACCMODE)
1356 @@ -651,14 +715,15 @@ struct file *filp_open(const char * file
1357 if (namei_flags & O_TRUNC)
1360 - error = open_namei(filename, namei_flags, mode, &nd);
1362 - return dentry_open(nd.dentry, nd.mnt, flags);
1363 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1365 + return ERR_PTR(error);
1367 - return ERR_PTR(error);
1368 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1371 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1372 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1373 + int flags, struct lookup_intent *it)
1376 struct inode *inode;
1377 @@ -695,7 +760,9 @@ struct file *dentry_open(struct dentry *
1380 if (f->f_op && f->f_op->open) {
1382 error = f->f_op->open(inode,f);
1387 @@ -708,6 +775,7 @@ struct file *dentry_open(struct dentry *
1388 inode->i_mapping->a_ops->direct_sector_IO)))
1391 + intent_release(it);
1395 @@ -722,11 +790,17 @@ cleanup_all:
1399 + intent_release(it);
1402 return ERR_PTR(error);
1405 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1407 + return dentry_open_it(dentry, mnt, flags, NULL);
1411 * Find an empty file descriptor entry, and mark it busy.
1413 Index: linux-ia64/fs/stat.c
1414 ===================================================================
1415 --- linux-ia64.orig/fs/stat.c 2004-03-17 15:47:15.000000000 -0800
1416 +++ linux-ia64/fs/stat.c 2004-03-17 16:06:13.000000000 -0800
1418 * Revalidate the inode. This is required for proper NFS attribute caching.
1420 static __inline__ int
1421 -do_revalidate(struct dentry *dentry)
1422 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1424 struct inode * inode = dentry->d_inode;
1425 - if (inode->i_op && inode->i_op->revalidate)
1426 + if (inode->i_op && inode->i_op->revalidate_it)
1427 + return inode->i_op->revalidate_it(dentry, it);
1428 + else if (inode->i_op && inode->i_op->revalidate)
1429 return inode->i_op->revalidate(dentry);
1432 @@ -143,13 +145,15 @@ static int cp_new_stat(struct inode * in
1433 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1435 struct nameidata nd;
1436 + struct lookup_intent it = { .it_op = IT_GETATTR };
1439 - error = user_path_walk(filename, &nd);
1440 + error = user_path_walk_it(filename, &nd, &it);
1442 - error = do_revalidate(nd.dentry);
1443 + error = do_revalidate(nd.dentry, &it);
1445 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1446 + intent_release(&it);
1450 @@ -159,13 +163,15 @@ asmlinkage long sys_stat(char * filename
1451 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1453 struct nameidata nd;
1454 + struct lookup_intent it = { .it_op = IT_GETATTR };
1457 - error = user_path_walk(filename, &nd);
1458 + error = user_path_walk_it(filename, &nd, &it);
1460 - error = do_revalidate(nd.dentry);
1461 + error = do_revalidate(nd.dentry, &it);
1463 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1464 + intent_release(&it);
1468 @@ -180,13 +186,15 @@ asmlinkage long sys_newstat(char * filen
1469 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1471 struct nameidata nd;
1472 + struct lookup_intent it = { .it_op = IT_GETATTR };
1475 - error = user_path_walk_link(filename, &nd);
1476 + error = user_path_walk_link_it(filename, &nd, &it);
1478 - error = do_revalidate(nd.dentry);
1479 + error = do_revalidate(nd.dentry, &it);
1481 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1482 + intent_release(&it);
1486 @@ -197,13 +205,15 @@ asmlinkage long sys_lstat(char * filenam
1487 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1489 struct nameidata nd;
1490 + struct lookup_intent it = { .it_op = IT_GETATTR };
1493 - error = user_path_walk_link(filename, &nd);
1494 + error = user_path_walk_link_it(filename, &nd, &it);
1496 - error = do_revalidate(nd.dentry);
1497 + error = do_revalidate(nd.dentry, &it);
1499 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1500 + intent_release(&it);
1504 @@ -224,7 +234,7 @@ asmlinkage long sys_fstat(unsigned int f
1506 struct dentry * dentry = f->f_dentry;
1508 - err = do_revalidate(dentry);
1509 + err = do_revalidate(dentry, NULL);
1511 err = cp_old_stat(dentry->d_inode, statbuf);
1513 @@ -243,7 +253,7 @@ asmlinkage long sys_newfstat(unsigned in
1515 struct dentry * dentry = f->f_dentry;
1517 - err = do_revalidate(dentry);
1518 + err = do_revalidate(dentry, NULL);
1520 err = cp_new_stat(dentry->d_inode, statbuf);
1522 @@ -265,7 +275,7 @@ asmlinkage long sys_readlink(const char
1525 if (inode->i_op && inode->i_op->readlink &&
1526 - !(error = do_revalidate(nd.dentry))) {
1527 + !(error = do_revalidate(nd.dentry, NULL))) {
1528 UPDATE_ATIME(inode);
1529 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1531 @@ -341,12 +351,14 @@ asmlinkage long sys_stat64(char * filena
1533 struct nameidata nd;
1535 + struct lookup_intent it = { .it_op = IT_GETATTR };
1537 - error = user_path_walk(filename, &nd);
1538 + error = user_path_walk_it(filename, &nd, &it);
1540 - error = do_revalidate(nd.dentry);
1541 + error = do_revalidate(nd.dentry, &it);
1543 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1544 + intent_release(&it);
1548 @@ -356,12 +368,14 @@ asmlinkage long sys_lstat64(char * filen
1550 struct nameidata nd;
1552 + struct lookup_intent it = { .it_op = IT_GETATTR };
1554 - error = user_path_walk_link(filename, &nd);
1555 + error = user_path_walk_link_it(filename, &nd, &it);
1557 - error = do_revalidate(nd.dentry);
1558 + error = do_revalidate(nd.dentry, &it);
1560 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1561 + intent_release(&it);
1565 @@ -376,7 +390,7 @@ asmlinkage long sys_fstat64(unsigned lon
1567 struct dentry * dentry = f->f_dentry;
1569 - err = do_revalidate(dentry);
1570 + err = do_revalidate(dentry, NULL);
1572 err = cp_new_stat64(dentry->d_inode, statbuf);
1574 Index: linux-ia64/include/linux/dcache.h
1575 ===================================================================
1576 --- linux-ia64.orig/include/linux/dcache.h 2004-03-17 15:47:15.000000000 -0800
1577 +++ linux-ia64/include/linux/dcache.h 2004-03-17 16:05:28.000000000 -0800
1579 #include <asm/atomic.h>
1580 #include <linux/mount.h>
1581 #include <linux/kernel.h>
1582 +#include <linux/string.h>
1584 +#define IT_OPEN 0x0001
1585 +#define IT_CREAT 0x0002
1586 +#define IT_READDIR 0x0004
1587 +#define IT_GETATTR 0x0008
1588 +#define IT_LOOKUP 0x0010
1589 +#define IT_UNLINK 0x0020
1590 +#define IT_GETXATTR 0x0040
1591 +#define IT_EXEC 0x0080
1592 +#define IT_PIN 0x0100
1594 +#define IT_FL_LOCKED 0x0001
1595 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1597 +#define INTENT_MAGIC 0x19620323
1600 +struct lustre_intent_data {
1601 + int it_disposition;
1603 + __u64 it_lock_handle;
1608 +struct lookup_intent {
1610 + void (*it_op_release)(struct lookup_intent *);
1613 + int it_create_mode;
1615 + struct lustre_intent_data lustre;
1619 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1621 + memset(it, 0, sizeof(*it));
1622 + it->it_magic = INTENT_MAGIC;
1624 + it->it_flags = flags;
1629 * linux/include/linux/dcache.h
1630 @@ -96,8 +141,22 @@ struct dentry_operations {
1631 int (*d_delete)(struct dentry *);
1632 void (*d_release)(struct dentry *);
1633 void (*d_iput)(struct dentry *, struct inode *);
1634 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1635 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1636 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1639 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1640 + de->d_op->d_pin(de, mnt, flag);
1641 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1642 + de->d_op->d_unpin(de, mnt, flag);
1645 +/* defined in fs/namei.c */
1646 +extern void intent_release(struct lookup_intent *it);
1647 +/* defined in fs/dcache.c */
1648 +extern void __d_rehash(struct dentry * entry, int lock);
1650 /* the dentry parameter passed to d_hash and d_compare is the parent
1651 * directory of the entries to be compared. It is used in case these
1652 * functions need any directory specific information for determining
1653 @@ -129,6 +188,7 @@ d_iput: no no yes
1654 * s_nfsd_free_path semaphore will be down
1656 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1657 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1659 extern spinlock_t dcache_lock;
1661 Index: linux-ia64/include/linux/fs.h
1662 ===================================================================
1663 --- linux-ia64.orig/include/linux/fs.h 2004-03-17 16:05:28.000000000 -0800
1664 +++ linux-ia64/include/linux/fs.h 2004-03-17 16:05:52.000000000 -0800
1665 @@ -73,6 +73,7 @@ extern int leases_enable, dir_notify_ena
1667 #define FMODE_READ 1
1668 #define FMODE_WRITE 2
1669 +#define FMODE_EXEC 4
1673 @@ -359,6 +360,9 @@ extern void set_bh_page(struct buffer_he
1674 #define ATTR_MTIME_SET 256
1675 #define ATTR_FORCE 512 /* Not a change, but a change it */
1676 #define ATTR_ATTR_FLAG 1024
1677 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1678 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1679 +#define ATTR_CTIME_SET 0x2000
1682 * This is the Inode Attributes structure, used for notify_change(). It
1683 @@ -496,6 +500,7 @@ struct inode {
1684 struct pipe_inode_info *i_pipe;
1685 struct block_device *i_bdev;
1686 struct char_device *i_cdev;
1687 + void *i_filterdata;
1689 unsigned long i_dnotify_mask; /* Directory notify events */
1690 struct dnotify_struct *i_dnotify; /* for directory notifications */
1691 @@ -598,6 +603,7 @@ struct file {
1693 /* needed for tty driver, and maybe others */
1695 + struct lookup_intent *f_it;
1697 /* preallocated helper kiobuf to speedup O_DIRECT */
1698 struct kiobuf *f_iobuf;
1699 @@ -726,6 +732,7 @@ struct nameidata {
1703 + struct lookup_intent *intent;
1707 @@ -846,7 +853,8 @@ extern int vfs_symlink(struct inode *, s
1708 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1709 extern int vfs_rmdir(struct inode *, struct dentry *);
1710 extern int vfs_unlink(struct inode *, struct dentry *);
1711 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1712 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1713 + struct inode *new_dir, struct dentry *new_dentry);
1717 @@ -920,21 +928,32 @@ struct file_operations {
1719 struct inode_operations {
1720 int (*create) (struct inode *,struct dentry *,int);
1721 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1722 struct dentry * (*lookup) (struct inode *,struct dentry *);
1723 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1724 int (*link) (struct dentry *,struct inode *,struct dentry *);
1725 + int (*link_raw) (struct nameidata *,struct nameidata *);
1726 int (*unlink) (struct inode *,struct dentry *);
1727 + int (*unlink_raw) (struct nameidata *);
1728 int (*symlink) (struct inode *,struct dentry *,const char *);
1729 + int (*symlink_raw) (struct nameidata *,const char *);
1730 int (*mkdir) (struct inode *,struct dentry *,int);
1731 + int (*mkdir_raw) (struct nameidata *,int);
1732 int (*rmdir) (struct inode *,struct dentry *);
1733 + int (*rmdir_raw) (struct nameidata *);
1734 int (*mknod) (struct inode *,struct dentry *,int,int);
1735 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1736 int (*rename) (struct inode *, struct dentry *,
1737 struct inode *, struct dentry *);
1738 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1739 int (*readlink) (struct dentry *, char *,int);
1740 int (*follow_link) (struct dentry *, struct nameidata *);
1741 void (*truncate) (struct inode *);
1742 int (*permission) (struct inode *, int);
1743 int (*revalidate) (struct dentry *);
1744 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1745 int (*setattr) (struct dentry *, struct iattr *);
1746 + int (*setattr_raw) (struct inode *, struct iattr *);
1747 int (*getattr) (struct dentry *, struct iattr *);
1748 int (*setxattr) (struct dentry *, const char *, const void *, size_t, int);
1749 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1750 @@ -1131,10 +1150,14 @@ static inline int get_lease(struct inode
1752 asmlinkage long sys_open(const char *, int, int);
1753 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1754 -extern int do_truncate(struct dentry *, loff_t start);
1755 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1757 extern struct file *filp_open(const char *, int, int);
1758 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1759 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1760 + struct nameidata *nd, struct lookup_intent *it);
1761 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1762 + int flags, struct lookup_intent *it);
1763 extern int filp_close(struct file *, fl_owner_t id);
1764 extern char * getname(const char *);
1766 @@ -1425,6 +1448,7 @@ typedef int (*read_actor_t)(read_descrip
1767 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1769 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1770 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1771 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1772 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1773 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1774 @@ -1436,6 +1460,8 @@ extern struct dentry * lookup_one_len(co
1775 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1776 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1777 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1778 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1779 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1781 extern void inode_init_once(struct inode *);
1782 extern void iput(struct inode *);
1783 @@ -1599,6 +1625,8 @@ extern struct file_operations generic_ro
1785 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1786 extern int vfs_follow_link(struct nameidata *, const char *);
1787 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1788 + struct lookup_intent *it);
1789 extern int page_readlink(struct dentry *, char *, int);
1790 extern int page_follow_link(struct dentry *, struct nameidata *);
1791 extern struct inode_operations page_symlink_inode_operations;
1792 Index: linux-ia64/include/linux/fs_struct.h
1793 ===================================================================
1794 --- linux-ia64.orig/include/linux/fs_struct.h 2004-03-17 15:47:15.000000000 -0800
1795 +++ linux-ia64/include/linux/fs_struct.h 2004-03-17 16:05:28.000000000 -0800
1796 @@ -37,10 +37,12 @@ static inline void set_fs_root(struct fs
1797 write_lock(&fs->lock);
1798 old_root = fs->root;
1799 old_rootmnt = fs->rootmnt;
1800 + PIN(dentry, mnt, 1);
1801 fs->rootmnt = mntget(mnt);
1802 fs->root = dget(dentry);
1803 write_unlock(&fs->lock);
1805 + UNPIN(old_root, old_rootmnt, 1);
1807 mntput(old_rootmnt);
1809 @@ -60,10 +62,12 @@ static inline void set_fs_pwd(struct fs_
1810 write_lock(&fs->lock);
1812 old_pwdmnt = fs->pwdmnt;
1813 + PIN(dentry, mnt, 0);
1814 fs->pwdmnt = mntget(mnt);
1815 fs->pwd = dget(dentry);
1816 write_unlock(&fs->lock);
1818 + UNPIN(old_pwd, old_pwdmnt, 0);
1822 Index: linux-ia64/kernel/exit.c
1823 ===================================================================
1824 --- linux-ia64.orig/kernel/exit.c 2004-03-17 15:47:15.000000000 -0800
1825 +++ linux-ia64/kernel/exit.c 2004-03-17 16:05:28.000000000 -0800
1826 @@ -347,11 +347,14 @@ static inline void __put_fs_struct(struc
1828 /* No need to hold fs->lock if we are killing it */
1829 if (atomic_dec_and_test(&fs->count)) {
1830 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1831 + UNPIN(fs->root, fs->rootmnt, 1);
1833 mntput(fs->rootmnt);
1837 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1839 mntput(fs->altrootmnt);
1841 Index: linux-ia64/kernel/fork.c
1842 ===================================================================
1843 --- linux-ia64.orig/kernel/fork.c 2004-03-17 15:47:15.000000000 -0800
1844 +++ linux-ia64/kernel/fork.c 2004-03-17 16:05:28.000000000 -0800
1845 @@ -463,10 +463,13 @@ static inline struct fs_struct *__copy_f
1846 fs->umask = old->umask;
1847 read_lock(&old->lock);
1848 fs->rootmnt = mntget(old->rootmnt);
1849 + PIN(old->pwd, old->pwdmnt, 0);
1850 + PIN(old->root, old->rootmnt, 1);
1851 fs->root = dget(old->root);
1852 fs->pwdmnt = mntget(old->pwdmnt);
1853 fs->pwd = dget(old->pwd);
1855 + PIN(old->altroot, old->altrootmnt, 1);
1856 fs->altrootmnt = mntget(old->altrootmnt);
1857 fs->altroot = dget(old->altroot);
1859 Index: linux-ia64/kernel/ksyms.c
1860 ===================================================================
1861 --- linux-ia64.orig/kernel/ksyms.c 2004-03-17 16:05:28.000000000 -0800
1862 +++ linux-ia64/kernel/ksyms.c 2004-03-17 16:05:51.000000000 -0800
1863 @@ -318,6 +318,7 @@ EXPORT_SYMBOL(read_cache_page);
1864 EXPORT_SYMBOL(set_page_dirty);
1865 EXPORT_SYMBOL(vfs_readlink);
1866 EXPORT_SYMBOL(vfs_follow_link);
1867 +EXPORT_SYMBOL(vfs_follow_link_it);
1868 EXPORT_SYMBOL(page_readlink);
1869 EXPORT_SYMBOL(page_follow_link);
1870 EXPORT_SYMBOL(page_symlink_inode_operations);