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 --- linux-2.4.22-ac1/fs/dcache.c~vfs_intent-2.4.22-rh 2003-09-25 14:16:29.000000000 +0400
16 +++ linux-2.4.22-ac1-alexey/fs/dcache.c 2003-09-25 14:42:46.000000000 +0400
17 @@ -181,6 +181,13 @@ int d_invalidate(struct dentry * dentry)
18 spin_unlock(&dcache_lock);
22 + /* network invalidation by Lustre */
23 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
24 + spin_unlock(&dcache_lock);
29 * Check whether to do a partial shrink_dcache
30 * to get rid of unused child entries.
31 @@ -833,13 +840,19 @@ void d_delete(struct dentry * dentry)
32 * Adds a dentry to the hash according to its name.
35 -void d_rehash(struct dentry * entry)
36 +void __d_rehash(struct dentry * entry, int lock)
38 struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
39 if (!list_empty(&entry->d_hash)) BUG();
40 - spin_lock(&dcache_lock);
41 + if (lock) spin_lock(&dcache_lock);
42 list_add(&entry->d_hash, list);
43 - spin_unlock(&dcache_lock);
44 + if (lock) spin_unlock(&dcache_lock);
46 +EXPORT_SYMBOL(__d_rehash);
48 +void d_rehash(struct dentry * entry)
50 + __d_rehash(entry, 1);
53 #define do_switch(x,y) do { \
54 --- linux-2.4.22-ac1/fs/exec.c~vfs_intent-2.4.22-rh 2003-09-25 14:16:29.000000000 +0400
55 +++ linux-2.4.22-ac1-alexey/fs/exec.c 2003-09-25 14:42:46.000000000 +0400
56 @@ -115,8 +115,10 @@ asmlinkage long sys_uselib(const char *
60 + struct lookup_intent it = { .it_op = IT_OPEN,
61 + .it_flags = FMODE_READ|FMODE_EXEC };
63 - error = user_path_walk(library, &nd);
64 + error = user_path_walk_it(library, &nd, &it);
68 @@ -128,7 +130,8 @@ asmlinkage long sys_uselib(const char *
72 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
73 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
74 + intent_release(&it);
75 error = PTR_ERR(file);
78 @@ -390,8 +393,10 @@ struct file *open_exec(const char *name)
82 + struct lookup_intent it = { .it_op = IT_OPEN,
83 + .it_flags = FMODE_READ|FMODE_EXEC };
85 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
86 + err = path_lookup_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
89 inode = nd.dentry->d_inode;
90 @@ -403,7 +408,8 @@ struct file *open_exec(const char *name)
94 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
95 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
96 + intent_release(&it);
98 err = deny_write_access(file);
100 @@ -415,6 +421,7 @@ out:
104 + intent_release(&it);
108 @@ -1322,7 +1329,7 @@ int do_coredump(long signr, int exit_cod
110 if (!file->f_op->write)
112 - if (do_truncate(file->f_dentry, 0) != 0)
113 + if (do_truncate(file->f_dentry, 0, 0) != 0)
116 retval = binfmt->core_dump(signr, regs, file);
117 --- linux-2.4.22-ac1/fs/namei.c~vfs_intent-2.4.22-rh 2003-09-25 14:16:23.000000000 +0400
118 +++ linux-2.4.22-ac1-alexey/fs/namei.c 2003-09-25 14:44:40.000000000 +0400
120 * XEmacs seems to be relying on it...
123 +void intent_release(struct lookup_intent *it)
125 + if (it && it->it_op_release)
126 + it->it_op_release(it);
130 /* In order to reduce some races, while at the same time doing additional
131 * checking and hopefully speeding things up, we copy filenames to the
132 * kernel data space before using them..
133 @@ -260,10 +267,19 @@ void path_release(struct nameidata *nd)
134 * Internal lookup() using the new generic dcache.
137 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
138 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
139 + int flags, struct lookup_intent *it)
141 struct dentry * dentry = d_lookup(parent, name);
143 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
144 + if (!dentry->d_op->d_revalidate_it(dentry, flags, it) &&
145 + !d_invalidate(dentry)) {
151 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
152 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
154 @@ -281,11 +297,15 @@ static struct dentry * cached_lookup(str
155 * make sure that nobody added the entry to the dcache in the meantime..
158 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
159 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
160 + int flags, struct lookup_intent *it)
162 struct dentry * result;
163 struct inode *dir = parent->d_inode;
170 * First re-do the cached lookup just in case it was created
171 @@ -300,6 +320,9 @@ static struct dentry * real_lookup(struc
172 result = ERR_PTR(-ENOMEM);
175 + if (dir->i_op->lookup_it)
176 + result = dir->i_op->lookup_it(dir, dentry, it, flags);
178 result = dir->i_op->lookup(dir, dentry);
181 @@ -321,6 +344,15 @@ static struct dentry * real_lookup(struc
183 result = ERR_PTR(-ENOENT);
185 + } else if (result->d_op && result->d_op->d_revalidate_it) {
186 + if (!result->d_op->d_revalidate_it(result, flags, it) &&
187 + !d_invalidate(result)) {
190 + result = ERR_PTR(-ESTALE);
191 + if (!IS_ERR(result))
197 @@ -332,7 +364,8 @@ static struct dentry * real_lookup(struc
198 * Without that kind of total limit, nasty chains of consecutive
199 * symlinks can cause almost arbitrarily long lookups.
201 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
202 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
203 + struct lookup_intent *it)
206 if (current->link_count >= 5)
207 @@ -346,10 +379,12 @@ static inline int do_follow_link(struct
208 current->link_count++;
209 current->total_link_count++;
210 UPDATE_ATIME(dentry->d_inode);
212 err = dentry->d_inode->i_op->follow_link(dentry, nd);
213 current->link_count--;
216 + intent_release(it);
220 @@ -447,7 +482,8 @@ static inline void follow_dotdot(struct
222 * We expect 'base' to be positive and a directory.
224 -int link_path_walk(const char * name, struct nameidata *nd)
225 +int link_path_walk_it(const char *name, struct nameidata *nd,
226 + struct lookup_intent *it)
228 struct dentry *dentry;
230 @@ -520,9 +556,9 @@ int link_path_walk(const char * name, st
233 /* This does the actual lookups.. */
234 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
235 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
237 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
238 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
239 err = PTR_ERR(dentry);
242 @@ -540,7 +576,7 @@ int link_path_walk(const char * name, st
245 if (inode->i_op->follow_link) {
246 - err = do_follow_link(dentry, nd);
247 + err = do_follow_link(dentry, nd, NULL);
251 @@ -556,7 +592,7 @@ int link_path_walk(const char * name, st
255 - if (!inode->i_op->lookup)
256 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
259 /* here ends the main loop */
260 @@ -583,9 +619,9 @@ last_component:
264 - dentry = cached_lookup(nd->dentry, &this, 0);
265 + dentry = cached_lookup(nd->dentry, &this, 0, it);
267 - dentry = real_lookup(nd->dentry, &this, 0);
268 + dentry = real_lookup(nd->dentry, &this, 0, it);
269 err = PTR_ERR(dentry);
272 @@ -595,7 +631,7 @@ last_component:
273 inode = dentry->d_inode;
274 if ((lookup_flags & LOOKUP_FOLLOW)
275 && inode && inode->i_op && inode->i_op->follow_link) {
276 - err = do_follow_link(dentry, nd);
277 + err = do_follow_link(dentry, nd, it);
281 @@ -609,7 +645,8 @@ last_component:
283 if (lookup_flags & LOOKUP_DIRECTORY) {
285 - if (!inode->i_op || !inode->i_op->lookup)
286 + if (!inode->i_op ||
287 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
291 @@ -635,6 +672,25 @@ return_reval:
292 * Check the cached dentry for staleness.
295 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
297 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
298 + struct dentry *new;
299 + err = permission(dentry->d_parent->d_inode,
303 + new = real_lookup(dentry->d_parent,
304 + &dentry->d_name, 0, it);
305 + d_invalidate(dentry);
308 + err = PTR_ERR(new);
314 if (dentry && dentry->d_sb
315 && (dentry->d_sb->s_type->fs_flags & FS_ALWAYS_REVAL)) {
317 @@ -649,15 +705,28 @@ out_dput:
322 + intent_release(it);
328 +int link_path_walk(const char * name, struct nameidata *nd)
330 + return link_path_walk_it(name, nd, NULL);
333 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
335 + current->total_link_count = 0;
336 + return link_path_walk_it(name, nd, it);
339 int path_walk(const char * name, struct nameidata *nd)
341 current->total_link_count = 0;
342 - return link_path_walk(name, nd);
343 + return link_path_walk_it(name, nd, NULL);
347 @@ -742,6 +811,17 @@ walk_init_root(const char *name, struct
351 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
352 + struct lookup_intent *it)
355 + if (path_init(path, flags, nd))
356 + error = path_walk_it(path, nd, it);
362 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
365 @@ -756,6 +836,7 @@ int path_init(const char *name, unsigned
367 nd->last_type = LAST_ROOT; /* if there are only slashes... */
371 return walk_init_root(name,nd);
372 read_lock(¤t->fs->lock);
373 @@ -770,7 +851,8 @@ int path_init(const char *name, unsigned
374 * needs parent already locked. Doesn't follow mounts.
377 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
378 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
379 + struct lookup_intent *it)
381 struct dentry * dentry;
383 @@ -793,13 +875,16 @@ struct dentry * lookup_hash(struct qstr
387 - dentry = cached_lookup(base, name, 0);
388 + dentry = cached_lookup(base, name, 0, it);
390 struct dentry *new = d_alloc(base, name);
391 dentry = ERR_PTR(-ENOMEM);
395 + if (inode->i_op->lookup_it)
396 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
398 dentry = inode->i_op->lookup(inode, new);
401 @@ -811,6 +896,12 @@ out:
405 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
407 + return lookup_hash_it(name, base, NULL);
412 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
414 @@ -832,7 +923,7 @@ struct dentry * lookup_one_len(const cha
416 this.hash = end_name_hash(hash);
418 - return lookup_hash(&this, base);
419 + return lookup_hash_it(&this, base, NULL);
421 return ERR_PTR(-EACCES);
423 @@ -863,6 +954,23 @@ int __user_walk(const char *name, unsign
427 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
428 + struct lookup_intent *it)
433 + tmp = getname(name);
434 + err = PTR_ERR(tmp);
435 + if (!IS_ERR(tmp)) {
437 + if (path_init(tmp, flags, nd))
438 + err = path_walk_it(tmp, nd, it);
445 * It's inline, so penalty for filesystems that don't use sticky bit is
447 @@ -958,7 +1066,8 @@ static inline int lookup_flags(unsigned
451 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
452 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
453 + struct lookup_intent *it)
457 @@ -971,12 +1080,15 @@ int vfs_create(struct inode *dir, struct
460 error = -EACCES; /* shouldn't it be ENOSYS? */
461 - if (!dir->i_op || !dir->i_op->create)
462 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
467 - error = dir->i_op->create(dir, dentry, mode);
468 + if (dir->i_op->create_it)
469 + error = dir->i_op->create_it(dir, dentry, mode, it);
471 + error = dir->i_op->create(dir, dentry, mode);
475 @@ -985,6 +1097,11 @@ exit_lock:
479 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
481 + return vfs_create_it(dir, dentry, mode, NULL);
487 @@ -999,7 +1116,8 @@ exit_lock:
488 * for symlinks (where the permissions are checked later).
491 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
492 +int open_namei_it(const char *pathname, int flag, int mode,
493 + struct nameidata *nd, struct lookup_intent *it)
495 int acc_mode, error = 0;
497 @@ -1009,11 +1127,14 @@ int open_namei(const char * pathname, in
499 acc_mode = ACC_MODE(flag);
502 + it->it_flags = flag;
505 * The simplest case - just a plain lookup.
507 if (!(flag & O_CREAT)) {
508 - error = path_lookup(pathname, lookup_flags(flag), nd);
509 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
513 @@ -1023,6 +1144,10 @@ int open_namei(const char * pathname, in
515 * Create - we need to know the parent.
518 + it->it_create_mode = mode;
519 + it->it_op |= IT_CREAT;
521 error = path_lookup(pathname, LOOKUP_PARENT, nd);
524 @@ -1038,7 +1163,7 @@ int open_namei(const char * pathname, in
527 down(&dir->d_inode->i_sem);
528 - dentry = lookup_hash(&nd->last, nd->dentry);
529 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
532 error = PTR_ERR(dentry);
533 @@ -1047,10 +1172,11 @@ do_last:
537 + it->it_create_mode = mode;
538 /* Negative dentry, just create the file */
539 if (!dentry->d_inode) {
540 - error = vfs_create(dir->d_inode, dentry,
541 - mode & ~current->fs->umask);
542 + error = vfs_create_it(dir->d_inode, dentry,
543 + mode & ~current->fs->umask, it);
544 up(&dir->d_inode->i_sem);
547 @@ -1154,7 +1280,7 @@ ok:
551 - error = do_truncate(dentry, 0);
552 + error = do_truncate(dentry, 0, 1);
554 put_write_access(inode);
556 @@ -1166,8 +1292,10 @@ ok:
560 + intent_release(it);
563 + intent_release(it);
567 @@ -1186,7 +1314,10 @@ do_link:
568 * are done. Procfs-like symlinks just set LAST_BIND.
570 UPDATE_ATIME(dentry->d_inode);
572 error = dentry->d_inode->i_op->follow_link(dentry, nd);
574 + intent_release(it);
578 @@ -1208,13 +1339,20 @@ do_link:
581 down(&dir->d_inode->i_sem);
582 - dentry = lookup_hash(&nd->last, nd->dentry);
583 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
584 putname(nd->last.name);
588 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
590 + return open_namei_it(pathname, flag, mode, nd, NULL);
595 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
596 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
597 + struct lookup_intent *it)
599 struct dentry *dentry;
601 @@ -1222,7 +1360,7 @@ static struct dentry *lookup_create(stru
602 dentry = ERR_PTR(-EEXIST);
603 if (nd->last_type != LAST_NORM)
605 - dentry = lookup_hash(&nd->last, nd->dentry);
606 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
609 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
610 @@ -1278,7 +1416,20 @@ asmlinkage long sys_mknod(const char * f
611 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
614 - dentry = lookup_create(&nd, 0);
616 + if (nd.last_type != LAST_NORM) {
620 + if (nd.dentry->d_inode->i_op->mknod_raw) {
621 + struct inode_operations *op = nd.dentry->d_inode->i_op;
622 + error = op->mknod_raw(&nd, mode, dev);
623 + /* the file system wants to use normal vfs path now */
624 + if (error != -EOPNOTSUPP)
628 + dentry = lookup_create(&nd, 0, NULL);
629 error = PTR_ERR(dentry);
631 mode &= ~current->fs->umask;
632 @@ -1299,6 +1446,7 @@ asmlinkage long sys_mknod(const char * f
635 up(&nd.dentry->d_inode->i_sem);
640 @@ -1346,7 +1494,20 @@ asmlinkage long sys_mkdir(const char * p
641 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
644 - dentry = lookup_create(&nd, 1);
645 + if (nd.last_type != LAST_NORM) {
649 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
650 + struct inode_operations *op = nd.dentry->d_inode->i_op;
651 + error = op->mkdir_raw(&nd, mode);
652 + /* the file system wants to use normal vfs path now */
653 + if (error != -EOPNOTSUPP)
656 + dentry = lookup_create(&nd, 1, NULL);
657 error = PTR_ERR(dentry);
658 if (!IS_ERR(dentry)) {
659 error = vfs_mkdir(nd.dentry->d_inode, dentry,
660 @@ -1354,6 +1509,7 @@ asmlinkage long sys_mkdir(const char * p
663 up(&nd.dentry->d_inode->i_sem);
668 @@ -1454,8 +1610,16 @@ asmlinkage long sys_rmdir(const char * p
672 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
673 + struct inode_operations *op = nd.dentry->d_inode->i_op;
675 + error = op->rmdir_raw(&nd);
676 + /* the file system wants to use normal vfs path now */
677 + if (error != -EOPNOTSUPP)
680 down(&nd.dentry->d_inode->i_sem);
681 - dentry = lookup_hash(&nd.last, nd.dentry);
682 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
683 error = PTR_ERR(dentry);
684 if (!IS_ERR(dentry)) {
685 error = vfs_rmdir(nd.dentry->d_inode, dentry);
686 @@ -1513,8 +1677,15 @@ asmlinkage long sys_unlink(const char *
688 if (nd.last_type != LAST_NORM)
690 + if (nd.dentry->d_inode->i_op->unlink_raw) {
691 + struct inode_operations *op = nd.dentry->d_inode->i_op;
692 + error = op->unlink_raw(&nd);
693 + /* the file system wants to use normal vfs path now */
694 + if (error != -EOPNOTSUPP)
697 down(&nd.dentry->d_inode->i_sem);
698 - dentry = lookup_hash(&nd.last, nd.dentry);
699 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
700 error = PTR_ERR(dentry);
701 if (!IS_ERR(dentry)) {
702 /* Why not before? Because we want correct error value */
703 @@ -1581,15 +1752,27 @@ asmlinkage long sys_symlink(const char *
704 error = path_lookup(to, LOOKUP_PARENT, &nd);
707 - dentry = lookup_create(&nd, 0);
708 + if (nd.last_type != LAST_NORM) {
712 + if (nd.dentry->d_inode->i_op->symlink_raw) {
713 + struct inode_operations *op = nd.dentry->d_inode->i_op;
714 + error = op->symlink_raw(&nd, from);
715 + /* the file system wants to use normal vfs path now */
716 + if (error != -EOPNOTSUPP)
719 + dentry = lookup_create(&nd, 0, NULL);
720 error = PTR_ERR(dentry);
721 if (!IS_ERR(dentry)) {
722 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
725 up(&nd.dentry->d_inode->i_sem);
733 @@ -1665,7 +1844,18 @@ asmlinkage long sys_link(const char * ol
735 if (old_nd.mnt != nd.mnt)
737 - new_dentry = lookup_create(&nd, 0);
738 + if (nd.last_type != LAST_NORM) {
742 + if (nd.dentry->d_inode->i_op->link_raw) {
743 + struct inode_operations *op = nd.dentry->d_inode->i_op;
744 + error = op->link_raw(&old_nd, &nd);
745 + /* the file system wants to use normal vfs path now */
746 + if (error != -EOPNOTSUPP)
749 + new_dentry = lookup_create(&nd, 0, NULL);
750 error = PTR_ERR(new_dentry);
751 if (!IS_ERR(new_dentry)) {
752 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
753 @@ -1709,7 +1895,7 @@ exit:
756 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
757 - struct inode *new_dir, struct dentry *new_dentry)
758 + struct inode *new_dir, struct dentry *new_dentry)
761 struct inode *target;
762 @@ -1788,7 +1974,7 @@ out_unlock:
765 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
766 - struct inode *new_dir, struct dentry *new_dentry)
767 + struct inode *new_dir, struct dentry *new_dentry)
771 @@ -1876,9 +2062,18 @@ static inline int do_rename(const char *
772 if (newnd.last_type != LAST_NORM)
775 + if (old_dir->d_inode->i_op->rename_raw) {
777 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
779 + /* the file system wants to use normal vfs path now */
780 + if (error != -EOPNOTSUPP)
784 double_lock(new_dir, old_dir);
786 - old_dentry = lookup_hash(&oldnd.last, old_dir);
787 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
788 error = PTR_ERR(old_dentry);
789 if (IS_ERR(old_dentry))
791 @@ -1894,16 +2089,16 @@ static inline int do_rename(const char *
792 if (newnd.last.name[newnd.last.len])
795 - new_dentry = lookup_hash(&newnd.last, new_dir);
796 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
797 error = PTR_ERR(new_dentry);
798 if (IS_ERR(new_dentry))
803 error = vfs_rename(old_dir->d_inode, old_dentry,
804 new_dir->d_inode, new_dentry);
810 @@ -1954,20 +2149,26 @@ out:
814 -__vfs_follow_link(struct nameidata *nd, const char *link)
815 +__vfs_follow_link(struct nameidata *nd, const char *link,
816 + struct lookup_intent *it)
825 + else if (it != nd->intent)
826 + printk("it != nd->intent: tell phil@clusterfs.com\n");
830 if (!walk_init_root(link, nd))
831 /* weird __emul_prefix() stuff did it */
834 - res = link_path_walk(link, nd);
835 + res = link_path_walk_it(link, nd, it);
837 if (current->link_count || res || nd->last_type!=LAST_NORM)
839 @@ -1991,7 +2192,13 @@ fail:
841 int vfs_follow_link(struct nameidata *nd, const char *link)
843 - return __vfs_follow_link(nd, link);
844 + return __vfs_follow_link(nd, link, NULL);
847 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
848 + struct lookup_intent *it)
850 + return __vfs_follow_link(nd, link, it);
853 /* get the link contents into pagecache */
854 @@ -2033,7 +2240,7 @@ int page_follow_link(struct dentry *dent
856 struct page *page = NULL;
857 char *s = page_getlink(dentry, &page);
858 - int res = __vfs_follow_link(nd, s);
859 + int res = __vfs_follow_link(nd, s, NULL);
862 page_cache_release(page);
863 --- linux-2.4.22-ac1/fs/namespace.c~vfs_intent-2.4.22-rh 2003-09-25 14:16:28.000000000 +0400
864 +++ linux-2.4.22-ac1-alexey/fs/namespace.c 2003-09-25 14:42:46.000000000 +0400
865 @@ -98,6 +98,7 @@ static void detach_mnt(struct vfsmount *
867 old_nd->dentry = mnt->mnt_mountpoint;
868 old_nd->mnt = mnt->mnt_parent;
869 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
870 mnt->mnt_parent = mnt;
871 mnt->mnt_mountpoint = mnt->mnt_root;
872 list_del_init(&mnt->mnt_child);
873 @@ -109,6 +110,7 @@ static void attach_mnt(struct vfsmount *
875 mnt->mnt_parent = mntget(nd->mnt);
876 mnt->mnt_mountpoint = dget(nd->dentry);
877 + PIN(nd->dentry, nd->mnt, 1);
878 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
879 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
880 nd->dentry->d_mounted++;
881 @@ -488,14 +490,17 @@ static int do_loopback(struct nameidata
883 struct nameidata old_nd;
884 struct vfsmount *mnt = NULL;
885 + struct lookup_intent it = { .it_op = IT_GETATTR };
886 int err = mount_is_safe(nd);
889 if (!old_name || !*old_name)
891 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
893 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
895 + intent_release(&it);
899 down_write(¤t->namespace->sem);
901 @@ -518,6 +523,7 @@ static int do_loopback(struct nameidata
904 up_write(¤t->namespace->sem);
905 + intent_release(&it);
906 path_release(&old_nd);
909 @@ -701,6 +707,7 @@ long do_mount(char * dev_name, char * di
910 unsigned long flags, void *data_page)
913 + struct lookup_intent it = { .it_op = IT_GETATTR };
917 @@ -725,9 +732,11 @@ long do_mount(char * dev_name, char * di
918 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
920 /* ... and get the mountpoint */
921 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
923 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
925 + intent_release(&it);
929 if (flags & MS_REMOUNT)
930 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
931 @@ -739,6 +747,8 @@ long do_mount(char * dev_name, char * di
933 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
934 dev_name, data_page);
936 + intent_release(&it);
940 @@ -904,6 +914,8 @@ asmlinkage long sys_pivot_root(const cha
942 struct vfsmount *tmp;
943 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
944 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
945 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
948 if (!capable(CAP_SYS_ADMIN))
949 @@ -911,14 +923,14 @@ asmlinkage long sys_pivot_root(const cha
953 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
954 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
958 if (!check_mnt(new_nd.mnt))
961 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
962 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
966 @@ -973,8 +985,10 @@ out2:
967 up(&old_nd.dentry->d_inode->i_zombie);
968 up_write(¤t->namespace->sem);
969 path_release(&user_nd);
970 + intent_release(&old_it);
971 path_release(&old_nd);
973 + intent_release(&new_it);
974 path_release(&new_nd);
977 --- linux-2.4.22-ac1/fs/open.c~vfs_intent-2.4.22-rh 2003-08-25 15:44:43.000000000 +0400
978 +++ linux-2.4.22-ac1-alexey/fs/open.c 2003-09-25 14:42:46.000000000 +0400
980 #include <asm/uaccess.h>
982 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
983 +extern int path_walk_it(const char *name, struct nameidata *nd,
984 + struct lookup_intent *it);
986 int vfs_statfs(struct super_block *sb, struct statfs *buf)
988 @@ -95,9 +97,10 @@ void fd_install(unsigned int fd, struct
989 write_unlock(&files->file_lock);
992 -int do_truncate(struct dentry *dentry, loff_t length)
993 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
995 struct inode *inode = dentry->d_inode;
996 + struct inode_operations *op = dentry->d_inode->i_op;
998 struct iattr newattrs;
1000 @@ -109,7 +112,13 @@ int do_truncate(struct dentry *dentry, l
1001 down(&inode->i_sem);
1002 newattrs.ia_size = length;
1003 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1004 - error = notify_change(dentry, &newattrs);
1005 + if (called_from_open)
1006 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1007 + if (op->setattr_raw) {
1008 + newattrs.ia_valid |= ATTR_RAW;
1009 + error = op->setattr_raw(inode, &newattrs);
1011 + error = notify_change(dentry, &newattrs);
1013 up_write(&inode->i_alloc_sem);
1015 @@ -120,12 +129,13 @@ static inline long do_sys_truncate(const
1016 struct nameidata nd;
1017 struct inode * inode;
1019 + struct lookup_intent it = { .it_op = IT_GETATTR };
1022 if (length < 0) /* sorry, but loff_t says... */
1025 - error = user_path_walk(path, &nd);
1026 + error = user_path_walk_it(path, &nd, &it);
1029 inode = nd.dentry->d_inode;
1030 @@ -165,11 +175,13 @@ static inline long do_sys_truncate(const
1031 error = locks_verify_truncate(inode, NULL, length);
1034 - error = do_truncate(nd.dentry, length);
1035 + intent_release(&it);
1036 + error = do_truncate(nd.dentry, length, 0);
1038 put_write_access(inode);
1041 + intent_release(&it);
1045 @@ -217,7 +229,7 @@ static inline long do_sys_ftruncate(unsi
1047 error = locks_verify_truncate(inode, file, length);
1049 - error = do_truncate(dentry, length);
1050 + error = do_truncate(dentry, length, 0);
1054 @@ -262,11 +274,13 @@ asmlinkage long sys_utime(char * filenam
1055 struct inode * inode;
1056 struct iattr newattrs;
1058 - error = user_path_walk(filename, &nd);
1059 + error = user_path_walk_it(filename, &nd, NULL);
1062 inode = nd.dentry->d_inode;
1064 + /* this is safe without a Lustre lock because it only depends
1065 + on the super block */
1067 if (IS_RDONLY(inode))
1069 @@ -281,11 +295,25 @@ asmlinkage long sys_utime(char * filenam
1072 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1076 + if (inode->i_op->setattr_raw) {
1077 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1079 + newattrs.ia_valid |= ATTR_RAW;
1080 + error = op->setattr_raw(inode, &newattrs);
1081 + /* the file system wants to use normal vfs path now */
1082 + if (error != -EOPNOTSUPP)
1083 + goto dput_and_out;
1088 if (current->fsuid != inode->i_uid &&
1089 (error = permission(inode,MAY_WRITE)) != 0)
1093 error = notify_change(nd.dentry, &newattrs);
1096 @@ -306,12 +334,14 @@ asmlinkage long sys_utimes(char * filena
1097 struct inode * inode;
1098 struct iattr newattrs;
1100 - error = user_path_walk(filename, &nd);
1101 + error = user_path_walk_it(filename, &nd, NULL);
1105 inode = nd.dentry->d_inode;
1107 + /* this is safe without a Lustre lock because it only depends
1108 + on the super block */
1110 if (IS_RDONLY(inode))
1112 @@ -326,7 +356,20 @@ asmlinkage long sys_utimes(char * filena
1113 newattrs.ia_atime = times[0].tv_sec;
1114 newattrs.ia_mtime = times[1].tv_sec;
1115 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1119 + if (inode->i_op->setattr_raw) {
1120 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1122 + newattrs.ia_valid |= ATTR_RAW;
1123 + error = op->setattr_raw(inode, &newattrs);
1124 + /* the file system wants to use normal vfs path now */
1125 + if (error != -EOPNOTSUPP)
1126 + goto dput_and_out;
1131 if (current->fsuid != inode->i_uid &&
1132 (error = permission(inode,MAY_WRITE)) != 0)
1134 @@ -349,6 +392,7 @@ asmlinkage long sys_access(const char *
1135 int old_fsuid, old_fsgid;
1136 kernel_cap_t old_cap;
1138 + struct lookup_intent it = { .it_op = IT_GETATTR };
1140 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1142 @@ -366,13 +410,14 @@ asmlinkage long sys_access(const char *
1144 current->cap_effective = current->cap_permitted;
1146 - res = user_path_walk(filename, &nd);
1147 + res = user_path_walk_it(filename, &nd, &it);
1149 res = permission(nd.dentry->d_inode, mode);
1150 /* SuS v2 requires we report a read only fs too */
1151 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1152 && !special_file(nd.dentry->d_inode->i_mode))
1154 + intent_release(&it);
1158 @@ -387,8 +432,9 @@ asmlinkage long sys_chdir(const char * f
1161 struct nameidata nd;
1162 + struct lookup_intent it = { .it_op = IT_GETATTR };
1164 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1165 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1169 @@ -399,6 +445,7 @@ asmlinkage long sys_chdir(const char * f
1170 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1173 + intent_release(&it);
1177 @@ -438,9 +485,10 @@ asmlinkage long sys_chroot(const char *
1180 struct nameidata nd;
1181 + struct lookup_intent it = { .it_op = IT_GETATTR };
1183 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1184 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1185 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1186 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1190 @@ -456,39 +504,56 @@ asmlinkage long sys_chroot(const char *
1194 + intent_release(&it);
1200 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1201 +int chmod_common(struct dentry *dentry, mode_t mode)
1203 - struct inode * inode;
1204 - struct dentry * dentry;
1205 - struct file * file;
1207 + struct inode *inode = dentry->d_inode;
1208 struct iattr newattrs;
1213 + if (IS_RDONLY(inode))
1216 - dentry = file->f_dentry;
1217 - inode = dentry->d_inode;
1218 + if (inode->i_op->setattr_raw) {
1219 + newattrs.ia_mode = mode;
1220 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1221 + newattrs.ia_valid |= ATTR_RAW;
1222 + err = inode->i_op->setattr_raw(inode, &newattrs);
1223 + /* the file system wants to use normal vfs path now */
1224 + if (err != -EOPNOTSUPP)
1229 - if (IS_RDONLY(inode))
1232 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1236 if (mode == (mode_t) -1)
1237 mode = inode->i_mode;
1238 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1239 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1240 err = notify_change(dentry, &newattrs);
1247 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1249 + struct file * file;
1256 + err = chmod_common(file->f_dentry, mode);
1261 @@ -497,30 +562,14 @@ out:
1262 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1264 struct nameidata nd;
1265 - struct inode * inode;
1267 - struct iattr newattrs;
1269 error = user_path_walk(filename, &nd);
1272 - inode = nd.dentry->d_inode;
1275 - if (IS_RDONLY(inode))
1276 - goto dput_and_out;
1279 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1280 - goto dput_and_out;
1281 + error = chmod_common(nd.dentry, mode);
1283 - if (mode == (mode_t) -1)
1284 - mode = inode->i_mode;
1285 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1286 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1287 - error = notify_change(nd.dentry, &newattrs);
1293 @@ -540,6 +589,20 @@ static int chown_common(struct dentry *
1295 if (IS_RDONLY(inode))
1298 + if (inode->i_op->setattr_raw) {
1299 + struct inode_operations *op = dentry->d_inode->i_op;
1301 + newattrs.ia_uid = user;
1302 + newattrs.ia_gid = group;
1303 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1304 + newattrs.ia_valid |= ATTR_RAW;
1305 + error = op->setattr_raw(inode, &newattrs);
1306 + /* the file system wants to use normal vfs path now */
1307 + if (error != -EOPNOTSUPP)
1312 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1314 @@ -644,6 +707,7 @@ struct file *filp_open(const char * file
1316 int namei_flags, error;
1317 struct nameidata nd;
1318 + struct lookup_intent it = { .it_op = IT_OPEN };
1320 namei_flags = flags;
1321 if ((namei_flags+1) & O_ACCMODE)
1322 @@ -651,14 +715,15 @@ struct file *filp_open(const char * file
1323 if (namei_flags & O_TRUNC)
1326 - error = open_namei(filename, namei_flags, mode, &nd);
1328 - return dentry_open(nd.dentry, nd.mnt, flags);
1329 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1331 + return ERR_PTR(error);
1333 - return ERR_PTR(error);
1334 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1337 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1338 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1339 + int flags, struct lookup_intent *it)
1342 struct inode *inode;
1343 @@ -695,12 +760,15 @@ struct file *dentry_open(struct dentry *
1346 if (f->f_op && f->f_op->open) {
1348 error = f->f_op->open(inode,f);
1353 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1355 + intent_release(it);
1359 @@ -715,11 +783,17 @@ cleanup_all:
1363 + intent_release(it);
1366 return ERR_PTR(error);
1369 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1371 + return dentry_open_it(dentry, mnt, flags, NULL);
1375 * Find an empty file descriptor entry, and mark it busy.
1377 --- linux-2.4.22-ac1/fs/stat.c~vfs_intent-2.4.22-rh 2003-09-25 14:16:27.000000000 +0400
1378 +++ linux-2.4.22-ac1-alexey/fs/stat.c 2003-09-25 14:42:46.000000000 +0400
1380 * Revalidate the inode. This is required for proper NFS attribute caching.
1382 static __inline__ int
1383 -do_revalidate(struct dentry *dentry)
1384 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1386 struct inode * inode = dentry->d_inode;
1387 - if (inode->i_op && inode->i_op->revalidate)
1388 + if (inode->i_op && inode->i_op->revalidate_it)
1389 + return inode->i_op->revalidate_it(dentry, it);
1390 + else if (inode->i_op && inode->i_op->revalidate)
1391 return inode->i_op->revalidate(dentry);
1394 @@ -143,13 +147,15 @@ static int cp_new_stat(struct inode * in
1395 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1397 struct nameidata nd;
1398 + struct lookup_intent it = { .it_op = IT_GETATTR };
1401 - error = user_path_walk(filename, &nd);
1402 + error = user_path_walk_it(filename, &nd, &it);
1404 - error = do_revalidate(nd.dentry);
1405 + error = do_revalidate(nd.dentry, &it);
1407 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1408 + intent_release(&it);
1412 @@ -159,13 +165,15 @@ asmlinkage long sys_stat(char * filename
1413 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1415 struct nameidata nd;
1416 + struct lookup_intent it = { .it_op = IT_GETATTR };
1419 - error = user_path_walk(filename, &nd);
1420 + error = user_path_walk_it(filename, &nd, &it);
1422 - error = do_revalidate(nd.dentry);
1423 + error = do_revalidate(nd.dentry, &it);
1425 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1426 + intent_release(&it);
1430 @@ -180,13 +188,15 @@ asmlinkage long sys_newstat(char * filen
1431 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1433 struct nameidata nd;
1434 + struct lookup_intent it = { .it_op = IT_GETATTR };
1437 - error = user_path_walk_link(filename, &nd);
1438 + error = user_path_walk_link_it(filename, &nd, &it);
1440 - error = do_revalidate(nd.dentry);
1441 + error = do_revalidate(nd.dentry, &it);
1443 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1444 + intent_release(&it);
1448 @@ -197,13 +207,15 @@ asmlinkage long sys_lstat(char * filenam
1449 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1451 struct nameidata nd;
1452 + struct lookup_intent it = { .it_op = IT_GETATTR };
1455 - error = user_path_walk_link(filename, &nd);
1456 + error = user_path_walk_link_it(filename, &nd, &it);
1458 - error = do_revalidate(nd.dentry);
1459 + error = do_revalidate(nd.dentry, &it);
1461 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1462 + intent_release(&it);
1466 @@ -224,7 +236,7 @@ asmlinkage long sys_fstat(unsigned int f
1468 struct dentry * dentry = f->f_dentry;
1470 - err = do_revalidate(dentry);
1471 + err = do_revalidate(dentry, NULL);
1473 err = cp_old_stat(dentry->d_inode, statbuf);
1475 @@ -243,7 +255,7 @@ asmlinkage long sys_newfstat(unsigned in
1477 struct dentry * dentry = f->f_dentry;
1479 - err = do_revalidate(dentry);
1480 + err = do_revalidate(dentry, NULL);
1482 err = cp_new_stat(dentry->d_inode, statbuf);
1484 @@ -265,7 +277,7 @@ asmlinkage long sys_readlink(const char
1487 if (inode->i_op && inode->i_op->readlink &&
1488 - !(error = do_revalidate(nd.dentry))) {
1489 + !(error = do_revalidate(nd.dentry, NULL))) {
1490 UPDATE_ATIME(inode);
1491 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1493 @@ -341,12 +353,14 @@ asmlinkage long sys_stat64(char * filena
1495 struct nameidata nd;
1497 + struct lookup_intent it = { .it_op = IT_GETATTR };
1499 - error = user_path_walk(filename, &nd);
1500 + error = user_path_walk_it(filename, &nd, &it);
1502 - error = do_revalidate(nd.dentry);
1503 + error = do_revalidate(nd.dentry, &it);
1505 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1506 + intent_release(&it);
1510 @@ -356,12 +370,14 @@ asmlinkage long sys_lstat64(char * filen
1512 struct nameidata nd;
1514 + struct lookup_intent it = { .it_op = IT_GETATTR };
1516 - error = user_path_walk_link(filename, &nd);
1517 + error = user_path_walk_link_it(filename, &nd, &it);
1519 - error = do_revalidate(nd.dentry);
1520 + error = do_revalidate(nd.dentry, &it);
1522 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1523 + intent_release(&it);
1527 @@ -376,7 +392,7 @@ asmlinkage long sys_fstat64(unsigned lon
1529 struct dentry * dentry = f->f_dentry;
1531 - err = do_revalidate(dentry);
1532 + err = do_revalidate(dentry, NULL);
1534 err = cp_new_stat64(dentry->d_inode, statbuf);
1536 --- linux-2.4.22-ac1/include/linux/dcache.h~vfs_intent-2.4.22-rh 2003-09-25 14:16:28.000000000 +0400
1537 +++ linux-2.4.22-ac1-alexey/include/linux/dcache.h 2003-09-25 14:42:46.000000000 +0400
1539 #include <asm/atomic.h>
1540 #include <linux/mount.h>
1541 #include <linux/kernel.h>
1542 +#include <linux/string.h>
1544 +#define IT_OPEN 0x0001
1545 +#define IT_CREAT 0x0002
1546 +#define IT_READDIR 0x0004
1547 +#define IT_GETATTR 0x0008
1548 +#define IT_LOOKUP 0x0010
1549 +#define IT_UNLINK 0x0020
1550 +#define IT_GETXATTR 0x0040
1551 +#define IT_EXEC 0x0080
1552 +#define IT_PIN 0x0100
1554 +#define IT_FL_LOCKED 0x0001
1555 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1557 +#define INTENT_MAGIC 0x19620323
1560 +struct lustre_intent_data {
1561 + int it_disposition;
1563 + __u64 it_lock_handle;
1568 +struct lookup_intent {
1570 + void (*it_op_release)(struct lookup_intent *);
1573 + int it_create_mode;
1575 + struct lustre_intent_data lustre;
1579 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1581 + memset(it, 0, sizeof(*it));
1582 + it->it_magic = INTENT_MAGIC;
1584 + it->it_flags = flags;
1589 * linux/include/linux/dcache.h
1590 @@ -95,8 +140,22 @@ struct dentry_operations {
1591 int (*d_delete)(struct dentry *);
1592 void (*d_release)(struct dentry *);
1593 void (*d_iput)(struct dentry *, struct inode *);
1594 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1595 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1596 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1599 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1600 + de->d_op->d_pin(de, mnt, flag);
1601 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1602 + de->d_op->d_unpin(de, mnt, flag);
1605 +/* defined in fs/namei.c */
1606 +extern void intent_release(struct lookup_intent *it);
1607 +/* defined in fs/dcache.c */
1608 +extern void __d_rehash(struct dentry * entry, int lock);
1610 /* the dentry parameter passed to d_hash and d_compare is the parent
1611 * directory of the entries to be compared. It is used in case these
1612 * functions need any directory specific information for determining
1613 @@ -128,6 +187,7 @@ d_iput: no no yes
1614 * s_nfsd_free_path semaphore will be down
1616 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1617 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1619 extern spinlock_t dcache_lock;
1621 --- linux-2.4.22-ac1/include/linux/fs.h~vfs_intent-2.4.22-rh 2003-09-25 14:39:01.000000000 +0400
1622 +++ linux-2.4.22-ac1-alexey/include/linux/fs.h 2003-09-25 14:42:46.000000000 +0400
1623 @@ -73,6 +73,7 @@ extern int leases_enable, dir_notify_ena
1625 #define FMODE_READ 1
1626 #define FMODE_WRITE 2
1627 +#define FMODE_EXEC 4
1631 @@ -343,6 +344,9 @@ extern void set_bh_page(struct buffer_he
1632 #define ATTR_MTIME_SET 256
1633 #define ATTR_FORCE 512 /* Not a change, but a change it */
1634 #define ATTR_ATTR_FLAG 1024
1635 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1636 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1637 +#define ATTR_CTIME_SET 0x2000
1640 * This is the Inode Attributes structure, used for notify_change(). It
1641 @@ -481,6 +485,7 @@ struct inode {
1642 struct pipe_inode_info *i_pipe;
1643 struct block_device *i_bdev;
1644 struct char_device *i_cdev;
1645 + void *i_filterdata;
1647 unsigned long i_dnotify_mask; /* Directory notify events */
1648 struct dnotify_struct *i_dnotify; /* for directory notifications */
1649 @@ -583,6 +588,7 @@ struct file {
1651 /* needed for tty driver, and maybe others */
1653 + struct lookup_intent *f_it;
1655 /* preallocated helper kiobuf to speedup O_DIRECT */
1656 struct kiobuf *f_iobuf;
1657 @@ -703,6 +709,7 @@ struct nameidata {
1661 + struct lookup_intent *intent;
1665 @@ -823,7 +830,8 @@ extern int vfs_symlink(struct inode *, s
1666 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1667 extern int vfs_rmdir(struct inode *, struct dentry *);
1668 extern int vfs_unlink(struct inode *, struct dentry *);
1669 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1670 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1671 + struct inode *new_dir, struct dentry *new_dentry);
1675 @@ -883,21 +891,32 @@ struct file_operations {
1677 struct inode_operations {
1678 int (*create) (struct inode *,struct dentry *,int);
1679 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1680 struct dentry * (*lookup) (struct inode *,struct dentry *);
1681 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1682 int (*link) (struct dentry *,struct inode *,struct dentry *);
1683 + int (*link_raw) (struct nameidata *,struct nameidata *);
1684 int (*unlink) (struct inode *,struct dentry *);
1685 + int (*unlink_raw) (struct nameidata *);
1686 int (*symlink) (struct inode *,struct dentry *,const char *);
1687 + int (*symlink_raw) (struct nameidata *,const char *);
1688 int (*mkdir) (struct inode *,struct dentry *,int);
1689 + int (*mkdir_raw) (struct nameidata *,int);
1690 int (*rmdir) (struct inode *,struct dentry *);
1691 + int (*rmdir_raw) (struct nameidata *);
1692 int (*mknod) (struct inode *,struct dentry *,int,int);
1693 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1694 int (*rename) (struct inode *, struct dentry *,
1695 struct inode *, struct dentry *);
1696 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1697 int (*readlink) (struct dentry *, char *,int);
1698 int (*follow_link) (struct dentry *, struct nameidata *);
1699 void (*truncate) (struct inode *);
1700 int (*permission) (struct inode *, int);
1701 int (*revalidate) (struct dentry *);
1702 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1703 int (*setattr) (struct dentry *, struct iattr *);
1704 + int (*setattr_raw) (struct inode *, struct iattr *);
1705 int (*getattr) (struct dentry *, struct iattr *);
1706 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
1707 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1708 @@ -1094,10 +1113,14 @@ static inline int get_lease(struct inode
1710 asmlinkage long sys_open(const char *, int, int);
1711 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1712 -extern int do_truncate(struct dentry *, loff_t start);
1713 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1715 extern struct file *filp_open(const char *, int, int);
1716 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1717 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1718 + struct nameidata *nd, struct lookup_intent *it);
1719 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1720 + int flags, struct lookup_intent *it);
1721 extern int filp_close(struct file *, fl_owner_t id);
1722 extern char * getname(const char *);
1724 @@ -1388,6 +1411,7 @@ typedef int (*read_actor_t)(read_descrip
1725 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1727 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1728 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1729 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1730 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1731 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1732 @@ -1399,6 +1423,8 @@ extern struct dentry * lookup_one_len(co
1733 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1734 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1735 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1736 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1737 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1739 extern void inode_init_once(struct inode *);
1740 extern void iput(struct inode *);
1741 @@ -1538,6 +1564,8 @@ extern struct file_operations generic_ro
1743 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1744 extern int vfs_follow_link(struct nameidata *, const char *);
1745 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1746 + struct lookup_intent *it);
1747 extern int page_readlink(struct dentry *, char *, int);
1748 extern int page_follow_link(struct dentry *, struct nameidata *);
1749 extern struct inode_operations page_symlink_inode_operations;
1750 --- linux-2.4.22-ac1/include/linux/fs_struct.h~vfs_intent-2.4.22-rh 2003-09-25 14:16:24.000000000 +0400
1751 +++ linux-2.4.22-ac1-alexey/include/linux/fs_struct.h 2003-09-25 14:42:46.000000000 +0400
1752 @@ -37,10 +37,12 @@ static inline void set_fs_root(struct fs
1753 write_lock(&fs->lock);
1754 old_root = fs->root;
1755 old_rootmnt = fs->rootmnt;
1756 + PIN(dentry, mnt, 1);
1757 fs->rootmnt = mntget(mnt);
1758 fs->root = dget(dentry);
1759 write_unlock(&fs->lock);
1761 + UNPIN(old_root, old_rootmnt, 1);
1763 mntput(old_rootmnt);
1765 @@ -60,10 +62,12 @@ static inline void set_fs_pwd(struct fs_
1766 write_lock(&fs->lock);
1768 old_pwdmnt = fs->pwdmnt;
1769 + PIN(dentry, mnt, 0);
1770 fs->pwdmnt = mntget(mnt);
1771 fs->pwd = dget(dentry);
1772 write_unlock(&fs->lock);
1774 + UNPIN(old_pwd, old_pwdmnt, 0);
1778 --- linux-2.4.22-ac1/kernel/exit.c~vfs_intent-2.4.22-rh 2003-09-25 14:16:29.000000000 +0400
1779 +++ linux-2.4.22-ac1-alexey/kernel/exit.c 2003-09-25 14:42:46.000000000 +0400
1780 @@ -342,11 +342,14 @@ static inline void __put_fs_struct(struc
1782 /* No need to hold fs->lock if we are killing it */
1783 if (atomic_dec_and_test(&fs->count)) {
1784 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1785 + UNPIN(fs->root, fs->rootmnt, 1);
1787 mntput(fs->rootmnt);
1791 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1793 mntput(fs->altrootmnt);
1795 --- linux-2.4.22-ac1/kernel/fork.c~vfs_intent-2.4.22-rh 2003-09-25 14:16:28.000000000 +0400
1796 +++ linux-2.4.22-ac1-alexey/kernel/fork.c 2003-09-25 14:42:46.000000000 +0400
1797 @@ -457,10 +457,13 @@ static inline struct fs_struct *__copy_f
1798 fs->umask = old->umask;
1799 read_lock(&old->lock);
1800 fs->rootmnt = mntget(old->rootmnt);
1801 + PIN(old->pwd, old->pwdmnt, 0);
1802 + PIN(old->root, old->rootmnt, 1);
1803 fs->root = dget(old->root);
1804 fs->pwdmnt = mntget(old->pwdmnt);
1805 fs->pwd = dget(old->pwd);
1807 + PIN(old->altroot, old->altrootmnt, 1);
1808 fs->altrootmnt = mntget(old->altrootmnt);
1809 fs->altroot = dget(old->altroot);
1811 --- linux-2.4.22-ac1/kernel/ksyms.c~vfs_intent-2.4.22-rh 2003-09-25 14:39:02.000000000 +0400
1812 +++ linux-2.4.22-ac1-alexey/kernel/ksyms.c 2003-09-25 14:42:46.000000000 +0400
1813 @@ -295,6 +295,7 @@ EXPORT_SYMBOL(read_cache_page);
1814 EXPORT_SYMBOL(set_page_dirty);
1815 EXPORT_SYMBOL(vfs_readlink);
1816 EXPORT_SYMBOL(vfs_follow_link);
1817 +EXPORT_SYMBOL(vfs_follow_link_it);
1818 EXPORT_SYMBOL(page_readlink);
1819 EXPORT_SYMBOL(page_follow_link);
1820 EXPORT_SYMBOL(page_symlink_inode_operations);