1 Index: linux-2.4.21-40.EL/fs/dcache.c
2 ===================================================================
3 --- linux-2.4.21-40.EL.orig/fs/dcache.c
4 +++ linux-2.4.21-40.EL/fs/dcache.c
5 @@ -187,6 +187,13 @@ int d_invalidate(struct dentry * dentry)
6 spin_unlock(&dcache_lock);
10 + /* network invalidation by Lustre */
11 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
12 + spin_unlock(&dcache_lock);
17 * Check whether to do a partial shrink_dcache
18 * to get rid of unused child entries.
19 @@ -848,13 +855,19 @@ void d_delete(struct dentry * dentry)
20 * Adds a dentry to the hash according to its name.
23 -void d_rehash(struct dentry * entry)
24 +void __d_rehash(struct dentry * entry, int lock)
26 struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
27 if (!list_empty(&entry->d_hash)) BUG();
28 - spin_lock(&dcache_lock);
29 + if (lock) spin_lock(&dcache_lock);
30 list_add(&entry->d_hash, list);
31 - spin_unlock(&dcache_lock);
32 + if (lock) spin_unlock(&dcache_lock);
34 +EXPORT_SYMBOL(__d_rehash);
36 +void d_rehash(struct dentry * entry)
38 + __d_rehash(entry, 1);
41 #define do_switch(x,y) do { \
42 Index: linux-2.4.21-40.EL/fs/exec.c
43 ===================================================================
44 --- linux-2.4.21-40.EL.orig/fs/exec.c
45 +++ linux-2.4.21-40.EL/fs/exec.c
46 @@ -116,8 +116,10 @@ asmlinkage long sys_uselib(const char *
50 + struct lookup_intent it = { .it_op = IT_OPEN,
51 + .it_flags = FMODE_READ|FMODE_EXEC };
53 - error = user_path_walk(library, &nd);
54 + error = user_path_walk_it(library, &nd, &it);
58 @@ -129,7 +131,8 @@ asmlinkage long sys_uselib(const char *
62 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
63 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
64 + intent_release(&it);
65 error = PTR_ERR(file);
68 @@ -405,8 +408,10 @@ struct file *open_exec(const char *name)
72 + struct lookup_intent it = { .it_op = IT_OPEN,
73 + .it_flags = FMODE_READ|FMODE_EXEC };
75 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
76 + err = path_lookup_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
79 inode = nd.dentry->d_inode;
80 @@ -418,7 +423,8 @@ struct file *open_exec(const char *name)
84 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
85 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
86 + intent_release(&it);
88 err = deny_write_access(file);
90 @@ -430,6 +436,7 @@ out:
94 + intent_release(&it);
98 @@ -1383,7 +1390,7 @@ int do_coredump(long signr, int exit_cod
100 if (!file->f_op->write)
102 - if (do_truncate(file->f_dentry, 0) != 0)
103 + if (do_truncate(file->f_dentry, 0, 0) != 0)
106 retval = binfmt->core_dump(signr, regs, file);
107 Index: linux-2.4.21-40.EL/fs/namei.c
108 ===================================================================
109 --- linux-2.4.21-40.EL.orig/fs/namei.c
110 +++ linux-2.4.21-40.EL/fs/namei.c
112 * XEmacs seems to be relying on it...
115 +void intent_release(struct lookup_intent *it)
117 + if (it && it->it_op_release)
118 + it->it_op_release(it);
122 /* In order to reduce some races, while at the same time doing additional
123 * checking and hopefully speeding things up, we copy filenames to the
124 * kernel data space before using them..
125 @@ -260,10 +267,19 @@ void path_release(struct nameidata *nd)
126 * Internal lookup() using the new generic dcache.
129 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
130 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
131 + int flags, struct lookup_intent *it)
133 struct dentry * dentry = d_lookup(parent, name);
135 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
136 + if (!dentry->d_op->d_revalidate_it(dentry, flags, it) &&
137 + !d_invalidate(dentry)) {
143 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
144 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
146 @@ -281,11 +297,15 @@ static struct dentry * cached_lookup(str
147 * make sure that nobody added the entry to the dcache in the meantime..
150 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
151 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
152 + int flags, struct lookup_intent *it)
154 struct dentry * result;
155 struct inode *dir = parent->d_inode;
162 * First re-do the cached lookup just in case it was created
163 @@ -300,6 +320,9 @@ static struct dentry * real_lookup(struc
164 result = ERR_PTR(-ENOMEM);
167 + if (dir->i_op->lookup_it)
168 + result = dir->i_op->lookup_it(dir, dentry, it, flags);
170 result = dir->i_op->lookup(dir, dentry);
173 @@ -321,6 +344,15 @@ static struct dentry * real_lookup(struc
175 result = ERR_PTR(-ENOENT);
177 + } else if (result->d_op && result->d_op->d_revalidate_it) {
178 + if (!result->d_op->d_revalidate_it(result, flags, it) &&
179 + !d_invalidate(result)) {
182 + result = ERR_PTR(-ESTALE);
183 + if (!IS_ERR(result))
189 @@ -332,7 +364,8 @@ static struct dentry * real_lookup(struc
190 * Without that kind of total limit, nasty chains of consecutive
191 * symlinks can cause almost arbitrarily long lookups.
193 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
194 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
195 + struct lookup_intent *it)
198 if (current->link_count >= 8)
199 @@ -346,10 +379,12 @@ static inline int do_follow_link(struct
200 current->link_count++;
201 current->total_link_count++;
202 UPDATE_ATIME(dentry->d_inode);
204 err = dentry->d_inode->i_op->follow_link(dentry, nd);
205 current->link_count--;
208 + intent_release(it);
212 @@ -447,7 +482,8 @@ static inline void follow_dotdot(struct
214 * We expect 'base' to be positive and a directory.
216 -int link_path_walk(const char * name, struct nameidata *nd)
217 +int link_path_walk_it(const char *name, struct nameidata *nd,
218 + struct lookup_intent *it)
220 struct dentry *dentry;
222 @@ -524,12 +560,12 @@ int link_path_walk(const char * name, st
225 /* This does the actual lookups.. */
226 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
227 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
229 err = -EWOULDBLOCKIO;
232 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
233 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
234 err = PTR_ERR(dentry);
237 @@ -548,7 +584,7 @@ int link_path_walk(const char * name, st
239 if (inode->i_op->follow_link) {
240 struct vfsmount *mnt = mntget(nd->mnt);
241 - err = do_follow_link(dentry, nd);
242 + err = do_follow_link(dentry, nd, NULL);
246 @@ -565,7 +601,7 @@ int link_path_walk(const char * name, st
250 - if (!inode->i_op->lookup)
251 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
254 /* here ends the main loop */
255 @@ -592,12 +628,12 @@ last_component:
259 - dentry = cached_lookup(nd->dentry, &this, nd->flags);
260 + dentry = cached_lookup(nd->dentry, &this, nd->flags, it);
262 err = -EWOULDBLOCKIO;
265 - dentry = real_lookup(nd->dentry, &this, nd->flags);
266 + dentry = real_lookup(nd->dentry, &this, nd->flags, it);
267 err = PTR_ERR(dentry);
270 @@ -608,7 +644,7 @@ last_component:
271 if ((lookup_flags & LOOKUP_FOLLOW)
272 && inode && inode->i_op && inode->i_op->follow_link) {
273 struct vfsmount *mnt = mntget(nd->mnt);
274 - err = do_follow_link(dentry, nd);
275 + err = do_follow_link(dentry, nd, it);
279 @@ -623,7 +659,8 @@ last_component:
281 if (lookup_flags & LOOKUP_DIRECTORY) {
283 - if (!inode->i_op || !inode->i_op->lookup)
284 + if (!inode->i_op ||
285 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
289 @@ -641,12 +678,42 @@ lookup_parent:
290 nd->last_type = LAST_DOT;
291 else if (this.len == 2 && this.name[1] == '.')
292 nd->last_type = LAST_DOTDOT;
297 * We bypassed the ordinary revalidation routines.
298 * Check the cached dentry for staleness.
301 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
303 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
304 + struct dentry *new;
305 + err = permission(dentry->d_parent->d_inode,
309 + new = real_lookup(dentry->d_parent,
310 + &dentry->d_name, 0, it);
312 + err = PTR_ERR(new);
315 + d_invalidate(dentry);
319 + if (!nd->dentry->d_inode)
321 + if (lookup_flags & LOOKUP_DIRECTORY) {
323 + if (!nd->dentry->d_inode->i_op ||
324 + (!nd->dentry->d_inode->i_op->lookup &&
325 + !nd->dentry->d_inode->i_op->lookup_it))
329 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
331 if (!dentry->d_op->d_revalidate(dentry, 0)) {
332 @@ -660,15 +727,28 @@ out_dput:
337 + intent_release(it);
343 +int link_path_walk(const char * name, struct nameidata *nd)
345 + return link_path_walk_it(name, nd, NULL);
348 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
350 + current->total_link_count = 0;
351 + return link_path_walk_it(name, nd, it);
354 int path_walk(const char * name, struct nameidata *nd)
356 current->total_link_count = 0;
357 - return link_path_walk(name, nd);
358 + return link_path_walk_it(name, nd, NULL);
362 @@ -753,6 +833,17 @@ walk_init_root(const char *name, struct
366 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
367 + struct lookup_intent *it)
370 + if (path_init(path, flags, nd))
371 + error = path_walk_it(path, nd, it);
377 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
380 @@ -767,6 +858,7 @@ int path_init(const char *name, unsigned
382 nd->last_type = LAST_ROOT; /* if there are only slashes... */
386 return walk_init_root(name,nd);
387 read_lock(¤t->fs->lock);
388 @@ -781,7 +873,8 @@ int path_init(const char *name, unsigned
389 * needs parent already locked. Doesn't follow mounts.
392 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
393 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
394 + struct lookup_intent *it)
396 struct dentry * dentry;
398 @@ -804,13 +897,16 @@ struct dentry * lookup_hash(struct qstr
402 - dentry = cached_lookup(base, name, 0);
403 + dentry = cached_lookup(base, name, 0, it);
405 struct dentry *new = d_alloc(base, name);
406 dentry = ERR_PTR(-ENOMEM);
410 + if (inode->i_op->lookup_it)
411 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
413 dentry = inode->i_op->lookup(inode, new);
416 @@ -822,6 +918,12 @@ out:
420 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
422 + return lookup_hash_it(name, base, NULL);
427 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
429 @@ -843,7 +945,7 @@ struct dentry * lookup_one_len(const cha
431 this.hash = end_name_hash(hash);
433 - return lookup_hash(&this, base);
434 + return lookup_hash_it(&this, base, NULL);
436 return ERR_PTR(-EACCES);
438 @@ -874,6 +976,23 @@ int __user_walk(const char *name, unsign
442 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
443 + struct lookup_intent *it)
448 + tmp = getname(name);
449 + err = PTR_ERR(tmp);
450 + if (!IS_ERR(tmp)) {
452 + if (path_init(tmp, flags, nd))
453 + err = path_walk_it(tmp, nd, it);
460 * It's inline, so penalty for filesystems that don't use sticky bit is
462 @@ -971,7 +1090,8 @@ static inline int lookup_flags(unsigned
466 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
467 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
468 + struct lookup_intent *it)
472 @@ -984,12 +1104,15 @@ int vfs_create(struct inode *dir, struct
475 error = -EACCES; /* shouldn't it be ENOSYS? */
476 - if (!dir->i_op || !dir->i_op->create)
477 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
482 - error = dir->i_op->create(dir, dentry, mode);
483 + if (dir->i_op->create_it)
484 + error = dir->i_op->create_it(dir, dentry, mode, it);
486 + error = dir->i_op->create(dir, dentry, mode);
490 @@ -998,6 +1121,11 @@ exit_lock:
494 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
496 + return vfs_create_it(dir, dentry, mode, NULL);
502 @@ -1012,7 +1140,8 @@ exit_lock:
503 * for symlinks (where the permissions are checked later).
506 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
507 +int open_namei_it(const char *pathname, int flag, int mode,
508 + struct nameidata *nd, struct lookup_intent *it)
510 int acc_mode, error = 0;
512 @@ -1023,11 +1152,14 @@ int open_namei(const char * pathname, in
514 acc_mode = ACC_MODE(flag);
517 + it->it_flags = flag;
520 * The simplest case - just a plain lookup.
522 if (!(flag & O_CREAT)) {
523 - error = path_lookup(pathname, lookup_flags(flag), nd);
524 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
528 @@ -1037,6 +1169,10 @@ int open_namei(const char * pathname, in
530 * Create - we need to know the parent.
533 + it->it_create_mode = mode;
534 + it->it_op |= IT_CREAT;
536 error = path_lookup(pathname, LOOKUP_PARENT, nd);
539 @@ -1052,7 +1188,7 @@ int open_namei(const char * pathname, in
542 down(&dir->d_inode->i_sem);
543 - dentry = lookup_hash(&nd->last, nd->dentry);
544 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
547 error = PTR_ERR(dentry);
548 @@ -1061,11 +1197,12 @@ do_last:
552 + it->it_create_mode = mode;
553 /* Negative dentry, just create the file */
554 if (!dentry->d_inode) {
555 if (!IS_POSIXACL(dir->d_inode))
556 mode &= ~current->fs->umask;
557 - error = vfs_create(dir->d_inode, dentry, mode);
558 + error = vfs_create_it(dir->d_inode, dentry, mode, it);
559 up(&dir->d_inode->i_sem);
562 @@ -1169,7 +1306,7 @@ ok:
566 - error = do_truncate(dentry, 0);
567 + error = do_truncate(dentry, 0, 1);
569 put_write_access(inode);
571 @@ -1181,8 +1318,10 @@ ok:
575 + intent_release(it);
578 + intent_release(it);
582 @@ -1202,7 +1341,10 @@ do_link:
584 UPDATE_ATIME(dentry->d_inode);
585 mnt = mntget(nd->mnt);
587 error = dentry->d_inode->i_op->follow_link(dentry, nd);
589 + intent_release(it);
593 @@ -1225,13 +1367,20 @@ do_link:
596 down(&dir->d_inode->i_sem);
597 - dentry = lookup_hash(&nd->last, nd->dentry);
598 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
599 putname(nd->last.name);
603 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
605 + return open_namei_it(pathname, flag, mode, nd, NULL);
610 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
611 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
612 + struct lookup_intent *it)
614 struct dentry *dentry;
616 @@ -1239,7 +1388,7 @@ static struct dentry *lookup_create(stru
617 dentry = ERR_PTR(-EEXIST);
618 if (nd->last_type != LAST_NORM)
620 - dentry = lookup_hash(&nd->last, nd->dentry);
621 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
624 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
625 @@ -1295,7 +1444,20 @@ asmlinkage long sys_mknod(const char * f
626 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
629 - dentry = lookup_create(&nd, 0);
631 + if (nd.last_type != LAST_NORM) {
635 + if (nd.dentry->d_inode->i_op->mknod_raw) {
636 + struct inode_operations *op = nd.dentry->d_inode->i_op;
637 + error = op->mknod_raw(&nd, mode, dev);
638 + /* the file system wants to use normal vfs path now */
639 + if (error != -EOPNOTSUPP)
643 + dentry = lookup_create(&nd, 0, NULL);
644 error = PTR_ERR(dentry);
646 if (!IS_POSIXACL(nd.dentry->d_inode))
647 @@ -1317,6 +1479,7 @@ asmlinkage long sys_mknod(const char * f
650 up(&nd.dentry->d_inode->i_sem);
655 @@ -1364,7 +1527,18 @@ asmlinkage long sys_mkdir(const char * p
656 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
659 - dentry = lookup_create(&nd, 1);
660 + if (nd.last_type != LAST_NORM) {
664 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
665 + struct inode_operations *op = nd.dentry->d_inode->i_op;
666 + error = op->mkdir_raw(&nd, mode);
667 + /* the file system wants to use normal vfs path now */
668 + if (error != -EOPNOTSUPP)
671 + dentry = lookup_create(&nd, 1, NULL);
672 error = PTR_ERR(dentry);
673 if (!IS_ERR(dentry)) {
674 if (!IS_POSIXACL(nd.dentry->d_inode))
675 @@ -1373,6 +1547,7 @@ asmlinkage long sys_mkdir(const char * p
678 up(&nd.dentry->d_inode->i_sem);
683 @@ -1473,8 +1648,16 @@ asmlinkage long sys_rmdir(const char * p
687 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
688 + struct inode_operations *op = nd.dentry->d_inode->i_op;
690 + error = op->rmdir_raw(&nd);
691 + /* the file system wants to use normal vfs path now */
692 + if (error != -EOPNOTSUPP)
695 down(&nd.dentry->d_inode->i_sem);
696 - dentry = lookup_hash(&nd.last, nd.dentry);
697 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
698 error = PTR_ERR(dentry);
699 if (!IS_ERR(dentry)) {
700 error = vfs_rmdir(nd.dentry->d_inode, dentry);
701 @@ -1532,8 +1715,15 @@ asmlinkage long sys_unlink(const char *
703 if (nd.last_type != LAST_NORM)
705 + if (nd.dentry->d_inode->i_op->unlink_raw) {
706 + struct inode_operations *op = nd.dentry->d_inode->i_op;
707 + error = op->unlink_raw(&nd);
708 + /* the file system wants to use normal vfs path now */
709 + if (error != -EOPNOTSUPP)
712 down(&nd.dentry->d_inode->i_sem);
713 - dentry = lookup_hash(&nd.last, nd.dentry);
714 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
715 error = PTR_ERR(dentry);
716 if (!IS_ERR(dentry)) {
717 /* Why not before? Because we want correct error value */
718 @@ -1600,15 +1790,27 @@ asmlinkage long sys_symlink(const char *
719 error = path_lookup(to, LOOKUP_PARENT, &nd);
722 - dentry = lookup_create(&nd, 0);
723 + if (nd.last_type != LAST_NORM) {
727 + if (nd.dentry->d_inode->i_op->symlink_raw) {
728 + struct inode_operations *op = nd.dentry->d_inode->i_op;
729 + error = op->symlink_raw(&nd, from);
730 + /* the file system wants to use normal vfs path now */
731 + if (error != -EOPNOTSUPP)
734 + dentry = lookup_create(&nd, 0, NULL);
735 error = PTR_ERR(dentry);
736 if (!IS_ERR(dentry)) {
737 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
740 up(&nd.dentry->d_inode->i_sem);
748 @@ -1684,7 +1886,18 @@ asmlinkage long sys_link(const char * ol
750 if (old_nd.mnt != nd.mnt)
752 - new_dentry = lookup_create(&nd, 0);
753 + if (nd.last_type != LAST_NORM) {
757 + if (nd.dentry->d_inode->i_op->link_raw) {
758 + struct inode_operations *op = nd.dentry->d_inode->i_op;
759 + error = op->link_raw(&old_nd, &nd);
760 + /* the file system wants to use normal vfs path now */
761 + if (error != -EOPNOTSUPP)
764 + new_dentry = lookup_create(&nd, 0, NULL);
765 error = PTR_ERR(new_dentry);
766 if (!IS_ERR(new_dentry)) {
767 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
768 @@ -1728,7 +1941,7 @@ exit:
771 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
772 - struct inode *new_dir, struct dentry *new_dentry)
773 + struct inode *new_dir, struct dentry *new_dentry)
776 struct inode *target;
777 @@ -1807,7 +2020,7 @@ out_unlock:
780 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
781 - struct inode *new_dir, struct dentry *new_dentry)
782 + struct inode *new_dir, struct dentry *new_dentry)
786 @@ -1895,9 +2108,18 @@ static inline int do_rename(const char *
787 if (newnd.last_type != LAST_NORM)
790 + if (old_dir->d_inode->i_op->rename_raw) {
792 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
794 + /* the file system wants to use normal vfs path now */
795 + if (error != -EOPNOTSUPP)
799 double_lock(new_dir, old_dir);
801 - old_dentry = lookup_hash(&oldnd.last, old_dir);
802 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
803 error = PTR_ERR(old_dentry);
804 if (IS_ERR(old_dentry))
806 @@ -1913,16 +2135,16 @@ static inline int do_rename(const char *
807 if (newnd.last.name[newnd.last.len])
810 - new_dentry = lookup_hash(&newnd.last, new_dir);
811 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
812 error = PTR_ERR(new_dentry);
813 if (IS_ERR(new_dentry))
818 error = vfs_rename(old_dir->d_inode, old_dentry,
819 new_dir->d_inode, new_dentry);
825 @@ -1973,20 +2195,26 @@ out:
829 -__vfs_follow_link(struct nameidata *nd, const char *link)
830 +__vfs_follow_link(struct nameidata *nd, const char *link,
831 + struct lookup_intent *it)
840 + else if (it != nd->intent)
841 + printk("it != nd->intent: tell phil@clusterfs.com\n");
845 if (!walk_init_root(link, nd))
846 /* weird __emul_prefix() stuff did it */
849 - res = link_path_walk(link, nd);
850 + res = link_path_walk_it(link, nd, it);
852 if (current->link_count || res || nd->last_type!=LAST_NORM)
854 @@ -2010,7 +2238,13 @@ fail:
856 int vfs_follow_link(struct nameidata *nd, const char *link)
858 - return __vfs_follow_link(nd, link);
859 + return __vfs_follow_link(nd, link, NULL);
862 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
863 + struct lookup_intent *it)
865 + return __vfs_follow_link(nd, link, it);
868 /* get the link contents into pagecache */
869 @@ -2052,7 +2286,7 @@ int page_follow_link(struct dentry *dent
871 struct page *page = NULL;
872 char *s = page_getlink(dentry, &page);
873 - int res = __vfs_follow_link(nd, s);
874 + int res = __vfs_follow_link(nd, s, NULL);
877 page_cache_release(page);
878 Index: linux-2.4.21-40.EL/fs/namespace.c
879 ===================================================================
880 --- linux-2.4.21-40.EL.orig/fs/namespace.c
881 +++ linux-2.4.21-40.EL/fs/namespace.c
882 @@ -98,6 +98,7 @@ static void detach_mnt(struct vfsmount *
884 old_nd->dentry = mnt->mnt_mountpoint;
885 old_nd->mnt = mnt->mnt_parent;
886 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
887 mnt->mnt_parent = mnt;
888 mnt->mnt_mountpoint = mnt->mnt_root;
889 list_del_init(&mnt->mnt_child);
890 @@ -109,6 +110,7 @@ static void attach_mnt(struct vfsmount *
892 mnt->mnt_parent = mntget(nd->mnt);
893 mnt->mnt_mountpoint = dget(nd->dentry);
894 + PIN(nd->dentry, nd->mnt, 1);
895 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
896 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
897 nd->dentry->d_mounted++;
898 @@ -488,14 +490,17 @@ static int do_loopback(struct nameidata
900 struct nameidata old_nd;
901 struct vfsmount *mnt = NULL;
902 + struct lookup_intent it = { .it_op = IT_GETATTR };
903 int err = mount_is_safe(nd);
906 if (!old_name || !*old_name)
908 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
910 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
912 + intent_release(&it);
916 down_write(¤t->namespace->sem);
918 @@ -518,6 +523,7 @@ static int do_loopback(struct nameidata
921 up_write(¤t->namespace->sem);
922 + intent_release(&it);
923 path_release(&old_nd);
926 @@ -701,6 +707,7 @@ long do_mount(char * dev_name, char * di
927 unsigned long flags, void *data_page)
930 + struct lookup_intent it = { .it_op = IT_GETATTR };
934 @@ -725,9 +732,11 @@ long do_mount(char * dev_name, char * di
935 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
937 /* ... and get the mountpoint */
938 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
940 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
942 + intent_release(&it);
946 if (flags & MS_REMOUNT)
947 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
948 @@ -739,6 +748,8 @@ long do_mount(char * dev_name, char * di
950 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
951 dev_name, data_page);
953 + intent_release(&it);
957 @@ -904,6 +915,8 @@ asmlinkage long sys_pivot_root(const cha
959 struct vfsmount *tmp;
960 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
961 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
962 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
965 if (!capable(CAP_SYS_ADMIN))
966 @@ -911,14 +924,14 @@ asmlinkage long sys_pivot_root(const cha
970 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
971 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
975 if (!check_mnt(new_nd.mnt))
978 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
979 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
983 @@ -973,8 +986,10 @@ out2:
984 up(&old_nd.dentry->d_inode->i_zombie);
985 up_write(¤t->namespace->sem);
986 path_release(&user_nd);
987 + intent_release(&old_it);
988 path_release(&old_nd);
990 + intent_release(&new_it);
991 path_release(&new_nd);
994 Index: linux-2.4.21-40.EL/fs/open.c
995 ===================================================================
996 --- linux-2.4.21-40.EL.orig/fs/open.c
997 +++ linux-2.4.21-40.EL/fs/open.c
999 #include <asm/uaccess.h>
1001 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1002 +extern int path_walk_it(const char *name, struct nameidata *nd,
1003 + struct lookup_intent *it);
1005 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1007 @@ -170,9 +172,10 @@ void fd_install(unsigned int fd, struct
1008 write_unlock(&files->file_lock);
1011 -int do_truncate(struct dentry *dentry, loff_t length)
1012 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1014 struct inode *inode = dentry->d_inode;
1015 + struct inode_operations *op = dentry->d_inode->i_op;
1017 struct iattr newattrs;
1019 @@ -184,7 +187,13 @@ int do_truncate(struct dentry *dentry, l
1020 down(&inode->i_sem);
1021 newattrs.ia_size = length;
1022 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1023 - error = notify_change(dentry, &newattrs);
1024 + if (called_from_open)
1025 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1026 + if (op->setattr_raw) {
1027 + newattrs.ia_valid |= ATTR_RAW;
1028 + error = op->setattr_raw(inode, &newattrs);
1030 + error = notify_change(dentry, &newattrs);
1032 up_write(&inode->i_alloc_sem);
1034 @@ -195,12 +204,13 @@ static inline long do_sys_truncate(const
1035 struct nameidata nd;
1036 struct inode * inode;
1038 + struct lookup_intent it = { .it_op = IT_GETATTR };
1041 if (length < 0) /* sorry, but loff_t says... */
1044 - error = user_path_walk(path, &nd);
1045 + error = user_path_walk_it(path, &nd, &it);
1048 inode = nd.dentry->d_inode;
1049 @@ -240,11 +250,13 @@ static inline long do_sys_truncate(const
1050 error = locks_verify_truncate(inode, NULL, length);
1053 - error = do_truncate(nd.dentry, length);
1054 + intent_release(&it);
1055 + error = do_truncate(nd.dentry, length, 0);
1057 put_write_access(inode);
1060 + intent_release(&it);
1064 @@ -292,7 +304,7 @@ static inline long do_sys_ftruncate(unsi
1066 error = locks_verify_truncate(inode, file, length);
1068 - error = do_truncate(dentry, length);
1069 + error = do_truncate(dentry, length, 0);
1073 @@ -337,11 +349,13 @@ asmlinkage long sys_utime(char * filenam
1074 struct inode * inode;
1075 struct iattr newattrs;
1077 - error = user_path_walk(filename, &nd);
1078 + error = user_path_walk_it(filename, &nd, NULL);
1081 inode = nd.dentry->d_inode;
1083 + /* this is safe without a Lustre lock because it only depends
1084 + on the super block */
1086 if (IS_RDONLY(inode))
1088 @@ -356,11 +370,25 @@ asmlinkage long sys_utime(char * filenam
1091 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1095 + if (inode->i_op->setattr_raw) {
1096 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1098 + newattrs.ia_valid |= ATTR_RAW;
1099 + error = op->setattr_raw(inode, &newattrs);
1100 + /* the file system wants to use normal vfs path now */
1101 + if (error != -EOPNOTSUPP)
1102 + goto dput_and_out;
1107 if (current->fsuid != inode->i_uid &&
1108 (error = permission(inode,MAY_WRITE)) != 0)
1112 error = notify_change(nd.dentry, &newattrs);
1115 @@ -381,12 +409,14 @@ asmlinkage long sys_utimes(char * filena
1116 struct inode * inode;
1117 struct iattr newattrs;
1119 - error = user_path_walk(filename, &nd);
1120 + error = user_path_walk_it(filename, &nd, NULL);
1124 inode = nd.dentry->d_inode;
1126 + /* this is safe without a Lustre lock because it only depends
1127 + on the super block */
1129 if (IS_RDONLY(inode))
1131 @@ -401,7 +431,20 @@ asmlinkage long sys_utimes(char * filena
1132 newattrs.ia_atime = times[0].tv_sec;
1133 newattrs.ia_mtime = times[1].tv_sec;
1134 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1138 + if (inode->i_op->setattr_raw) {
1139 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1141 + newattrs.ia_valid |= ATTR_RAW;
1142 + error = op->setattr_raw(inode, &newattrs);
1143 + /* the file system wants to use normal vfs path now */
1144 + if (error != -EOPNOTSUPP)
1145 + goto dput_and_out;
1150 if (current->fsuid != inode->i_uid &&
1151 (error = permission(inode,MAY_WRITE)) != 0)
1153 @@ -424,6 +467,7 @@ asmlinkage long sys_access(const char *
1154 int old_fsuid, old_fsgid;
1155 kernel_cap_t old_cap;
1157 + struct lookup_intent it = { .it_op = IT_GETATTR };
1159 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1161 @@ -441,13 +485,14 @@ asmlinkage long sys_access(const char *
1163 current->cap_effective = current->cap_permitted;
1165 - res = user_path_walk(filename, &nd);
1166 + res = user_path_walk_it(filename, &nd, &it);
1168 res = permission(nd.dentry->d_inode, mode);
1169 /* SuS v2 requires we report a read only fs too */
1170 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1171 && !special_file(nd.dentry->d_inode->i_mode))
1173 + intent_release(&it);
1177 @@ -462,8 +507,9 @@ asmlinkage long sys_chdir(const char * f
1180 struct nameidata nd;
1181 + struct lookup_intent it = { .it_op = IT_GETATTR };
1183 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1184 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1188 @@ -474,6 +520,7 @@ asmlinkage long sys_chdir(const char * f
1189 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1192 + intent_release(&it);
1196 @@ -513,9 +560,10 @@ asmlinkage long sys_chroot(const char *
1199 struct nameidata nd;
1200 + struct lookup_intent it = { .it_op = IT_GETATTR };
1202 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1203 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1204 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1205 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1209 @@ -531,39 +579,56 @@ asmlinkage long sys_chroot(const char *
1213 + intent_release(&it);
1219 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1220 +int chmod_common(struct dentry *dentry, mode_t mode)
1222 - struct inode * inode;
1223 - struct dentry * dentry;
1224 - struct file * file;
1226 + struct inode *inode = dentry->d_inode;
1227 struct iattr newattrs;
1232 + if (IS_RDONLY(inode))
1235 - dentry = file->f_dentry;
1236 - inode = dentry->d_inode;
1237 + if (inode->i_op->setattr_raw) {
1238 + newattrs.ia_mode = mode;
1239 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1240 + newattrs.ia_valid |= ATTR_RAW;
1241 + err = inode->i_op->setattr_raw(inode, &newattrs);
1242 + /* the file system wants to use normal vfs path now */
1243 + if (err != -EOPNOTSUPP)
1248 - if (IS_RDONLY(inode))
1251 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1255 if (mode == (mode_t) -1)
1256 mode = inode->i_mode;
1257 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1258 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1259 err = notify_change(dentry, &newattrs);
1266 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1268 + struct file * file;
1275 + err = chmod_common(file->f_dentry, mode);
1280 @@ -572,30 +637,14 @@ out:
1281 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1283 struct nameidata nd;
1284 - struct inode * inode;
1286 - struct iattr newattrs;
1288 error = user_path_walk(filename, &nd);
1291 - inode = nd.dentry->d_inode;
1294 - if (IS_RDONLY(inode))
1295 - goto dput_and_out;
1296 + error = chmod_common(nd.dentry, mode);
1299 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1300 - goto dput_and_out;
1302 - if (mode == (mode_t) -1)
1303 - mode = inode->i_mode;
1304 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1305 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1306 - error = notify_change(nd.dentry, &newattrs);
1312 @@ -615,6 +664,20 @@ static int chown_common(struct dentry *
1314 if (IS_RDONLY(inode))
1317 + if (inode->i_op->setattr_raw) {
1318 + struct inode_operations *op = dentry->d_inode->i_op;
1320 + newattrs.ia_uid = user;
1321 + newattrs.ia_gid = group;
1322 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1323 + newattrs.ia_valid |= ATTR_RAW;
1324 + error = op->setattr_raw(inode, &newattrs);
1325 + /* the file system wants to use normal vfs path now */
1326 + if (error != -EOPNOTSUPP)
1331 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1333 @@ -701,7 +764,7 @@ asmlinkage long sys_fchown(unsigned int
1337 -static struct file *__dentry_open(struct dentry *, struct vfsmount *, int, struct file *);
1338 +static struct file *__dentry_open(struct dentry *, struct vfsmount *, int, struct file *, struct lookup_intent *);
1341 * Note that while the flag value (low two bits) for sys_open means:
1342 @@ -721,7 +784,7 @@ struct file *filp_open(const char * file
1344 int namei_flags, error;
1345 struct nameidata nd;
1347 + struct lookup_intent it = { .it_op = IT_OPEN };
1349 namei_flags = flags;
1350 if ((namei_flags+1) & O_ACCMODE)
1351 @@ -730,19 +793,16 @@ struct file *filp_open(const char * file
1355 - f = get_empty_filp();
1357 - return ERR_PTR(error);
1359 - error = open_namei(filename, namei_flags, mode, &nd);
1361 - return __dentry_open(nd.dentry, nd.mnt, flags, f);
1362 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1364 + 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)
1377 @@ -753,10 +813,10 @@ struct file *dentry_open(struct dentry *
1378 return ERR_PTR(-ENFILE);
1381 - return __dentry_open(dentry, mnt, flags, f);
1382 + return __dentry_open(dentry, mnt, flags, f, it);
1385 -static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags, struct file *f)
1386 +static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags, struct file *f, struct lookup_intent *it)
1388 struct inode *inode;
1389 static LIST_HEAD(kill_list);
1390 @@ -788,7 +848,9 @@ static struct file *__dentry_open(struct
1393 if (f->f_op && f->f_op->open) {
1395 error = f->f_op->open(inode,f);
1400 @@ -804,6 +866,7 @@ static struct file *__dentry_open(struct
1404 + intent_release(it);
1408 @@ -817,11 +880,17 @@ cleanup_all:
1412 + intent_release(it);
1415 return ERR_PTR(error);
1418 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1420 + return dentry_open_it(dentry, mnt, flags, NULL);
1424 * Find an empty file descriptor entry, and mark it busy.
1426 Index: linux-2.4.21-40.EL/fs/stat.c
1427 ===================================================================
1428 --- linux-2.4.21-40.EL.orig/fs/stat.c
1429 +++ linux-2.4.21-40.EL/fs/stat.c
1431 * Revalidate the inode. This is required for proper NFS attribute caching.
1433 static __inline__ int
1434 -do_revalidate(struct dentry *dentry)
1435 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1437 struct inode * inode = dentry->d_inode;
1438 - if (inode->i_op && inode->i_op->revalidate)
1439 + if (inode->i_op && inode->i_op->revalidate_it)
1440 + return inode->i_op->revalidate_it(dentry, it);
1441 + else if (inode->i_op && inode->i_op->revalidate)
1442 return inode->i_op->revalidate(dentry);
1445 @@ -143,14 +145,16 @@ static int cp_new_stat(struct inode * in
1446 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1448 struct nameidata nd;
1449 + struct lookup_intent it = { .it_op = IT_GETATTR };
1450 int error, errcnt = 0;
1453 - error = user_path_walk(filename, &nd);
1454 + error = user_path_walk_it(filename, &nd, &it);
1456 - error = do_revalidate(nd.dentry);
1457 + error = do_revalidate(nd.dentry, &it);
1459 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1460 + intent_release(&it);
1463 if (error == -ESTALE && !errcnt) {
1464 @@ -164,14 +168,16 @@ again:
1465 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1467 struct nameidata nd;
1468 + struct lookup_intent it = { .it_op = IT_GETATTR };
1469 int error, errcnt = 0;
1472 - error = user_path_walk(filename, &nd);
1473 + error = user_path_walk_it(filename, &nd, &it);
1475 - error = do_revalidate(nd.dentry);
1476 + error = do_revalidate(nd.dentry, &it);
1478 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1479 + intent_release(&it);
1482 if (error == -ESTALE && !errcnt) {
1483 @@ -191,14 +197,16 @@ again:
1484 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1486 struct nameidata nd;
1487 + struct lookup_intent it = { .it_op = IT_GETATTR };
1488 int error, errcnt = 0;
1491 - error = user_path_walk_link(filename, &nd);
1492 + error = user_path_walk_link_it(filename, &nd, &it);
1494 - error = do_revalidate(nd.dentry);
1495 + error = do_revalidate(nd.dentry, &it);
1497 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1498 + intent_release(&it);
1501 if (error == -ESTALE && !errcnt) {
1502 @@ -214,14 +222,16 @@ again:
1503 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1505 struct nameidata nd;
1506 + struct lookup_intent it = { .it_op = IT_GETATTR };
1507 int error, errcnt = 0;
1510 - error = user_path_walk_link(filename, &nd);
1511 + error = user_path_walk_link_it(filename, &nd, &it);
1513 - error = do_revalidate(nd.dentry);
1514 + error = do_revalidate(nd.dentry, &it);
1516 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1517 + intent_release(&it);
1521 @@ -248,7 +258,7 @@ asmlinkage long sys_fstat(unsigned int f
1523 struct dentry * dentry = f->f_dentry;
1525 - err = do_revalidate(dentry);
1526 + err = do_revalidate(dentry, NULL);
1528 err = cp_old_stat(dentry->d_inode, statbuf);
1530 @@ -267,7 +277,7 @@ asmlinkage long sys_newfstat(unsigned in
1532 struct dentry * dentry = f->f_dentry;
1534 - err = do_revalidate(dentry);
1535 + err = do_revalidate(dentry, NULL);
1537 err = cp_new_stat(dentry->d_inode, statbuf);
1539 @@ -289,7 +299,7 @@ asmlinkage long sys_readlink(const char
1542 if (inode->i_op && inode->i_op->readlink &&
1543 - !(error = do_revalidate(nd.dentry))) {
1544 + !(error = do_revalidate(nd.dentry, NULL))) {
1545 UPDATE_ATIME(inode);
1546 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1548 @@ -364,14 +374,16 @@ static long cp_new_stat64(struct inode *
1549 asmlinkage long sys_stat64(char * filename, struct stat64 * statbuf, long flags)
1551 struct nameidata nd;
1552 + struct lookup_intent it = { .it_op = IT_GETATTR };
1553 int error, errcnt = 0;
1556 - error = user_path_walk(filename, &nd);
1557 + error = user_path_walk_it(filename, &nd, &it);
1559 - error = do_revalidate(nd.dentry);
1560 + error = do_revalidate(nd.dentry, &it);
1562 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1563 + intent_release(&it);
1566 if (error == -ESTALE && !errcnt) {
1567 @@ -385,14 +397,16 @@ again:
1568 asmlinkage long sys_lstat64(char * filename, struct stat64 * statbuf, long flags)
1570 struct nameidata nd;
1571 + struct lookup_intent it = { .it_op = IT_GETATTR };
1572 int error, errcnt = 0;
1575 - error = user_path_walk_link(filename, &nd);
1576 + error = user_path_walk_link_it(filename, &nd, &it);
1578 - error = do_revalidate(nd.dentry);
1579 + error = do_revalidate(nd.dentry, &it);
1581 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1582 + intent_release(&it);
1585 if (error == -ESTALE && !errcnt) {
1586 @@ -412,7 +426,7 @@ asmlinkage long sys_fstat64(unsigned lon
1588 struct dentry * dentry = f->f_dentry;
1590 - err = do_revalidate(dentry);
1591 + err = do_revalidate(dentry, NULL);
1593 err = cp_new_stat64(dentry->d_inode, statbuf);
1595 Index: linux-2.4.21-40.EL/include/linux/dcache.h
1596 ===================================================================
1597 --- linux-2.4.21-40.EL.orig/include/linux/dcache.h
1598 +++ linux-2.4.21-40.EL/include/linux/dcache.h
1600 #include <asm/atomic.h>
1601 #include <linux/mount.h>
1602 #include <linux/kernel.h>
1603 +#include <linux/string.h>
1605 +#define IT_OPEN 0x0001
1606 +#define IT_CREAT 0x0002
1607 +#define IT_READDIR 0x0004
1608 +#define IT_GETATTR 0x0008
1609 +#define IT_LOOKUP 0x0010
1610 +#define IT_UNLINK 0x0020
1611 +#define IT_GETXATTR 0x0040
1612 +#define IT_EXEC 0x0080
1613 +#define IT_PIN 0x0100
1615 +#define IT_FL_LOCKED 0x0001
1616 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1618 +#define INTENT_MAGIC 0x19620323
1621 +struct lustre_intent_data {
1622 + int it_disposition;
1624 + __u64 it_lock_handle;
1629 +struct lookup_intent {
1631 + void (*it_op_release)(struct lookup_intent *);
1634 + int it_create_mode;
1636 + struct lustre_intent_data lustre;
1640 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1642 + memset(it, 0, sizeof(*it));
1643 + it->it_magic = INTENT_MAGIC;
1645 + it->it_flags = flags;
1650 * linux/include/linux/dcache.h
1651 @@ -96,8 +141,22 @@ struct dentry_operations {
1652 int (*d_delete)(struct dentry *);
1653 void (*d_release)(struct dentry *);
1654 void (*d_iput)(struct dentry *, struct inode *);
1655 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1656 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1657 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1660 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1661 + de->d_op->d_pin(de, mnt, flag);
1662 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1663 + de->d_op->d_unpin(de, mnt, flag);
1666 +/* defined in fs/namei.c */
1667 +extern void intent_release(struct lookup_intent *it);
1668 +/* defined in fs/dcache.c */
1669 +extern void __d_rehash(struct dentry * entry, int lock);
1671 /* the dentry parameter passed to d_hash and d_compare is the parent
1672 * directory of the entries to be compared. It is used in case these
1673 * functions need any directory specific information for determining
1674 @@ -129,6 +188,7 @@ d_iput: no no yes
1675 * s_nfsd_free_path semaphore will be down
1677 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1678 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1680 extern spinlock_t dcache_lock;
1682 Index: linux-2.4.21-40.EL/include/linux/fs.h
1683 ===================================================================
1684 --- linux-2.4.21-40.EL.orig/include/linux/fs.h
1685 +++ linux-2.4.21-40.EL/include/linux/fs.h
1686 @@ -73,6 +73,7 @@ extern int leases_enable, dir_notify_ena
1688 #define FMODE_READ 1
1689 #define FMODE_WRITE 2
1690 +#define FMODE_EXEC 4
1694 @@ -365,6 +366,9 @@ extern void set_bh_page(struct buffer_he
1695 #define ATTR_MTIME_SET 256
1696 #define ATTR_FORCE 512 /* Not a change, but a change it */
1697 #define ATTR_ATTR_FLAG 1024
1698 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1699 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1700 +#define ATTR_CTIME_SET 0x2000
1703 * This is the Inode Attributes structure, used for notify_change(). It
1704 @@ -502,6 +506,7 @@ struct inode {
1705 struct pipe_inode_info *i_pipe;
1706 struct block_device *i_bdev;
1707 struct char_device *i_cdev;
1708 + void *i_filterdata;
1710 unsigned long i_dnotify_mask; /* Directory notify events */
1711 struct dnotify_struct *i_dnotify; /* for directory notifications */
1712 @@ -604,6 +609,7 @@ struct file {
1714 /* needed for tty driver, and maybe others */
1716 + struct lookup_intent *f_it;
1718 /* preallocated helper kiobuf to speedup O_DIRECT */
1719 struct kiobuf *f_iobuf;
1720 @@ -736,6 +742,7 @@ struct nameidata {
1724 + struct lookup_intent *intent;
1728 @@ -856,7 +863,8 @@ extern int vfs_symlink(struct inode *, s
1729 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1730 extern int vfs_rmdir(struct inode *, struct dentry *);
1731 extern int vfs_unlink(struct inode *, struct dentry *);
1732 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1733 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1734 + struct inode *new_dir, struct dentry *new_dentry);
1738 @@ -935,21 +943,32 @@ struct file_operations_ext {
1740 struct inode_operations {
1741 int (*create) (struct inode *,struct dentry *,int);
1742 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1743 struct dentry * (*lookup) (struct inode *,struct dentry *);
1744 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1745 int (*link) (struct dentry *,struct inode *,struct dentry *);
1746 + int (*link_raw) (struct nameidata *,struct nameidata *);
1747 int (*unlink) (struct inode *,struct dentry *);
1748 + int (*unlink_raw) (struct nameidata *);
1749 int (*symlink) (struct inode *,struct dentry *,const char *);
1750 + int (*symlink_raw) (struct nameidata *,const char *);
1751 int (*mkdir) (struct inode *,struct dentry *,int);
1752 + int (*mkdir_raw) (struct nameidata *,int);
1753 int (*rmdir) (struct inode *,struct dentry *);
1754 + int (*rmdir_raw) (struct nameidata *);
1755 int (*mknod) (struct inode *,struct dentry *,int,int);
1756 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1757 int (*rename) (struct inode *, struct dentry *,
1758 struct inode *, struct dentry *);
1759 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1760 int (*readlink) (struct dentry *, char *,int);
1761 int (*follow_link) (struct dentry *, struct nameidata *);
1762 void (*truncate) (struct inode *);
1763 int (*permission) (struct inode *, int);
1764 int (*revalidate) (struct dentry *);
1765 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1766 int (*setattr) (struct dentry *, struct iattr *);
1767 + int (*setattr_raw) (struct inode *, struct iattr *);
1768 int (*getattr) (struct dentry *, struct iattr *);
1769 int (*setxattr) (struct dentry *, const char *, const void *, size_t, int);
1770 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1771 @@ -1151,10 +1170,14 @@ static inline int get_lease(struct inode
1773 asmlinkage long sys_open(const char *, int, int);
1774 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1775 -extern int do_truncate(struct dentry *, loff_t start);
1776 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1778 extern struct file *filp_open(const char *, int, int);
1779 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1780 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1781 + struct nameidata *nd, struct lookup_intent *it);
1782 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1783 + int flags, struct lookup_intent *it);
1784 extern int filp_close(struct file *, fl_owner_t id);
1785 extern char * getname(const char *);
1787 @@ -1446,6 +1469,7 @@ typedef int (*read_actor_t)(read_descrip
1788 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1790 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1791 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1792 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1793 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1794 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1795 @@ -1457,6 +1481,8 @@ extern struct dentry * lookup_one_len(co
1796 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1797 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1798 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1799 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1800 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1802 extern void inode_init_once(struct inode *);
1803 extern void iput(struct inode *);
1804 @@ -1625,6 +1651,8 @@ extern struct file_operations generic_ro
1806 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1807 extern int vfs_follow_link(struct nameidata *, const char *);
1808 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1809 + struct lookup_intent *it);
1810 extern int page_readlink(struct dentry *, char *, int);
1811 extern int page_follow_link(struct dentry *, struct nameidata *);
1812 extern struct inode_operations page_symlink_inode_operations;
1813 Index: linux-2.4.21-40.EL/include/linux/fs_struct.h
1814 ===================================================================
1815 --- linux-2.4.21-40.EL.orig/include/linux/fs_struct.h
1816 +++ linux-2.4.21-40.EL/include/linux/fs_struct.h
1817 @@ -37,10 +37,12 @@ static inline void set_fs_root(struct fs
1818 write_lock(&fs->lock);
1819 old_root = fs->root;
1820 old_rootmnt = fs->rootmnt;
1821 + PIN(dentry, mnt, 1);
1822 fs->rootmnt = mntget(mnt);
1823 fs->root = dget(dentry);
1824 write_unlock(&fs->lock);
1826 + UNPIN(old_root, old_rootmnt, 1);
1828 mntput(old_rootmnt);
1830 @@ -60,10 +62,12 @@ static inline void set_fs_pwd(struct fs_
1831 write_lock(&fs->lock);
1833 old_pwdmnt = fs->pwdmnt;
1834 + PIN(dentry, mnt, 0);
1835 fs->pwdmnt = mntget(mnt);
1836 fs->pwd = dget(dentry);
1837 write_unlock(&fs->lock);
1839 + UNPIN(old_pwd, old_pwdmnt, 0);
1843 Index: linux-2.4.21-40.EL/kernel/exit.c
1844 ===================================================================
1845 --- linux-2.4.21-40.EL.orig/kernel/exit.c
1846 +++ linux-2.4.21-40.EL/kernel/exit.c
1847 @@ -367,11 +367,14 @@ static inline void __put_fs_struct(struc
1849 /* No need to hold fs->lock if we are killing it */
1850 if (atomic_dec_and_test(&fs->count)) {
1851 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1852 + UNPIN(fs->root, fs->rootmnt, 1);
1854 mntput(fs->rootmnt);
1858 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1860 mntput(fs->altrootmnt);
1862 Index: linux-2.4.21-40.EL/kernel/fork.c
1863 ===================================================================
1864 --- linux-2.4.21-40.EL.orig/kernel/fork.c
1865 +++ linux-2.4.21-40.EL/kernel/fork.c
1866 @@ -473,10 +473,13 @@ static inline struct fs_struct *__copy_f
1867 fs->umask = old->umask;
1868 read_lock(&old->lock);
1869 fs->rootmnt = mntget(old->rootmnt);
1870 + PIN(old->pwd, old->pwdmnt, 0);
1871 + PIN(old->root, old->rootmnt, 1);
1872 fs->root = dget(old->root);
1873 fs->pwdmnt = mntget(old->pwdmnt);
1874 fs->pwd = dget(old->pwd);
1876 + PIN(old->altroot, old->altrootmnt, 1);
1877 fs->altrootmnt = mntget(old->altrootmnt);
1878 fs->altroot = dget(old->altroot);
1880 Index: linux-2.4.21-40.EL/kernel/ksyms.c
1881 ===================================================================
1882 --- linux-2.4.21-40.EL.orig/kernel/ksyms.c
1883 +++ linux-2.4.21-40.EL/kernel/ksyms.c
1884 @@ -319,6 +319,7 @@ EXPORT_SYMBOL(read_cache_page);
1885 EXPORT_SYMBOL(set_page_dirty);
1886 EXPORT_SYMBOL(vfs_readlink);
1887 EXPORT_SYMBOL(vfs_follow_link);
1888 +EXPORT_SYMBOL(vfs_follow_link_it);
1889 EXPORT_SYMBOL(page_readlink);
1890 EXPORT_SYMBOL(page_follow_link);
1891 EXPORT_SYMBOL(page_symlink_inode_operations);