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-2.4.24/fs/dcache.c
16 ===================================================================
17 --- linux-2.4.24.orig/fs/dcache.c Fri Jun 13 07:51:37 2003
18 +++ linux-2.4.24/fs/dcache.c Wed Mar 17 17:36:14 2004
19 @@ -181,6 +181,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 @@ -830,13 +837,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-2.4.24/fs/exec.c
57 ===================================================================
58 --- linux-2.4.24.orig/fs/exec.c Fri Nov 28 10:26:21 2003
59 +++ linux-2.4.24/fs/exec.c Wed Mar 17 17:36:14 2004
60 @@ -112,8 +112,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 @@ -125,7 +127,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 @@ -374,8 +377,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 @@ -387,7 +392,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 @@ -399,6 +405,7 @@ out:
108 + intent_release(&it);
112 @@ -1132,7 +1139,7 @@ int do_coredump(long signr, struct pt_re
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-2.4.24/fs/namei.c
122 ===================================================================
123 --- linux-2.4.24.orig/fs/namei.c Mon Aug 25 04:44:43 2003
124 +++ linux-2.4.24/fs/namei.c Wed Mar 17 17:36:52 2004
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 >= 5)
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 @@ -520,9 +556,9 @@ 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 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
244 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
245 err = PTR_ERR(dentry);
248 @@ -540,7 +576,7 @@ int link_path_walk(const char * name, st
251 if (inode->i_op->follow_link) {
252 - err = do_follow_link(dentry, nd);
253 + err = do_follow_link(dentry, nd, NULL);
257 @@ -556,7 +592,7 @@ int link_path_walk(const char * name, st
261 - if (!inode->i_op->lookup)
262 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
265 /* here ends the main loop */
266 @@ -583,9 +619,9 @@ last_component:
270 - dentry = cached_lookup(nd->dentry, &this, 0);
271 + dentry = cached_lookup(nd->dentry, &this, 0, it);
273 - dentry = real_lookup(nd->dentry, &this, 0);
274 + dentry = real_lookup(nd->dentry, &this, 0, it);
275 err = PTR_ERR(dentry);
278 @@ -595,7 +631,7 @@ last_component:
279 inode = dentry->d_inode;
280 if ((lookup_flags & LOOKUP_FOLLOW)
281 && inode && inode->i_op && inode->i_op->follow_link) {
282 - err = do_follow_link(dentry, nd);
283 + err = do_follow_link(dentry, nd, it);
287 @@ -609,7 +645,8 @@ last_component:
289 if (lookup_flags & LOOKUP_DIRECTORY) {
291 - if (!inode->i_op || !inode->i_op->lookup)
292 + if (!inode->i_op ||
293 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
297 @@ -635,6 +672,27 @@ return_reval:
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)
322 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
324 if (!dentry->d_op->d_revalidate(dentry, 0)) {
325 @@ -648,15 +706,28 @@ out_dput:
330 + intent_release(it);
336 +int link_path_walk(const char * name, struct nameidata *nd)
338 + return link_path_walk_it(name, nd, NULL);
341 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
343 + current->total_link_count = 0;
344 + return link_path_walk_it(name, nd, it);
347 int path_walk(const char * name, struct nameidata *nd)
349 current->total_link_count = 0;
350 - return link_path_walk(name, nd);
351 + return link_path_walk_it(name, nd, NULL);
355 @@ -741,6 +812,17 @@ walk_init_root(const char *name, struct
359 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
360 + struct lookup_intent *it)
363 + if (path_init(path, flags, nd))
364 + error = path_walk_it(path, nd, it);
370 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
373 @@ -755,6 +837,7 @@ int path_init(const char *name, unsigned
375 nd->last_type = LAST_ROOT; /* if there are only slashes... */
379 return walk_init_root(name,nd);
380 read_lock(¤t->fs->lock);
381 @@ -769,7 +852,8 @@ int path_init(const char *name, unsigned
382 * needs parent already locked. Doesn't follow mounts.
385 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
386 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
387 + struct lookup_intent *it)
389 struct dentry * dentry;
391 @@ -792,13 +876,16 @@ struct dentry * lookup_hash(struct qstr
395 - dentry = cached_lookup(base, name, 0);
396 + dentry = cached_lookup(base, name, 0, it);
398 struct dentry *new = d_alloc(base, name);
399 dentry = ERR_PTR(-ENOMEM);
403 + if (inode->i_op->lookup_it)
404 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
406 dentry = inode->i_op->lookup(inode, new);
409 @@ -810,6 +897,12 @@ out:
413 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
415 + return lookup_hash_it(name, base, NULL);
420 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
422 @@ -831,7 +924,7 @@ struct dentry * lookup_one_len(const cha
424 this.hash = end_name_hash(hash);
426 - return lookup_hash(&this, base);
427 + return lookup_hash_it(&this, base, NULL);
429 return ERR_PTR(-EACCES);
431 @@ -862,6 +955,23 @@ int __user_walk(const char *name, unsign
435 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
436 + struct lookup_intent *it)
441 + tmp = getname(name);
442 + err = PTR_ERR(tmp);
443 + if (!IS_ERR(tmp)) {
445 + if (path_init(tmp, flags, nd))
446 + err = path_walk_it(tmp, nd, it);
453 * It's inline, so penalty for filesystems that don't use sticky bit is
455 @@ -957,7 +1067,8 @@ static inline int lookup_flags(unsigned
459 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
460 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
461 + struct lookup_intent *it)
465 @@ -970,12 +1081,15 @@ int vfs_create(struct inode *dir, struct
468 error = -EACCES; /* shouldn't it be ENOSYS? */
469 - if (!dir->i_op || !dir->i_op->create)
470 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
475 - error = dir->i_op->create(dir, dentry, mode);
476 + if (dir->i_op->create_it)
477 + error = dir->i_op->create_it(dir, dentry, mode, it);
479 + error = dir->i_op->create(dir, dentry, mode);
483 @@ -984,6 +1098,11 @@ exit_lock:
487 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
489 + return vfs_create_it(dir, dentry, mode, NULL);
495 @@ -998,7 +1117,8 @@ exit_lock:
496 * for symlinks (where the permissions are checked later).
499 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
500 +int open_namei_it(const char *pathname, int flag, int mode,
501 + struct nameidata *nd, struct lookup_intent *it)
503 int acc_mode, error = 0;
505 @@ -1008,11 +1128,14 @@ int open_namei(const char * pathname, in
507 acc_mode = ACC_MODE(flag);
510 + it->it_flags = flag;
513 * The simplest case - just a plain lookup.
515 if (!(flag & O_CREAT)) {
516 - error = path_lookup(pathname, lookup_flags(flag), nd);
517 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
521 @@ -1022,6 +1145,10 @@ int open_namei(const char * pathname, in
523 * Create - we need to know the parent.
526 + it->it_create_mode = mode;
527 + it->it_op |= IT_CREAT;
529 error = path_lookup(pathname, LOOKUP_PARENT, nd);
532 @@ -1037,7 +1164,7 @@ int open_namei(const char * pathname, in
535 down(&dir->d_inode->i_sem);
536 - dentry = lookup_hash(&nd->last, nd->dentry);
537 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
540 error = PTR_ERR(dentry);
541 @@ -1046,10 +1173,11 @@ do_last:
545 + it->it_create_mode = mode;
546 /* Negative dentry, just create the file */
547 if (!dentry->d_inode) {
548 - error = vfs_create(dir->d_inode, dentry,
549 - mode & ~current->fs->umask);
550 + error = vfs_create_it(dir->d_inode, dentry,
551 + mode & ~current->fs->umask, it);
552 up(&dir->d_inode->i_sem);
555 @@ -1153,7 +1281,7 @@ ok:
559 - error = do_truncate(dentry, 0);
560 + error = do_truncate(dentry, 0, 1);
562 put_write_access(inode);
564 @@ -1165,8 +1293,10 @@ ok:
568 + intent_release(it);
571 + intent_release(it);
575 @@ -1185,7 +1315,10 @@ do_link:
576 * are done. Procfs-like symlinks just set LAST_BIND.
578 UPDATE_ATIME(dentry->d_inode);
580 error = dentry->d_inode->i_op->follow_link(dentry, nd);
582 + intent_release(it);
586 @@ -1207,13 +1340,20 @@ do_link:
589 down(&dir->d_inode->i_sem);
590 - dentry = lookup_hash(&nd->last, nd->dentry);
591 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
592 putname(nd->last.name);
596 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
598 + return open_namei_it(pathname, flag, mode, nd, NULL);
603 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
604 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
605 + struct lookup_intent *it)
607 struct dentry *dentry;
609 @@ -1221,7 +1361,7 @@ static struct dentry *lookup_create(stru
610 dentry = ERR_PTR(-EEXIST);
611 if (nd->last_type != LAST_NORM)
613 - dentry = lookup_hash(&nd->last, nd->dentry);
614 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
617 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
618 @@ -1277,7 +1417,20 @@ asmlinkage long sys_mknod(const char * f
619 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
622 - dentry = lookup_create(&nd, 0);
624 + if (nd.last_type != LAST_NORM) {
628 + if (nd.dentry->d_inode->i_op->mknod_raw) {
629 + struct inode_operations *op = nd.dentry->d_inode->i_op;
630 + error = op->mknod_raw(&nd, mode, dev);
631 + /* the file system wants to use normal vfs path now */
632 + if (error != -EOPNOTSUPP)
636 + dentry = lookup_create(&nd, 0, NULL);
637 error = PTR_ERR(dentry);
639 mode &= ~current->fs->umask;
640 @@ -1298,6 +1451,7 @@ asmlinkage long sys_mknod(const char * f
643 up(&nd.dentry->d_inode->i_sem);
648 @@ -1345,7 +1499,18 @@ asmlinkage long sys_mkdir(const char * p
649 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
652 - dentry = lookup_create(&nd, 1);
653 + if (nd.last_type != LAST_NORM) {
657 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
658 + struct inode_operations *op = nd.dentry->d_inode->i_op;
659 + error = op->mkdir_raw(&nd, mode);
660 + /* the file system wants to use normal vfs path now */
661 + if (error != -EOPNOTSUPP)
664 + dentry = lookup_create(&nd, 1, NULL);
665 error = PTR_ERR(dentry);
666 if (!IS_ERR(dentry)) {
667 error = vfs_mkdir(nd.dentry->d_inode, dentry,
668 @@ -1353,6 +1518,7 @@ asmlinkage long sys_mkdir(const char * p
671 up(&nd.dentry->d_inode->i_sem);
676 @@ -1453,8 +1619,16 @@ asmlinkage long sys_rmdir(const char * p
680 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
681 + struct inode_operations *op = nd.dentry->d_inode->i_op;
683 + error = op->rmdir_raw(&nd);
684 + /* the file system wants to use normal vfs path now */
685 + if (error != -EOPNOTSUPP)
688 down(&nd.dentry->d_inode->i_sem);
689 - dentry = lookup_hash(&nd.last, nd.dentry);
690 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
691 error = PTR_ERR(dentry);
692 if (!IS_ERR(dentry)) {
693 error = vfs_rmdir(nd.dentry->d_inode, dentry);
694 @@ -1512,8 +1686,15 @@ asmlinkage long sys_unlink(const char *
696 if (nd.last_type != LAST_NORM)
698 + if (nd.dentry->d_inode->i_op->unlink_raw) {
699 + struct inode_operations *op = nd.dentry->d_inode->i_op;
700 + error = op->unlink_raw(&nd);
701 + /* the file system wants to use normal vfs path now */
702 + if (error != -EOPNOTSUPP)
705 down(&nd.dentry->d_inode->i_sem);
706 - dentry = lookup_hash(&nd.last, nd.dentry);
707 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
708 error = PTR_ERR(dentry);
709 if (!IS_ERR(dentry)) {
710 /* Why not before? Because we want correct error value */
711 @@ -1580,15 +1761,27 @@ asmlinkage long sys_symlink(const char *
712 error = path_lookup(to, LOOKUP_PARENT, &nd);
715 - dentry = lookup_create(&nd, 0);
716 + if (nd.last_type != LAST_NORM) {
720 + if (nd.dentry->d_inode->i_op->symlink_raw) {
721 + struct inode_operations *op = nd.dentry->d_inode->i_op;
722 + error = op->symlink_raw(&nd, from);
723 + /* the file system wants to use normal vfs path now */
724 + if (error != -EOPNOTSUPP)
727 + dentry = lookup_create(&nd, 0, NULL);
728 error = PTR_ERR(dentry);
729 if (!IS_ERR(dentry)) {
730 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
733 up(&nd.dentry->d_inode->i_sem);
741 @@ -1664,7 +1857,18 @@ asmlinkage long sys_link(const char * ol
743 if (old_nd.mnt != nd.mnt)
745 - new_dentry = lookup_create(&nd, 0);
746 + if (nd.last_type != LAST_NORM) {
750 + if (nd.dentry->d_inode->i_op->link_raw) {
751 + struct inode_operations *op = nd.dentry->d_inode->i_op;
752 + error = op->link_raw(&old_nd, &nd);
753 + /* the file system wants to use normal vfs path now */
754 + if (error != -EOPNOTSUPP)
757 + new_dentry = lookup_create(&nd, 0, NULL);
758 error = PTR_ERR(new_dentry);
759 if (!IS_ERR(new_dentry)) {
760 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
761 @@ -1708,7 +1912,7 @@ exit:
764 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
765 - struct inode *new_dir, struct dentry *new_dentry)
766 + struct inode *new_dir, struct dentry *new_dentry)
769 struct inode *target;
770 @@ -1787,7 +1991,7 @@ out_unlock:
773 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
774 - struct inode *new_dir, struct dentry *new_dentry)
775 + struct inode *new_dir, struct dentry *new_dentry)
779 @@ -1875,9 +2079,18 @@ static inline int do_rename(const char *
780 if (newnd.last_type != LAST_NORM)
783 + if (old_dir->d_inode->i_op->rename_raw) {
785 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
787 + /* the file system wants to use normal vfs path now */
788 + if (error != -EOPNOTSUPP)
792 double_lock(new_dir, old_dir);
794 - old_dentry = lookup_hash(&oldnd.last, old_dir);
795 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
796 error = PTR_ERR(old_dentry);
797 if (IS_ERR(old_dentry))
799 @@ -1893,16 +2106,16 @@ static inline int do_rename(const char *
800 if (newnd.last.name[newnd.last.len])
803 - new_dentry = lookup_hash(&newnd.last, new_dir);
804 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
805 error = PTR_ERR(new_dentry);
806 if (IS_ERR(new_dentry))
811 error = vfs_rename(old_dir->d_inode, old_dentry,
812 new_dir->d_inode, new_dentry);
818 @@ -1953,20 +2166,26 @@ out:
822 -__vfs_follow_link(struct nameidata *nd, const char *link)
823 +__vfs_follow_link(struct nameidata *nd, const char *link,
824 + struct lookup_intent *it)
833 + else if (it != nd->intent)
834 + printk("it != nd->intent: tell phil@clusterfs.com\n");
838 if (!walk_init_root(link, nd))
839 /* weird __emul_prefix() stuff did it */
842 - res = link_path_walk(link, nd);
843 + res = link_path_walk_it(link, nd, it);
845 if (current->link_count || res || nd->last_type!=LAST_NORM)
847 @@ -1990,7 +2209,13 @@ fail:
849 int vfs_follow_link(struct nameidata *nd, const char *link)
851 - return __vfs_follow_link(nd, link);
852 + return __vfs_follow_link(nd, link, NULL);
855 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
856 + struct lookup_intent *it)
858 + return __vfs_follow_link(nd, link, it);
861 /* get the link contents into pagecache */
862 @@ -2032,7 +2257,7 @@ int page_follow_link(struct dentry *dent
864 struct page *page = NULL;
865 char *s = page_getlink(dentry, &page);
866 - int res = __vfs_follow_link(nd, s);
867 + int res = __vfs_follow_link(nd, s, NULL);
870 page_cache_release(page);
871 Index: linux-2.4.24/fs/namespace.c
872 ===================================================================
873 --- linux-2.4.24.orig/fs/namespace.c Fri Nov 28 10:26:21 2003
874 +++ linux-2.4.24/fs/namespace.c Wed Mar 17 17:36:14 2004
875 @@ -98,6 +98,7 @@ static void detach_mnt(struct vfsmount *
877 old_nd->dentry = mnt->mnt_mountpoint;
878 old_nd->mnt = mnt->mnt_parent;
879 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
880 mnt->mnt_parent = mnt;
881 mnt->mnt_mountpoint = mnt->mnt_root;
882 list_del_init(&mnt->mnt_child);
883 @@ -109,6 +110,7 @@ static void attach_mnt(struct vfsmount *
885 mnt->mnt_parent = mntget(nd->mnt);
886 mnt->mnt_mountpoint = dget(nd->dentry);
887 + PIN(nd->dentry, nd->mnt, 1);
888 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
889 list_add_tail(&mnt->mnt_child, &nd->mnt->mnt_mounts);
890 nd->dentry->d_mounted++;
891 @@ -488,14 +490,17 @@ static int do_loopback(struct nameidata
893 struct nameidata old_nd;
894 struct vfsmount *mnt = NULL;
895 + struct lookup_intent it = { .it_op = IT_GETATTR };
896 int err = mount_is_safe(nd);
899 if (!old_name || !*old_name)
901 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
903 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
905 + intent_release(&it);
909 down_write(¤t->namespace->sem);
911 @@ -518,6 +523,7 @@ static int do_loopback(struct nameidata
914 up_write(¤t->namespace->sem);
915 + intent_release(&it);
916 path_release(&old_nd);
919 @@ -701,6 +707,7 @@ long do_mount(char * dev_name, char * di
920 unsigned long flags, void *data_page)
923 + struct lookup_intent it = { .it_op = IT_GETATTR };
927 @@ -725,9 +732,11 @@ long do_mount(char * dev_name, char * di
928 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
930 /* ... and get the mountpoint */
931 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
933 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
935 + intent_release(&it);
939 if (flags & MS_REMOUNT)
940 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
941 @@ -739,6 +747,8 @@ long do_mount(char * dev_name, char * di
943 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
944 dev_name, data_page);
946 + intent_release(&it);
950 @@ -904,6 +914,8 @@ asmlinkage long sys_pivot_root(const cha
952 struct vfsmount *tmp;
953 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
954 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
955 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
958 if (!capable(CAP_SYS_ADMIN))
959 @@ -911,14 +923,14 @@ asmlinkage long sys_pivot_root(const cha
963 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
964 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
968 if (!check_mnt(new_nd.mnt))
971 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
972 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
976 @@ -973,8 +985,10 @@ out2:
977 up(&old_nd.dentry->d_inode->i_zombie);
978 up_write(¤t->namespace->sem);
979 path_release(&user_nd);
980 + intent_release(&old_it);
981 path_release(&old_nd);
983 + intent_release(&new_it);
984 path_release(&new_nd);
987 Index: linux-2.4.24/fs/open.c
988 ===================================================================
989 --- linux-2.4.24.orig/fs/open.c Mon Aug 25 04:44:43 2003
990 +++ linux-2.4.24/fs/open.c Wed Mar 17 17:36:14 2004
992 #include <asm/uaccess.h>
994 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
995 +extern int path_walk_it(const char *name, struct nameidata *nd,
996 + struct lookup_intent *it);
998 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1000 @@ -95,9 +97,10 @@ void fd_install(unsigned int fd, struct
1001 write_unlock(&files->file_lock);
1004 -int do_truncate(struct dentry *dentry, loff_t length)
1005 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1007 struct inode *inode = dentry->d_inode;
1008 + struct inode_operations *op = dentry->d_inode->i_op;
1010 struct iattr newattrs;
1012 @@ -109,7 +112,13 @@ int do_truncate(struct dentry *dentry, l
1013 down(&inode->i_sem);
1014 newattrs.ia_size = length;
1015 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1016 - error = notify_change(dentry, &newattrs);
1017 + if (called_from_open)
1018 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1019 + if (op->setattr_raw) {
1020 + newattrs.ia_valid |= ATTR_RAW;
1021 + error = op->setattr_raw(inode, &newattrs);
1023 + error = notify_change(dentry, &newattrs);
1025 up_write(&inode->i_alloc_sem);
1027 @@ -120,12 +129,13 @@ static inline long do_sys_truncate(const
1028 struct nameidata nd;
1029 struct inode * inode;
1031 + struct lookup_intent it = { .it_op = IT_GETATTR };
1034 if (length < 0) /* sorry, but loff_t says... */
1037 - error = user_path_walk(path, &nd);
1038 + error = user_path_walk_it(path, &nd, &it);
1041 inode = nd.dentry->d_inode;
1042 @@ -165,11 +175,13 @@ static inline long do_sys_truncate(const
1043 error = locks_verify_truncate(inode, NULL, length);
1046 - error = do_truncate(nd.dentry, length);
1047 + intent_release(&it);
1048 + error = do_truncate(nd.dentry, length, 0);
1050 put_write_access(inode);
1053 + intent_release(&it);
1057 @@ -217,7 +229,7 @@ static inline long do_sys_ftruncate(unsi
1059 error = locks_verify_truncate(inode, file, length);
1061 - error = do_truncate(dentry, length);
1062 + error = do_truncate(dentry, length, 0);
1066 @@ -262,11 +274,13 @@ asmlinkage long sys_utime(char * filenam
1067 struct inode * inode;
1068 struct iattr newattrs;
1070 - error = user_path_walk(filename, &nd);
1071 + error = user_path_walk_it(filename, &nd, NULL);
1074 inode = nd.dentry->d_inode;
1076 + /* this is safe without a Lustre lock because it only depends
1077 + on the super block */
1079 if (IS_RDONLY(inode))
1081 @@ -281,11 +295,25 @@ asmlinkage long sys_utime(char * filenam
1084 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1088 + if (inode->i_op->setattr_raw) {
1089 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1091 + newattrs.ia_valid |= ATTR_RAW;
1092 + error = op->setattr_raw(inode, &newattrs);
1093 + /* the file system wants to use normal vfs path now */
1094 + if (error != -EOPNOTSUPP)
1095 + goto dput_and_out;
1100 if (current->fsuid != inode->i_uid &&
1101 (error = permission(inode,MAY_WRITE)) != 0)
1105 error = notify_change(nd.dentry, &newattrs);
1108 @@ -306,12 +334,14 @@ asmlinkage long sys_utimes(char * filena
1109 struct inode * inode;
1110 struct iattr newattrs;
1112 - error = user_path_walk(filename, &nd);
1113 + error = user_path_walk_it(filename, &nd, NULL);
1117 inode = nd.dentry->d_inode;
1119 + /* this is safe without a Lustre lock because it only depends
1120 + on the super block */
1122 if (IS_RDONLY(inode))
1124 @@ -326,7 +356,20 @@ asmlinkage long sys_utimes(char * filena
1125 newattrs.ia_atime = times[0].tv_sec;
1126 newattrs.ia_mtime = times[1].tv_sec;
1127 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1131 + if (inode->i_op->setattr_raw) {
1132 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1134 + newattrs.ia_valid |= ATTR_RAW;
1135 + error = op->setattr_raw(inode, &newattrs);
1136 + /* the file system wants to use normal vfs path now */
1137 + if (error != -EOPNOTSUPP)
1138 + goto dput_and_out;
1143 if (current->fsuid != inode->i_uid &&
1144 (error = permission(inode,MAY_WRITE)) != 0)
1146 @@ -349,6 +392,7 @@ asmlinkage long sys_access(const char *
1147 int old_fsuid, old_fsgid;
1148 kernel_cap_t old_cap;
1150 + struct lookup_intent it = { .it_op = IT_GETATTR };
1152 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1154 @@ -366,13 +410,14 @@ asmlinkage long sys_access(const char *
1156 current->cap_effective = current->cap_permitted;
1158 - res = user_path_walk(filename, &nd);
1159 + res = user_path_walk_it(filename, &nd, &it);
1161 res = permission(nd.dentry->d_inode, mode);
1162 /* SuS v2 requires we report a read only fs too */
1163 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1164 && !special_file(nd.dentry->d_inode->i_mode))
1166 + intent_release(&it);
1170 @@ -387,8 +432,9 @@ asmlinkage long sys_chdir(const char * f
1173 struct nameidata nd;
1174 + struct lookup_intent it = { .it_op = IT_GETATTR };
1176 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1177 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1181 @@ -399,6 +445,7 @@ asmlinkage long sys_chdir(const char * f
1182 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1185 + intent_release(&it);
1189 @@ -438,9 +485,10 @@ asmlinkage long sys_chroot(const char *
1192 struct nameidata nd;
1193 + struct lookup_intent it = { .it_op = IT_GETATTR };
1195 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1196 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1197 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1198 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1202 @@ -456,39 +504,56 @@ asmlinkage long sys_chroot(const char *
1206 + intent_release(&it);
1212 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1213 +int chmod_common(struct dentry *dentry, mode_t mode)
1215 - struct inode * inode;
1216 - struct dentry * dentry;
1217 - struct file * file;
1219 + struct inode *inode = dentry->d_inode;
1220 struct iattr newattrs;
1225 + if (IS_RDONLY(inode))
1228 - dentry = file->f_dentry;
1229 - inode = dentry->d_inode;
1230 + if (inode->i_op->setattr_raw) {
1231 + newattrs.ia_mode = mode;
1232 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1233 + newattrs.ia_valid |= ATTR_RAW;
1234 + err = inode->i_op->setattr_raw(inode, &newattrs);
1235 + /* the file system wants to use normal vfs path now */
1236 + if (err != -EOPNOTSUPP)
1241 - if (IS_RDONLY(inode))
1244 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1248 if (mode == (mode_t) -1)
1249 mode = inode->i_mode;
1250 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1251 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1252 err = notify_change(dentry, &newattrs);
1259 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1261 + struct file * file;
1268 + err = chmod_common(file->f_dentry, mode);
1273 @@ -497,30 +562,14 @@ out:
1274 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1276 struct nameidata nd;
1277 - struct inode * inode;
1279 - struct iattr newattrs;
1281 error = user_path_walk(filename, &nd);
1284 - inode = nd.dentry->d_inode;
1287 - if (IS_RDONLY(inode))
1288 - goto dput_and_out;
1291 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1292 - goto dput_and_out;
1293 + error = chmod_common(nd.dentry, mode);
1295 - if (mode == (mode_t) -1)
1296 - mode = inode->i_mode;
1297 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1298 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1299 - error = notify_change(nd.dentry, &newattrs);
1305 @@ -540,6 +589,20 @@ static int chown_common(struct dentry *
1307 if (IS_RDONLY(inode))
1310 + if (inode->i_op->setattr_raw) {
1311 + struct inode_operations *op = dentry->d_inode->i_op;
1313 + newattrs.ia_uid = user;
1314 + newattrs.ia_gid = group;
1315 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1316 + newattrs.ia_valid |= ATTR_RAW;
1317 + error = op->setattr_raw(inode, &newattrs);
1318 + /* the file system wants to use normal vfs path now */
1319 + if (error != -EOPNOTSUPP)
1324 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1326 @@ -644,6 +707,7 @@ struct file *filp_open(const char * file
1328 int namei_flags, error;
1329 struct nameidata nd;
1330 + struct lookup_intent it = { .it_op = IT_OPEN };
1332 namei_flags = flags;
1333 if ((namei_flags+1) & O_ACCMODE)
1334 @@ -651,14 +715,15 @@ struct file *filp_open(const char * file
1335 if (namei_flags & O_TRUNC)
1338 - error = open_namei(filename, namei_flags, mode, &nd);
1340 - return dentry_open(nd.dentry, nd.mnt, flags);
1341 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1343 + return ERR_PTR(error);
1345 - return ERR_PTR(error);
1346 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1349 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1350 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1351 + int flags, struct lookup_intent *it)
1354 struct inode *inode;
1355 @@ -695,12 +760,15 @@ struct file *dentry_open(struct dentry *
1358 if (f->f_op && f->f_op->open) {
1360 error = f->f_op->open(inode,f);
1365 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1367 + intent_release(it);
1371 @@ -715,11 +783,17 @@ cleanup_all:
1375 + intent_release(it);
1378 return ERR_PTR(error);
1381 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1383 + return dentry_open_it(dentry, mnt, flags, NULL);
1387 * Find an empty file descriptor entry, and mark it busy.
1389 Index: linux-2.4.24/fs/stat.c
1390 ===================================================================
1391 --- linux-2.4.24.orig/fs/stat.c Mon Aug 25 04:44:43 2003
1392 +++ linux-2.4.24/fs/stat.c Wed Mar 17 17:36:52 2004
1394 * Revalidate the inode. This is required for proper NFS attribute caching.
1396 static __inline__ int
1397 -do_revalidate(struct dentry *dentry)
1398 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1400 struct inode * inode = dentry->d_inode;
1401 - if (inode->i_op && inode->i_op->revalidate)
1402 + if (inode->i_op && inode->i_op->revalidate_it)
1403 + return inode->i_op->revalidate_it(dentry, it);
1404 + else if (inode->i_op && inode->i_op->revalidate)
1405 return inode->i_op->revalidate(dentry);
1408 @@ -137,13 +139,15 @@ static int cp_new_stat(struct inode * in
1409 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1411 struct nameidata nd;
1412 + struct lookup_intent it = { .it_op = IT_GETATTR };
1415 - error = user_path_walk(filename, &nd);
1416 + error = user_path_walk_it(filename, &nd, &it);
1418 - error = do_revalidate(nd.dentry);
1419 + error = do_revalidate(nd.dentry, &it);
1421 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1422 + intent_release(&it);
1426 @@ -153,13 +157,15 @@ asmlinkage long sys_stat(char * filename
1427 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1429 struct nameidata nd;
1430 + struct lookup_intent it = { .it_op = IT_GETATTR };
1433 - error = user_path_walk(filename, &nd);
1434 + error = user_path_walk_it(filename, &nd, &it);
1436 - error = do_revalidate(nd.dentry);
1437 + error = do_revalidate(nd.dentry, &it);
1439 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1440 + intent_release(&it);
1444 @@ -174,13 +180,15 @@ asmlinkage long sys_newstat(char * filen
1445 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1447 struct nameidata nd;
1448 + struct lookup_intent it = { .it_op = IT_GETATTR };
1451 - error = user_path_walk_link(filename, &nd);
1452 + error = user_path_walk_link_it(filename, &nd, &it);
1454 - error = do_revalidate(nd.dentry);
1455 + error = do_revalidate(nd.dentry, &it);
1457 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1458 + intent_release(&it);
1462 @@ -191,13 +199,15 @@ asmlinkage long sys_lstat(char * filenam
1463 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1465 struct nameidata nd;
1466 + struct lookup_intent it = { .it_op = IT_GETATTR };
1469 - error = user_path_walk_link(filename, &nd);
1470 + error = user_path_walk_link_it(filename, &nd, &it);
1472 - error = do_revalidate(nd.dentry);
1473 + error = do_revalidate(nd.dentry, &it);
1475 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1476 + intent_release(&it);
1480 @@ -218,7 +228,7 @@ asmlinkage long sys_fstat(unsigned int f
1482 struct dentry * dentry = f->f_dentry;
1484 - err = do_revalidate(dentry);
1485 + err = do_revalidate(dentry, NULL);
1487 err = cp_old_stat(dentry->d_inode, statbuf);
1489 @@ -237,7 +247,7 @@ asmlinkage long sys_newfstat(unsigned in
1491 struct dentry * dentry = f->f_dentry;
1493 - err = do_revalidate(dentry);
1494 + err = do_revalidate(dentry, NULL);
1496 err = cp_new_stat(dentry->d_inode, statbuf);
1498 @@ -259,7 +269,7 @@ asmlinkage long sys_readlink(const char
1501 if (inode->i_op && inode->i_op->readlink &&
1502 - !(error = do_revalidate(nd.dentry))) {
1503 + !(error = do_revalidate(nd.dentry, NULL))) {
1504 UPDATE_ATIME(inode);
1505 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1507 @@ -335,12 +345,14 @@ asmlinkage long sys_stat64(char * filena
1509 struct nameidata nd;
1511 + struct lookup_intent it = { .it_op = IT_GETATTR };
1513 - error = user_path_walk(filename, &nd);
1514 + error = user_path_walk_it(filename, &nd, &it);
1516 - error = do_revalidate(nd.dentry);
1517 + error = do_revalidate(nd.dentry, &it);
1519 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1520 + intent_release(&it);
1524 @@ -350,12 +362,14 @@ asmlinkage long sys_lstat64(char * filen
1526 struct nameidata nd;
1528 + struct lookup_intent it = { .it_op = IT_GETATTR };
1530 - error = user_path_walk_link(filename, &nd);
1531 + error = user_path_walk_link_it(filename, &nd, &it);
1533 - error = do_revalidate(nd.dentry);
1534 + error = do_revalidate(nd.dentry, &it);
1536 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1537 + intent_release(&it);
1541 @@ -370,7 +384,7 @@ asmlinkage long sys_fstat64(unsigned lon
1543 struct dentry * dentry = f->f_dentry;
1545 - err = do_revalidate(dentry);
1546 + err = do_revalidate(dentry, NULL);
1548 err = cp_new_stat64(dentry->d_inode, statbuf);
1550 Index: linux-2.4.24/include/linux/dcache.h
1551 ===================================================================
1552 --- linux-2.4.24.orig/include/linux/dcache.h Thu Nov 28 15:53:15 2002
1553 +++ linux-2.4.24/include/linux/dcache.h Wed Mar 17 17:36:14 2004
1555 #include <asm/atomic.h>
1556 #include <linux/mount.h>
1557 #include <linux/kernel.h>
1558 +#include <linux/string.h>
1560 +#define IT_OPEN 0x0001
1561 +#define IT_CREAT 0x0002
1562 +#define IT_READDIR 0x0004
1563 +#define IT_GETATTR 0x0008
1564 +#define IT_LOOKUP 0x0010
1565 +#define IT_UNLINK 0x0020
1566 +#define IT_GETXATTR 0x0040
1567 +#define IT_EXEC 0x0080
1568 +#define IT_PIN 0x0100
1570 +#define IT_FL_LOCKED 0x0001
1571 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1573 +#define INTENT_MAGIC 0x19620323
1576 +struct lustre_intent_data {
1577 + int it_disposition;
1579 + __u64 it_lock_handle;
1584 +struct lookup_intent {
1586 + void (*it_op_release)(struct lookup_intent *);
1589 + int it_create_mode;
1591 + struct lustre_intent_data lustre;
1595 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1597 + memset(it, 0, sizeof(*it));
1598 + it->it_magic = INTENT_MAGIC;
1600 + it->it_flags = flags;
1605 * linux/include/linux/dcache.h
1606 @@ -91,8 +136,22 @@ struct dentry_operations {
1607 int (*d_delete)(struct dentry *);
1608 void (*d_release)(struct dentry *);
1609 void (*d_iput)(struct dentry *, struct inode *);
1610 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1611 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1612 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1615 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1616 + de->d_op->d_pin(de, mnt, flag);
1617 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1618 + de->d_op->d_unpin(de, mnt, flag);
1621 +/* defined in fs/namei.c */
1622 +extern void intent_release(struct lookup_intent *it);
1623 +/* defined in fs/dcache.c */
1624 +extern void __d_rehash(struct dentry * entry, int lock);
1626 /* the dentry parameter passed to d_hash and d_compare is the parent
1627 * directory of the entries to be compared. It is used in case these
1628 * functions need any directory specific information for determining
1629 @@ -124,6 +183,7 @@ d_iput: no no yes
1630 * s_nfsd_free_path semaphore will be down
1632 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1633 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1635 extern spinlock_t dcache_lock;
1637 Index: linux-2.4.24/include/linux/fs.h
1638 ===================================================================
1639 --- linux-2.4.24.orig/include/linux/fs.h Wed Mar 17 17:36:14 2004
1640 +++ linux-2.4.24/include/linux/fs.h Wed Mar 17 17:36:14 2004
1641 @@ -73,6 +73,7 @@ extern int leases_enable, dir_notify_ena
1643 #define FMODE_READ 1
1644 #define FMODE_WRITE 2
1645 +#define FMODE_EXEC 4
1649 @@ -340,6 +341,9 @@ extern void set_bh_page(struct buffer_he
1650 #define ATTR_MTIME_SET 256
1651 #define ATTR_FORCE 512 /* Not a change, but a change it */
1652 #define ATTR_ATTR_FLAG 1024
1653 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1654 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1655 +#define ATTR_CTIME_SET 0x2000
1658 * This is the Inode Attributes structure, used for notify_change(). It
1659 @@ -478,6 +482,7 @@ struct inode {
1660 struct pipe_inode_info *i_pipe;
1661 struct block_device *i_bdev;
1662 struct char_device *i_cdev;
1663 + void *i_filterdata;
1665 unsigned long i_dnotify_mask; /* Directory notify events */
1666 struct dnotify_struct *i_dnotify; /* for directory notifications */
1667 @@ -582,6 +587,7 @@ struct file {
1669 /* needed for tty driver, and maybe others */
1671 + struct lookup_intent *f_it;
1673 /* preallocated helper kiobuf to speedup O_DIRECT */
1674 struct kiobuf *f_iobuf;
1675 @@ -702,6 +708,7 @@ struct nameidata {
1679 + struct lookup_intent *intent;
1683 @@ -822,7 +829,8 @@ extern int vfs_symlink(struct inode *, s
1684 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1685 extern int vfs_rmdir(struct inode *, struct dentry *);
1686 extern int vfs_unlink(struct inode *, struct dentry *);
1687 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1688 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1689 + struct inode *new_dir, struct dentry *new_dentry);
1693 @@ -884,21 +892,32 @@ struct file_operations {
1695 struct inode_operations {
1696 int (*create) (struct inode *,struct dentry *,int);
1697 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1698 struct dentry * (*lookup) (struct inode *,struct dentry *);
1699 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1700 int (*link) (struct dentry *,struct inode *,struct dentry *);
1701 + int (*link_raw) (struct nameidata *,struct nameidata *);
1702 int (*unlink) (struct inode *,struct dentry *);
1703 + int (*unlink_raw) (struct nameidata *);
1704 int (*symlink) (struct inode *,struct dentry *,const char *);
1705 + int (*symlink_raw) (struct nameidata *,const char *);
1706 int (*mkdir) (struct inode *,struct dentry *,int);
1707 + int (*mkdir_raw) (struct nameidata *,int);
1708 int (*rmdir) (struct inode *,struct dentry *);
1709 + int (*rmdir_raw) (struct nameidata *);
1710 int (*mknod) (struct inode *,struct dentry *,int,int);
1711 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1712 int (*rename) (struct inode *, struct dentry *,
1713 struct inode *, struct dentry *);
1714 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1715 int (*readlink) (struct dentry *, char *,int);
1716 int (*follow_link) (struct dentry *, struct nameidata *);
1717 void (*truncate) (struct inode *);
1718 int (*permission) (struct inode *, int);
1719 int (*revalidate) (struct dentry *);
1720 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1721 int (*setattr) (struct dentry *, struct iattr *);
1722 + int (*setattr_raw) (struct inode *, struct iattr *);
1723 int (*getattr) (struct dentry *, struct iattr *);
1724 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
1725 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1726 @@ -1094,10 +1113,14 @@ static inline int get_lease(struct inode
1728 asmlinkage long sys_open(const char *, int, int);
1729 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1730 -extern int do_truncate(struct dentry *, loff_t start);
1731 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1733 extern struct file *filp_open(const char *, int, int);
1734 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1735 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1736 + struct nameidata *nd, struct lookup_intent *it);
1737 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1738 + int flags, struct lookup_intent *it);
1739 extern int filp_close(struct file *, fl_owner_t id);
1740 extern char * getname(const char *);
1742 @@ -1386,6 +1409,7 @@ typedef int (*read_actor_t)(read_descrip
1743 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1745 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1746 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1747 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1748 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1749 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1750 @@ -1397,6 +1421,8 @@ extern struct dentry * lookup_one_len(co
1751 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1752 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1753 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1754 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1755 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1757 extern void inode_init_once(struct inode *);
1758 extern void iput(struct inode *);
1759 @@ -1500,6 +1526,8 @@ extern struct file_operations generic_ro
1761 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1762 extern int vfs_follow_link(struct nameidata *, const char *);
1763 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1764 + struct lookup_intent *it);
1765 extern int page_readlink(struct dentry *, char *, int);
1766 extern int page_follow_link(struct dentry *, struct nameidata *);
1767 extern struct inode_operations page_symlink_inode_operations;
1768 Index: linux-2.4.24/include/linux/fs_struct.h
1769 ===================================================================
1770 --- linux-2.4.24.orig/include/linux/fs_struct.h Fri Jul 13 15:10:44 2001
1771 +++ linux-2.4.24/include/linux/fs_struct.h Wed Mar 17 17:36:14 2004
1772 @@ -34,10 +34,12 @@ static inline void set_fs_root(struct fs
1773 write_lock(&fs->lock);
1774 old_root = fs->root;
1775 old_rootmnt = fs->rootmnt;
1776 + PIN(dentry, mnt, 1);
1777 fs->rootmnt = mntget(mnt);
1778 fs->root = dget(dentry);
1779 write_unlock(&fs->lock);
1781 + UNPIN(old_root, old_rootmnt, 1);
1783 mntput(old_rootmnt);
1785 @@ -57,10 +59,12 @@ static inline void set_fs_pwd(struct fs_
1786 write_lock(&fs->lock);
1788 old_pwdmnt = fs->pwdmnt;
1789 + PIN(dentry, mnt, 0);
1790 fs->pwdmnt = mntget(mnt);
1791 fs->pwd = dget(dentry);
1792 write_unlock(&fs->lock);
1794 + UNPIN(old_pwd, old_pwdmnt, 0);
1798 Index: linux-2.4.24/kernel/exit.c
1799 ===================================================================
1800 --- linux-2.4.24.orig/kernel/exit.c Thu Nov 28 15:53:15 2002
1801 +++ linux-2.4.24/kernel/exit.c Wed Mar 17 17:36:14 2004
1802 @@ -238,11 +238,14 @@ static inline void __put_fs_struct(struc
1804 /* No need to hold fs->lock if we are killing it */
1805 if (atomic_dec_and_test(&fs->count)) {
1806 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1807 + UNPIN(fs->root, fs->rootmnt, 1);
1809 mntput(fs->rootmnt);
1813 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1815 mntput(fs->altrootmnt);
1817 Index: linux-2.4.24/kernel/fork.c
1818 ===================================================================
1819 --- linux-2.4.24.orig/kernel/fork.c Fri Nov 28 10:26:21 2003
1820 +++ linux-2.4.24/kernel/fork.c Wed Mar 17 17:36:14 2004
1821 @@ -386,10 +386,13 @@ static inline struct fs_struct *__copy_f
1822 fs->umask = old->umask;
1823 read_lock(&old->lock);
1824 fs->rootmnt = mntget(old->rootmnt);
1825 + PIN(old->pwd, old->pwdmnt, 0);
1826 + PIN(old->root, old->rootmnt, 1);
1827 fs->root = dget(old->root);
1828 fs->pwdmnt = mntget(old->pwdmnt);
1829 fs->pwd = dget(old->pwd);
1831 + PIN(old->altroot, old->altrootmnt, 1);
1832 fs->altrootmnt = mntget(old->altrootmnt);
1833 fs->altroot = dget(old->altroot);
1835 Index: linux-2.4.24/kernel/ksyms.c
1836 ===================================================================
1837 --- linux-2.4.24.orig/kernel/ksyms.c Wed Mar 17 17:36:14 2004
1838 +++ linux-2.4.24/kernel/ksyms.c Wed Mar 17 17:36:14 2004
1839 @@ -275,6 +275,7 @@ EXPORT_SYMBOL(set_page_dirty);
1840 EXPORT_SYMBOL(mark_page_accessed);
1841 EXPORT_SYMBOL(vfs_readlink);
1842 EXPORT_SYMBOL(vfs_follow_link);
1843 +EXPORT_SYMBOL(vfs_follow_link_it);
1844 EXPORT_SYMBOL(page_readlink);
1845 EXPORT_SYMBOL(page_follow_link);
1846 EXPORT_SYMBOL(page_symlink_inode_operations);