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 @@ -643,6 +680,27 @@ return_reval:
304 * Check the cached dentry for staleness.
307 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
309 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
310 + struct dentry *new;
311 + err = permission(dentry->d_parent->d_inode,
315 + new = real_lookup(dentry->d_parent,
316 + &dentry->d_name, 0, it);
317 + d_invalidate(dentry);
320 + err = PTR_ERR(new);
325 + if (!nd->dentry->d_inode)
328 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
330 if (!dentry->d_op->d_revalidate(dentry, 0)) {
331 @@ -656,15 +714,28 @@ out_dput:
336 + intent_release(it);
342 +int link_path_walk(const char * name, struct nameidata *nd)
344 + return link_path_walk_it(name, nd, NULL);
347 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
349 + current->total_link_count = 0;
350 + return link_path_walk_it(name, nd, it);
353 int path_walk(const char * name, struct nameidata *nd)
355 current->total_link_count = 0;
356 - return link_path_walk(name, nd);
357 + return link_path_walk_it(name, nd, NULL);
361 @@ -749,6 +820,17 @@ walk_init_root(const char *name, struct
365 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
366 + struct lookup_intent *it)
369 + if (path_init(path, flags, nd))
370 + error = path_walk_it(path, nd, it);
376 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
379 @@ -763,6 +845,7 @@ int path_init(const char *name, unsigned
381 nd->last_type = LAST_ROOT; /* if there are only slashes... */
385 return walk_init_root(name,nd);
386 read_lock(¤t->fs->lock);
387 @@ -777,7 +860,8 @@ int path_init(const char *name, unsigned
388 * needs parent already locked. Doesn't follow mounts.
391 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
392 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
393 + struct lookup_intent *it)
395 struct dentry * dentry;
397 @@ -800,13 +884,16 @@ struct dentry * lookup_hash(struct qstr
401 - dentry = cached_lookup(base, name, 0);
402 + dentry = cached_lookup(base, name, 0, it);
404 struct dentry *new = d_alloc(base, name);
405 dentry = ERR_PTR(-ENOMEM);
409 + if (inode->i_op->lookup_it)
410 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
412 dentry = inode->i_op->lookup(inode, new);
415 @@ -818,6 +905,12 @@ out:
419 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
421 + return lookup_hash_it(name, base, NULL);
426 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
428 @@ -839,7 +932,7 @@ struct dentry * lookup_one_len(const cha
430 this.hash = end_name_hash(hash);
432 - return lookup_hash(&this, base);
433 + return lookup_hash_it(&this, base, NULL);
435 return ERR_PTR(-EACCES);
437 @@ -870,6 +963,23 @@ int __user_walk(const char *name, unsign
441 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
442 + struct lookup_intent *it)
447 + tmp = getname(name);
448 + err = PTR_ERR(tmp);
449 + if (!IS_ERR(tmp)) {
451 + if (path_init(tmp, flags, nd))
452 + err = path_walk_it(tmp, nd, it);
459 * It's inline, so penalty for filesystems that don't use sticky bit is
461 @@ -967,7 +1077,8 @@ static inline int lookup_flags(unsigned
465 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
466 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
467 + struct lookup_intent *it)
471 @@ -980,12 +1091,15 @@ int vfs_create(struct inode *dir, struct
474 error = -EACCES; /* shouldn't it be ENOSYS? */
475 - if (!dir->i_op || !dir->i_op->create)
476 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
481 - error = dir->i_op->create(dir, dentry, mode);
482 + if (dir->i_op->create_it)
483 + error = dir->i_op->create_it(dir, dentry, mode, it);
485 + error = dir->i_op->create(dir, dentry, mode);
489 @@ -994,6 +1108,11 @@ exit_lock:
493 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
495 + return vfs_create_it(dir, dentry, mode, NULL);
501 @@ -1008,7 +1127,8 @@ exit_lock:
502 * for symlinks (where the permissions are checked later).
505 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
506 +int open_namei_it(const char *pathname, int flag, int mode,
507 + struct nameidata *nd, struct lookup_intent *it)
509 int acc_mode, error = 0;
511 @@ -1018,11 +1138,14 @@ int open_namei(const char * pathname, in
513 acc_mode = ACC_MODE(flag);
516 + it->it_flags = flag;
519 * The simplest case - just a plain lookup.
521 if (!(flag & O_CREAT)) {
522 - error = path_lookup(pathname, lookup_flags(flag), nd);
523 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
527 @@ -1032,6 +1155,10 @@ int open_namei(const char * pathname, in
529 * Create - we need to know the parent.
532 + it->it_create_mode = mode;
533 + it->it_op |= IT_CREAT;
535 error = path_lookup(pathname, LOOKUP_PARENT, nd);
538 @@ -1047,7 +1174,7 @@ int open_namei(const char * pathname, in
541 down(&dir->d_inode->i_sem);
542 - dentry = lookup_hash(&nd->last, nd->dentry);
543 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
546 error = PTR_ERR(dentry);
547 @@ -1056,11 +1183,12 @@ do_last:
551 + it->it_create_mode = mode;
552 /* Negative dentry, just create the file */
553 if (!dentry->d_inode) {
554 if (!IS_POSIXACL(dir->d_inode))
555 mode &= ~current->fs->umask;
556 - error = vfs_create(dir->d_inode, dentry, mode);
557 + error = vfs_create_it(dir->d_inode, dentry, mode, it);
558 up(&dir->d_inode->i_sem);
561 @@ -1164,7 +1292,7 @@ ok:
565 - error = do_truncate(dentry, 0);
566 + error = do_truncate(dentry, 0, 1);
568 put_write_access(inode);
570 @@ -1176,8 +1304,10 @@ ok:
574 + intent_release(it);
577 + intent_release(it);
581 @@ -1196,7 +1326,10 @@ do_link:
582 * are done. Procfs-like symlinks just set LAST_BIND.
584 UPDATE_ATIME(dentry->d_inode);
586 error = dentry->d_inode->i_op->follow_link(dentry, nd);
588 + intent_release(it);
592 @@ -1218,13 +1351,20 @@ do_link:
595 down(&dir->d_inode->i_sem);
596 - dentry = lookup_hash(&nd->last, nd->dentry);
597 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
598 putname(nd->last.name);
602 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
604 + return open_namei_it(pathname, flag, mode, nd, NULL);
609 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
610 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
611 + struct lookup_intent *it)
613 struct dentry *dentry;
615 @@ -1232,7 +1372,7 @@ static struct dentry *lookup_create(stru
616 dentry = ERR_PTR(-EEXIST);
617 if (nd->last_type != LAST_NORM)
619 - dentry = lookup_hash(&nd->last, nd->dentry);
620 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
623 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
624 @@ -1288,7 +1428,20 @@ asmlinkage long sys_mknod(const char * f
625 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
628 - dentry = lookup_create(&nd, 0);
630 + if (nd.last_type != LAST_NORM) {
634 + if (nd.dentry->d_inode->i_op->mknod_raw) {
635 + struct inode_operations *op = nd.dentry->d_inode->i_op;
636 + error = op->mknod_raw(&nd, mode, dev);
637 + /* the file system wants to use normal vfs path now */
638 + if (error != -EOPNOTSUPP)
642 + dentry = lookup_create(&nd, 0, NULL);
643 error = PTR_ERR(dentry);
645 if (!IS_POSIXACL(nd.dentry->d_inode))
646 @@ -1310,6 +1463,7 @@ asmlinkage long sys_mknod(const char * f
649 up(&nd.dentry->d_inode->i_sem);
654 @@ -1357,7 +1511,18 @@ asmlinkage long sys_mkdir(const char * p
655 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
658 - dentry = lookup_create(&nd, 1);
659 + if (nd.last_type != LAST_NORM) {
663 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
664 + struct inode_operations *op = nd.dentry->d_inode->i_op;
665 + error = op->mkdir_raw(&nd, mode);
666 + /* the file system wants to use normal vfs path now */
667 + if (error != -EOPNOTSUPP)
670 + dentry = lookup_create(&nd, 1, NULL);
671 error = PTR_ERR(dentry);
672 if (!IS_ERR(dentry)) {
673 if (!IS_POSIXACL(nd.dentry->d_inode))
674 @@ -1366,6 +1531,7 @@ asmlinkage long sys_mkdir(const char * p
677 up(&nd.dentry->d_inode->i_sem);
682 @@ -1466,8 +1632,16 @@ asmlinkage long sys_rmdir(const char * p
686 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
687 + struct inode_operations *op = nd.dentry->d_inode->i_op;
689 + error = op->rmdir_raw(&nd);
690 + /* the file system wants to use normal vfs path now */
691 + if (error != -EOPNOTSUPP)
694 down(&nd.dentry->d_inode->i_sem);
695 - dentry = lookup_hash(&nd.last, nd.dentry);
696 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
697 error = PTR_ERR(dentry);
698 if (!IS_ERR(dentry)) {
699 error = vfs_rmdir(nd.dentry->d_inode, dentry);
700 @@ -1525,8 +1699,15 @@ asmlinkage long sys_unlink(const char *
702 if (nd.last_type != LAST_NORM)
704 + if (nd.dentry->d_inode->i_op->unlink_raw) {
705 + struct inode_operations *op = nd.dentry->d_inode->i_op;
706 + error = op->unlink_raw(&nd);
707 + /* the file system wants to use normal vfs path now */
708 + if (error != -EOPNOTSUPP)
711 down(&nd.dentry->d_inode->i_sem);
712 - dentry = lookup_hash(&nd.last, nd.dentry);
713 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
714 error = PTR_ERR(dentry);
715 if (!IS_ERR(dentry)) {
716 /* Why not before? Because we want correct error value */
717 @@ -1593,15 +1774,27 @@ asmlinkage long sys_symlink(const char *
718 error = path_lookup(to, LOOKUP_PARENT, &nd);
721 - dentry = lookup_create(&nd, 0);
722 + if (nd.last_type != LAST_NORM) {
726 + if (nd.dentry->d_inode->i_op->symlink_raw) {
727 + struct inode_operations *op = nd.dentry->d_inode->i_op;
728 + error = op->symlink_raw(&nd, from);
729 + /* the file system wants to use normal vfs path now */
730 + if (error != -EOPNOTSUPP)
733 + dentry = lookup_create(&nd, 0, NULL);
734 error = PTR_ERR(dentry);
735 if (!IS_ERR(dentry)) {
736 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
739 up(&nd.dentry->d_inode->i_sem);
747 @@ -1677,7 +1870,18 @@ asmlinkage long sys_link(const char * ol
749 if (old_nd.mnt != nd.mnt)
751 - new_dentry = lookup_create(&nd, 0);
752 + if (nd.last_type != LAST_NORM) {
756 + if (nd.dentry->d_inode->i_op->link_raw) {
757 + struct inode_operations *op = nd.dentry->d_inode->i_op;
758 + error = op->link_raw(&old_nd, &nd);
759 + /* the file system wants to use normal vfs path now */
760 + if (error != -EOPNOTSUPP)
763 + new_dentry = lookup_create(&nd, 0, NULL);
764 error = PTR_ERR(new_dentry);
765 if (!IS_ERR(new_dentry)) {
766 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
767 @@ -1721,7 +1925,7 @@ exit:
770 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
771 - struct inode *new_dir, struct dentry *new_dentry)
772 + struct inode *new_dir, struct dentry *new_dentry)
775 struct inode *target;
776 @@ -1800,7 +2004,7 @@ out_unlock:
779 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
780 - struct inode *new_dir, struct dentry *new_dentry)
781 + struct inode *new_dir, struct dentry *new_dentry)
785 @@ -1888,9 +2092,18 @@ static inline int do_rename(const char *
786 if (newnd.last_type != LAST_NORM)
789 + if (old_dir->d_inode->i_op->rename_raw) {
791 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
793 + /* the file system wants to use normal vfs path now */
794 + if (error != -EOPNOTSUPP)
798 double_lock(new_dir, old_dir);
800 - old_dentry = lookup_hash(&oldnd.last, old_dir);
801 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
802 error = PTR_ERR(old_dentry);
803 if (IS_ERR(old_dentry))
805 @@ -1906,16 +2119,16 @@ static inline int do_rename(const char *
806 if (newnd.last.name[newnd.last.len])
809 - new_dentry = lookup_hash(&newnd.last, new_dir);
810 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
811 error = PTR_ERR(new_dentry);
812 if (IS_ERR(new_dentry))
817 error = vfs_rename(old_dir->d_inode, old_dentry,
818 new_dir->d_inode, new_dentry);
824 @@ -1966,20 +2179,26 @@ out:
828 -__vfs_follow_link(struct nameidata *nd, const char *link)
829 +__vfs_follow_link(struct nameidata *nd, const char *link,
830 + struct lookup_intent *it)
839 + else if (it != nd->intent)
840 + printk("it != nd->intent: tell phil@clusterfs.com\n");
844 if (!walk_init_root(link, nd))
845 /* weird __emul_prefix() stuff did it */
848 - res = link_path_walk(link, nd);
849 + res = link_path_walk_it(link, nd, it);
851 if (current->link_count || res || nd->last_type!=LAST_NORM)
853 @@ -2003,7 +2222,13 @@ fail:
855 int vfs_follow_link(struct nameidata *nd, const char *link)
857 - return __vfs_follow_link(nd, link);
858 + return __vfs_follow_link(nd, link, NULL);
861 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
862 + struct lookup_intent *it)
864 + return __vfs_follow_link(nd, link, it);
867 /* get the link contents into pagecache */
868 @@ -2045,7 +2270,7 @@ int page_follow_link(struct dentry *dent
870 struct page *page = NULL;
871 char *s = page_getlink(dentry, &page);
872 - int res = __vfs_follow_link(nd, s);
873 + int res = __vfs_follow_link(nd, s, NULL);
876 page_cache_release(page);
877 Index: linux-ia64/fs/namespace.c
878 ===================================================================
879 --- linux-ia64.orig/fs/namespace.c 2004-03-17 15:47:15.000000000 -0800
880 +++ linux-ia64/fs/namespace.c 2004-03-17 16:05:28.000000000 -0800
881 @@ -98,6 +98,7 @@ static void detach_mnt(struct vfsmount *
883 old_nd->dentry = mnt->mnt_mountpoint;
884 old_nd->mnt = mnt->mnt_parent;
885 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
886 mnt->mnt_parent = mnt;
887 mnt->mnt_mountpoint = mnt->mnt_root;
888 list_del_init(&mnt->mnt_child);
889 @@ -109,6 +110,7 @@ static void attach_mnt(struct vfsmount *
891 mnt->mnt_parent = mntget(nd->mnt);
892 mnt->mnt_mountpoint = dget(nd->dentry);
893 + PIN(nd->dentry, nd->mnt, 1);
894 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
895 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
896 nd->dentry->d_mounted++;
897 @@ -488,14 +490,17 @@ static int do_loopback(struct nameidata
899 struct nameidata old_nd;
900 struct vfsmount *mnt = NULL;
901 + struct lookup_intent it = { .it_op = IT_GETATTR };
902 int err = mount_is_safe(nd);
905 if (!old_name || !*old_name)
907 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
909 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
911 + intent_release(&it);
915 down_write(¤t->namespace->sem);
917 @@ -518,6 +523,7 @@ static int do_loopback(struct nameidata
920 up_write(¤t->namespace->sem);
921 + intent_release(&it);
922 path_release(&old_nd);
925 @@ -701,6 +707,7 @@ long do_mount(char * dev_name, char * di
926 unsigned long flags, void *data_page)
929 + struct lookup_intent it = { .it_op = IT_GETATTR };
933 @@ -725,9 +732,11 @@ long do_mount(char * dev_name, char * di
934 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
936 /* ... and get the mountpoint */
937 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
939 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
941 + intent_release(&it);
945 if (flags & MS_REMOUNT)
946 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
947 @@ -739,6 +747,8 @@ long do_mount(char * dev_name, char * di
949 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
950 dev_name, data_page);
952 + intent_release(&it);
956 @@ -904,6 +914,8 @@ asmlinkage long sys_pivot_root(const cha
958 struct vfsmount *tmp;
959 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
960 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
961 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
964 if (!capable(CAP_SYS_ADMIN))
965 @@ -911,14 +923,14 @@ asmlinkage long sys_pivot_root(const cha
969 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
970 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
974 if (!check_mnt(new_nd.mnt))
977 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
978 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
982 @@ -973,8 +985,10 @@ out2:
983 up(&old_nd.dentry->d_inode->i_zombie);
984 up_write(¤t->namespace->sem);
985 path_release(&user_nd);
986 + intent_release(&old_it);
987 path_release(&old_nd);
989 + intent_release(&new_it);
990 path_release(&new_nd);
993 Index: linux-ia64/fs/open.c
994 ===================================================================
995 --- linux-ia64.orig/fs/open.c 2004-03-17 15:47:15.000000000 -0800
996 +++ linux-ia64/fs/open.c 2004-03-17 16:05:28.000000000 -0800
998 #include <asm/uaccess.h>
1000 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1001 +extern int path_walk_it(const char *name, struct nameidata *nd,
1002 + struct lookup_intent *it);
1004 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1006 @@ -95,9 +97,10 @@ void fd_install(unsigned int fd, struct
1007 write_unlock(&files->file_lock);
1010 -int do_truncate(struct dentry *dentry, loff_t length)
1011 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1013 struct inode *inode = dentry->d_inode;
1014 + struct inode_operations *op = dentry->d_inode->i_op;
1016 struct iattr newattrs;
1018 @@ -109,7 +112,13 @@ int do_truncate(struct dentry *dentry, l
1019 down(&inode->i_sem);
1020 newattrs.ia_size = length;
1021 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1022 - error = notify_change(dentry, &newattrs);
1023 + if (called_from_open)
1024 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1025 + if (op->setattr_raw) {
1026 + newattrs.ia_valid |= ATTR_RAW;
1027 + error = op->setattr_raw(inode, &newattrs);
1029 + error = notify_change(dentry, &newattrs);
1031 up_write(&inode->i_alloc_sem);
1033 @@ -120,12 +129,13 @@ static inline long do_sys_truncate(const
1034 struct nameidata nd;
1035 struct inode * inode;
1037 + struct lookup_intent it = { .it_op = IT_GETATTR };
1040 if (length < 0) /* sorry, but loff_t says... */
1043 - error = user_path_walk(path, &nd);
1044 + error = user_path_walk_it(path, &nd, &it);
1047 inode = nd.dentry->d_inode;
1048 @@ -165,11 +175,13 @@ static inline long do_sys_truncate(const
1049 error = locks_verify_truncate(inode, NULL, length);
1052 - error = do_truncate(nd.dentry, length);
1053 + intent_release(&it);
1054 + error = do_truncate(nd.dentry, length, 0);
1056 put_write_access(inode);
1059 + intent_release(&it);
1063 @@ -217,7 +229,7 @@ static inline long do_sys_ftruncate(unsi
1065 error = locks_verify_truncate(inode, file, length);
1067 - error = do_truncate(dentry, length);
1068 + error = do_truncate(dentry, length, 0);
1072 @@ -262,11 +274,13 @@ asmlinkage long sys_utime(char * filenam
1073 struct inode * inode;
1074 struct iattr newattrs;
1076 - error = user_path_walk(filename, &nd);
1077 + error = user_path_walk_it(filename, &nd, NULL);
1080 inode = nd.dentry->d_inode;
1082 + /* this is safe without a Lustre lock because it only depends
1083 + on the super block */
1085 if (IS_RDONLY(inode))
1087 @@ -281,11 +295,25 @@ asmlinkage long sys_utime(char * filenam
1090 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1094 + if (inode->i_op->setattr_raw) {
1095 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1097 + newattrs.ia_valid |= ATTR_RAW;
1098 + error = op->setattr_raw(inode, &newattrs);
1099 + /* the file system wants to use normal vfs path now */
1100 + if (error != -EOPNOTSUPP)
1101 + goto dput_and_out;
1106 if (current->fsuid != inode->i_uid &&
1107 (error = permission(inode,MAY_WRITE)) != 0)
1111 error = notify_change(nd.dentry, &newattrs);
1114 @@ -306,12 +334,14 @@ asmlinkage long sys_utimes(char * filena
1115 struct inode * inode;
1116 struct iattr newattrs;
1118 - error = user_path_walk(filename, &nd);
1119 + error = user_path_walk_it(filename, &nd, NULL);
1123 inode = nd.dentry->d_inode;
1125 + /* this is safe without a Lustre lock because it only depends
1126 + on the super block */
1128 if (IS_RDONLY(inode))
1130 @@ -326,7 +356,20 @@ asmlinkage long sys_utimes(char * filena
1131 newattrs.ia_atime = times[0].tv_sec;
1132 newattrs.ia_mtime = times[1].tv_sec;
1133 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1137 + if (inode->i_op->setattr_raw) {
1138 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1140 + newattrs.ia_valid |= ATTR_RAW;
1141 + error = op->setattr_raw(inode, &newattrs);
1142 + /* the file system wants to use normal vfs path now */
1143 + if (error != -EOPNOTSUPP)
1144 + goto dput_and_out;
1149 if (current->fsuid != inode->i_uid &&
1150 (error = permission(inode,MAY_WRITE)) != 0)
1152 @@ -349,6 +392,7 @@ asmlinkage long sys_access(const char *
1153 int old_fsuid, old_fsgid;
1154 kernel_cap_t old_cap;
1156 + struct lookup_intent it = { .it_op = IT_GETATTR };
1158 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1160 @@ -366,13 +410,14 @@ asmlinkage long sys_access(const char *
1162 current->cap_effective = current->cap_permitted;
1164 - res = user_path_walk(filename, &nd);
1165 + res = user_path_walk_it(filename, &nd, &it);
1167 res = permission(nd.dentry->d_inode, mode);
1168 /* SuS v2 requires we report a read only fs too */
1169 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1170 && !special_file(nd.dentry->d_inode->i_mode))
1172 + intent_release(&it);
1176 @@ -387,8 +432,9 @@ asmlinkage long sys_chdir(const char * f
1179 struct nameidata nd;
1180 + struct lookup_intent it = { .it_op = IT_GETATTR };
1182 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1183 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1187 @@ -399,6 +445,7 @@ asmlinkage long sys_chdir(const char * f
1188 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1191 + intent_release(&it);
1195 @@ -438,9 +485,10 @@ asmlinkage long sys_chroot(const char *
1198 struct nameidata nd;
1199 + struct lookup_intent it = { .it_op = IT_GETATTR };
1201 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1202 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1203 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1204 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1208 @@ -456,39 +504,56 @@ asmlinkage long sys_chroot(const char *
1212 + intent_release(&it);
1218 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1219 +int chmod_common(struct dentry *dentry, mode_t mode)
1221 - struct inode * inode;
1222 - struct dentry * dentry;
1223 - struct file * file;
1225 + struct inode *inode = dentry->d_inode;
1226 struct iattr newattrs;
1231 + if (IS_RDONLY(inode))
1234 - dentry = file->f_dentry;
1235 - inode = dentry->d_inode;
1236 + if (inode->i_op->setattr_raw) {
1237 + newattrs.ia_mode = mode;
1238 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1239 + newattrs.ia_valid |= ATTR_RAW;
1240 + err = inode->i_op->setattr_raw(inode, &newattrs);
1241 + /* the file system wants to use normal vfs path now */
1242 + if (err != -EOPNOTSUPP)
1247 - if (IS_RDONLY(inode))
1250 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1254 if (mode == (mode_t) -1)
1255 mode = inode->i_mode;
1256 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1257 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1258 err = notify_change(dentry, &newattrs);
1265 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1267 + struct file * file;
1274 + err = chmod_common(file->f_dentry, mode);
1279 @@ -497,30 +562,14 @@ out:
1280 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1282 struct nameidata nd;
1283 - struct inode * inode;
1285 - struct iattr newattrs;
1287 error = user_path_walk(filename, &nd);
1290 - inode = nd.dentry->d_inode;
1293 - if (IS_RDONLY(inode))
1294 - goto dput_and_out;
1297 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1298 - goto dput_and_out;
1299 + error = chmod_common(nd.dentry, mode);
1301 - if (mode == (mode_t) -1)
1302 - mode = inode->i_mode;
1303 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1304 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1305 - error = notify_change(nd.dentry, &newattrs);
1311 @@ -540,6 +589,20 @@ static int chown_common(struct dentry *
1313 if (IS_RDONLY(inode))
1316 + if (inode->i_op->setattr_raw) {
1317 + struct inode_operations *op = dentry->d_inode->i_op;
1319 + newattrs.ia_uid = user;
1320 + newattrs.ia_gid = group;
1321 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1322 + newattrs.ia_valid |= ATTR_RAW;
1323 + error = op->setattr_raw(inode, &newattrs);
1324 + /* the file system wants to use normal vfs path now */
1325 + if (error != -EOPNOTSUPP)
1330 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1332 @@ -644,6 +707,7 @@ struct file *filp_open(const char * file
1334 int namei_flags, error;
1335 struct nameidata nd;
1336 + struct lookup_intent it = { .it_op = IT_OPEN };
1338 namei_flags = flags;
1339 if ((namei_flags+1) & O_ACCMODE)
1340 @@ -651,14 +715,15 @@ struct file *filp_open(const char * file
1341 if (namei_flags & O_TRUNC)
1344 - error = open_namei(filename, namei_flags, mode, &nd);
1346 - return dentry_open(nd.dentry, nd.mnt, flags);
1347 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1349 + return ERR_PTR(error);
1351 - return ERR_PTR(error);
1352 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1355 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1356 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1357 + int flags, struct lookup_intent *it)
1360 struct inode *inode;
1361 @@ -695,7 +760,9 @@ struct file *dentry_open(struct dentry *
1364 if (f->f_op && f->f_op->open) {
1366 error = f->f_op->open(inode,f);
1371 @@ -708,6 +775,7 @@ struct file *dentry_open(struct dentry *
1372 inode->i_mapping->a_ops->direct_sector_IO)))
1375 + intent_release(it);
1379 @@ -722,11 +790,17 @@ cleanup_all:
1383 + intent_release(it);
1386 return ERR_PTR(error);
1389 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1391 + return dentry_open_it(dentry, mnt, flags, NULL);
1395 * Find an empty file descriptor entry, and mark it busy.
1397 Index: linux-ia64/fs/stat.c
1398 ===================================================================
1399 --- linux-ia64.orig/fs/stat.c 2004-03-17 15:47:15.000000000 -0800
1400 +++ linux-ia64/fs/stat.c 2004-03-17 16:06:13.000000000 -0800
1402 * Revalidate the inode. This is required for proper NFS attribute caching.
1404 static __inline__ int
1405 -do_revalidate(struct dentry *dentry)
1406 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1408 struct inode * inode = dentry->d_inode;
1409 - if (inode->i_op && inode->i_op->revalidate)
1410 + if (inode->i_op && inode->i_op->revalidate_it)
1411 + return inode->i_op->revalidate_it(dentry, it);
1412 + else if (inode->i_op && inode->i_op->revalidate)
1413 return inode->i_op->revalidate(dentry);
1416 @@ -143,13 +145,15 @@ static int cp_new_stat(struct inode * in
1417 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1419 struct nameidata nd;
1420 + struct lookup_intent it = { .it_op = IT_GETATTR };
1423 - error = user_path_walk(filename, &nd);
1424 + error = user_path_walk_it(filename, &nd, &it);
1426 - error = do_revalidate(nd.dentry);
1427 + error = do_revalidate(nd.dentry, &it);
1429 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1430 + intent_release(&it);
1434 @@ -159,13 +163,15 @@ asmlinkage long sys_stat(char * filename
1435 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1437 struct nameidata nd;
1438 + struct lookup_intent it = { .it_op = IT_GETATTR };
1441 - error = user_path_walk(filename, &nd);
1442 + error = user_path_walk_it(filename, &nd, &it);
1444 - error = do_revalidate(nd.dentry);
1445 + error = do_revalidate(nd.dentry, &it);
1447 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1448 + intent_release(&it);
1452 @@ -180,13 +186,15 @@ asmlinkage long sys_newstat(char * filen
1453 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1455 struct nameidata nd;
1456 + struct lookup_intent it = { .it_op = IT_GETATTR };
1459 - error = user_path_walk_link(filename, &nd);
1460 + error = user_path_walk_link_it(filename, &nd, &it);
1462 - error = do_revalidate(nd.dentry);
1463 + error = do_revalidate(nd.dentry, &it);
1465 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1466 + intent_release(&it);
1470 @@ -197,13 +205,15 @@ asmlinkage long sys_lstat(char * filenam
1471 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1473 struct nameidata nd;
1474 + struct lookup_intent it = { .it_op = IT_GETATTR };
1477 - error = user_path_walk_link(filename, &nd);
1478 + error = user_path_walk_link_it(filename, &nd, &it);
1480 - error = do_revalidate(nd.dentry);
1481 + error = do_revalidate(nd.dentry, &it);
1483 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1484 + intent_release(&it);
1488 @@ -224,7 +234,7 @@ asmlinkage long sys_fstat(unsigned int f
1490 struct dentry * dentry = f->f_dentry;
1492 - err = do_revalidate(dentry);
1493 + err = do_revalidate(dentry, NULL);
1495 err = cp_old_stat(dentry->d_inode, statbuf);
1497 @@ -243,7 +253,7 @@ asmlinkage long sys_newfstat(unsigned in
1499 struct dentry * dentry = f->f_dentry;
1501 - err = do_revalidate(dentry);
1502 + err = do_revalidate(dentry, NULL);
1504 err = cp_new_stat(dentry->d_inode, statbuf);
1506 @@ -265,7 +275,7 @@ asmlinkage long sys_readlink(const char
1509 if (inode->i_op && inode->i_op->readlink &&
1510 - !(error = do_revalidate(nd.dentry))) {
1511 + !(error = do_revalidate(nd.dentry, NULL))) {
1512 UPDATE_ATIME(inode);
1513 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1515 @@ -341,12 +351,14 @@ asmlinkage long sys_stat64(char * filena
1517 struct nameidata nd;
1519 + struct lookup_intent it = { .it_op = IT_GETATTR };
1521 - error = user_path_walk(filename, &nd);
1522 + error = user_path_walk_it(filename, &nd, &it);
1524 - error = do_revalidate(nd.dentry);
1525 + error = do_revalidate(nd.dentry, &it);
1527 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1528 + intent_release(&it);
1532 @@ -356,12 +368,14 @@ asmlinkage long sys_lstat64(char * filen
1534 struct nameidata nd;
1536 + struct lookup_intent it = { .it_op = IT_GETATTR };
1538 - error = user_path_walk_link(filename, &nd);
1539 + error = user_path_walk_link_it(filename, &nd, &it);
1541 - error = do_revalidate(nd.dentry);
1542 + error = do_revalidate(nd.dentry, &it);
1544 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1545 + intent_release(&it);
1549 @@ -376,7 +390,7 @@ asmlinkage long sys_fstat64(unsigned lon
1551 struct dentry * dentry = f->f_dentry;
1553 - err = do_revalidate(dentry);
1554 + err = do_revalidate(dentry, NULL);
1556 err = cp_new_stat64(dentry->d_inode, statbuf);
1558 Index: linux-ia64/include/linux/dcache.h
1559 ===================================================================
1560 --- linux-ia64.orig/include/linux/dcache.h 2004-03-17 15:47:15.000000000 -0800
1561 +++ linux-ia64/include/linux/dcache.h 2004-03-17 16:05:28.000000000 -0800
1563 #include <asm/atomic.h>
1564 #include <linux/mount.h>
1565 #include <linux/kernel.h>
1566 +#include <linux/string.h>
1568 +#define IT_OPEN 0x0001
1569 +#define IT_CREAT 0x0002
1570 +#define IT_READDIR 0x0004
1571 +#define IT_GETATTR 0x0008
1572 +#define IT_LOOKUP 0x0010
1573 +#define IT_UNLINK 0x0020
1574 +#define IT_GETXATTR 0x0040
1575 +#define IT_EXEC 0x0080
1576 +#define IT_PIN 0x0100
1578 +#define IT_FL_LOCKED 0x0001
1579 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1581 +#define INTENT_MAGIC 0x19620323
1584 +struct lustre_intent_data {
1585 + int it_disposition;
1587 + __u64 it_lock_handle;
1592 +struct lookup_intent {
1594 + void (*it_op_release)(struct lookup_intent *);
1597 + int it_create_mode;
1599 + struct lustre_intent_data lustre;
1603 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1605 + memset(it, 0, sizeof(*it));
1606 + it->it_magic = INTENT_MAGIC;
1608 + it->it_flags = flags;
1613 * linux/include/linux/dcache.h
1614 @@ -96,8 +141,22 @@ struct dentry_operations {
1615 int (*d_delete)(struct dentry *);
1616 void (*d_release)(struct dentry *);
1617 void (*d_iput)(struct dentry *, struct inode *);
1618 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1619 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1620 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1623 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1624 + de->d_op->d_pin(de, mnt, flag);
1625 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1626 + de->d_op->d_unpin(de, mnt, flag);
1629 +/* defined in fs/namei.c */
1630 +extern void intent_release(struct lookup_intent *it);
1631 +/* defined in fs/dcache.c */
1632 +extern void __d_rehash(struct dentry * entry, int lock);
1634 /* the dentry parameter passed to d_hash and d_compare is the parent
1635 * directory of the entries to be compared. It is used in case these
1636 * functions need any directory specific information for determining
1637 @@ -129,6 +188,7 @@ d_iput: no no yes
1638 * s_nfsd_free_path semaphore will be down
1640 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1641 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1643 extern spinlock_t dcache_lock;
1645 Index: linux-ia64/include/linux/fs.h
1646 ===================================================================
1647 --- linux-ia64.orig/include/linux/fs.h 2004-03-17 16:05:28.000000000 -0800
1648 +++ linux-ia64/include/linux/fs.h 2004-03-17 16:05:52.000000000 -0800
1649 @@ -73,6 +73,7 @@ extern int leases_enable, dir_notify_ena
1651 #define FMODE_READ 1
1652 #define FMODE_WRITE 2
1653 +#define FMODE_EXEC 4
1657 @@ -359,6 +360,9 @@ extern void set_bh_page(struct buffer_he
1658 #define ATTR_MTIME_SET 256
1659 #define ATTR_FORCE 512 /* Not a change, but a change it */
1660 #define ATTR_ATTR_FLAG 1024
1661 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1662 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1663 +#define ATTR_CTIME_SET 0x2000
1666 * This is the Inode Attributes structure, used for notify_change(). It
1667 @@ -496,6 +500,7 @@ struct inode {
1668 struct pipe_inode_info *i_pipe;
1669 struct block_device *i_bdev;
1670 struct char_device *i_cdev;
1671 + void *i_filterdata;
1673 unsigned long i_dnotify_mask; /* Directory notify events */
1674 struct dnotify_struct *i_dnotify; /* for directory notifications */
1675 @@ -598,6 +603,7 @@ struct file {
1677 /* needed for tty driver, and maybe others */
1679 + struct lookup_intent *f_it;
1681 /* preallocated helper kiobuf to speedup O_DIRECT */
1682 struct kiobuf *f_iobuf;
1683 @@ -726,6 +732,7 @@ struct nameidata {
1687 + struct lookup_intent *intent;
1691 @@ -846,7 +853,8 @@ extern int vfs_symlink(struct inode *, s
1692 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1693 extern int vfs_rmdir(struct inode *, struct dentry *);
1694 extern int vfs_unlink(struct inode *, struct dentry *);
1695 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1696 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1697 + struct inode *new_dir, struct dentry *new_dentry);
1701 @@ -920,21 +928,32 @@ struct file_operations {
1703 struct inode_operations {
1704 int (*create) (struct inode *,struct dentry *,int);
1705 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1706 struct dentry * (*lookup) (struct inode *,struct dentry *);
1707 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1708 int (*link) (struct dentry *,struct inode *,struct dentry *);
1709 + int (*link_raw) (struct nameidata *,struct nameidata *);
1710 int (*unlink) (struct inode *,struct dentry *);
1711 + int (*unlink_raw) (struct nameidata *);
1712 int (*symlink) (struct inode *,struct dentry *,const char *);
1713 + int (*symlink_raw) (struct nameidata *,const char *);
1714 int (*mkdir) (struct inode *,struct dentry *,int);
1715 + int (*mkdir_raw) (struct nameidata *,int);
1716 int (*rmdir) (struct inode *,struct dentry *);
1717 + int (*rmdir_raw) (struct nameidata *);
1718 int (*mknod) (struct inode *,struct dentry *,int,int);
1719 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1720 int (*rename) (struct inode *, struct dentry *,
1721 struct inode *, struct dentry *);
1722 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1723 int (*readlink) (struct dentry *, char *,int);
1724 int (*follow_link) (struct dentry *, struct nameidata *);
1725 void (*truncate) (struct inode *);
1726 int (*permission) (struct inode *, int);
1727 int (*revalidate) (struct dentry *);
1728 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1729 int (*setattr) (struct dentry *, struct iattr *);
1730 + int (*setattr_raw) (struct inode *, struct iattr *);
1731 int (*getattr) (struct dentry *, struct iattr *);
1732 int (*setxattr) (struct dentry *, const char *, const void *, size_t, int);
1733 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1734 @@ -1131,10 +1150,14 @@ static inline int get_lease(struct inode
1736 asmlinkage long sys_open(const char *, int, int);
1737 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1738 -extern int do_truncate(struct dentry *, loff_t start);
1739 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1741 extern struct file *filp_open(const char *, int, int);
1742 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1743 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1744 + struct nameidata *nd, struct lookup_intent *it);
1745 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1746 + int flags, struct lookup_intent *it);
1747 extern int filp_close(struct file *, fl_owner_t id);
1748 extern char * getname(const char *);
1750 @@ -1425,6 +1448,7 @@ typedef int (*read_actor_t)(read_descrip
1751 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1753 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1754 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1755 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1756 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1757 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1758 @@ -1436,6 +1460,8 @@ extern struct dentry * lookup_one_len(co
1759 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1760 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1761 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1762 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1763 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1765 extern void inode_init_once(struct inode *);
1766 extern void iput(struct inode *);
1767 @@ -1599,6 +1625,8 @@ extern struct file_operations generic_ro
1769 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1770 extern int vfs_follow_link(struct nameidata *, const char *);
1771 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1772 + struct lookup_intent *it);
1773 extern int page_readlink(struct dentry *, char *, int);
1774 extern int page_follow_link(struct dentry *, struct nameidata *);
1775 extern struct inode_operations page_symlink_inode_operations;
1776 Index: linux-ia64/include/linux/fs_struct.h
1777 ===================================================================
1778 --- linux-ia64.orig/include/linux/fs_struct.h 2004-03-17 15:47:15.000000000 -0800
1779 +++ linux-ia64/include/linux/fs_struct.h 2004-03-17 16:05:28.000000000 -0800
1780 @@ -37,10 +37,12 @@ static inline void set_fs_root(struct fs
1781 write_lock(&fs->lock);
1782 old_root = fs->root;
1783 old_rootmnt = fs->rootmnt;
1784 + PIN(dentry, mnt, 1);
1785 fs->rootmnt = mntget(mnt);
1786 fs->root = dget(dentry);
1787 write_unlock(&fs->lock);
1789 + UNPIN(old_root, old_rootmnt, 1);
1791 mntput(old_rootmnt);
1793 @@ -60,10 +62,12 @@ static inline void set_fs_pwd(struct fs_
1794 write_lock(&fs->lock);
1796 old_pwdmnt = fs->pwdmnt;
1797 + PIN(dentry, mnt, 0);
1798 fs->pwdmnt = mntget(mnt);
1799 fs->pwd = dget(dentry);
1800 write_unlock(&fs->lock);
1802 + UNPIN(old_pwd, old_pwdmnt, 0);
1806 Index: linux-ia64/kernel/exit.c
1807 ===================================================================
1808 --- linux-ia64.orig/kernel/exit.c 2004-03-17 15:47:15.000000000 -0800
1809 +++ linux-ia64/kernel/exit.c 2004-03-17 16:05:28.000000000 -0800
1810 @@ -347,11 +347,14 @@ static inline void __put_fs_struct(struc
1812 /* No need to hold fs->lock if we are killing it */
1813 if (atomic_dec_and_test(&fs->count)) {
1814 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1815 + UNPIN(fs->root, fs->rootmnt, 1);
1817 mntput(fs->rootmnt);
1821 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1823 mntput(fs->altrootmnt);
1825 Index: linux-ia64/kernel/fork.c
1826 ===================================================================
1827 --- linux-ia64.orig/kernel/fork.c 2004-03-17 15:47:15.000000000 -0800
1828 +++ linux-ia64/kernel/fork.c 2004-03-17 16:05:28.000000000 -0800
1829 @@ -463,10 +463,13 @@ static inline struct fs_struct *__copy_f
1830 fs->umask = old->umask;
1831 read_lock(&old->lock);
1832 fs->rootmnt = mntget(old->rootmnt);
1833 + PIN(old->pwd, old->pwdmnt, 0);
1834 + PIN(old->root, old->rootmnt, 1);
1835 fs->root = dget(old->root);
1836 fs->pwdmnt = mntget(old->pwdmnt);
1837 fs->pwd = dget(old->pwd);
1839 + PIN(old->altroot, old->altrootmnt, 1);
1840 fs->altrootmnt = mntget(old->altrootmnt);
1841 fs->altroot = dget(old->altroot);
1843 Index: linux-ia64/kernel/ksyms.c
1844 ===================================================================
1845 --- linux-ia64.orig/kernel/ksyms.c 2004-03-17 16:05:28.000000000 -0800
1846 +++ linux-ia64/kernel/ksyms.c 2004-03-17 16:05:51.000000000 -0800
1847 @@ -318,6 +318,7 @@ EXPORT_SYMBOL(read_cache_page);
1848 EXPORT_SYMBOL(set_page_dirty);
1849 EXPORT_SYMBOL(vfs_readlink);
1850 EXPORT_SYMBOL(vfs_follow_link);
1851 +EXPORT_SYMBOL(vfs_follow_link_it);
1852 EXPORT_SYMBOL(page_readlink);
1853 EXPORT_SYMBOL(page_follow_link);
1854 EXPORT_SYMBOL(page_symlink_inode_operations);