3 fs/namei.c | 333 ++++++++++++++++++++++++++++++++++++++--------
4 fs/namespace.c | 28 ++-
5 fs/open.c | 176 +++++++++++++++++-------
8 include/linux/dcache.h | 60 ++++++++
9 include/linux/fs.h | 32 ++++
10 include/linux/fs_struct.h | 4
14 13 files changed, 578 insertions(+), 129 deletions(-)
16 --- linux-2.4.20-rh-20.9/fs/dcache.c~vfs_intent-2.4.20-rh 2003-09-13 19:34:35.000000000 +0400
17 +++ linux-2.4.20-rh-20.9-alexey/fs/dcache.c 2003-09-14 17:34:53.000000000 +0400
18 @@ -186,6 +186,13 @@ int d_invalidate(struct dentry * dentry)
19 spin_unlock(&dcache_lock);
23 + /* network invalidation by Lustre */
24 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
25 + spin_unlock(&dcache_lock);
30 * Check whether to do a partial shrink_dcache
31 * to get rid of unused child entries.
32 @@ -841,13 +848,19 @@ void d_delete(struct dentry * dentry)
33 * Adds a dentry to the hash according to its name.
36 -void d_rehash(struct dentry * entry)
37 +void __d_rehash(struct dentry * entry, int lock)
39 struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
40 if (!list_empty(&entry->d_hash)) BUG();
41 - spin_lock(&dcache_lock);
42 + if (lock) spin_lock(&dcache_lock);
43 list_add(&entry->d_hash, list);
44 - spin_unlock(&dcache_lock);
45 + if (lock) spin_unlock(&dcache_lock);
47 +EXPORT_SYMBOL(__d_rehash);
49 +void d_rehash(struct dentry * entry)
51 + __d_rehash(entry, 1);
54 #define do_switch(x,y) do { \
55 --- linux-2.4.20-rh-20.9/fs/exec.c~vfs_intent-2.4.20-rh 2003-09-13 19:34:35.000000000 +0400
56 +++ linux-2.4.20-rh-20.9-alexey/fs/exec.c 2003-09-14 17:34:53.000000000 +0400
57 @@ -114,8 +114,10 @@ asmlinkage long sys_uselib(const char *
61 + struct lookup_intent it = { .it_op = IT_OPEN,
62 + .it_flags = FMODE_READ|FMODE_EXEC };
64 - error = user_path_walk(library, &nd);
65 + error = user_path_walk_it(library, &nd, &it);
69 @@ -127,7 +129,8 @@ asmlinkage long sys_uselib(const char *
73 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
74 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
75 + intent_release(&it);
76 error = PTR_ERR(file);
79 @@ -382,8 +385,10 @@ struct file *open_exec(const char *name)
83 + struct lookup_intent it = { .it_op = IT_OPEN,
84 + .it_flags = FMODE_READ|FMODE_EXEC };
86 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
87 + err = path_lookup_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
90 inode = nd.dentry->d_inode;
91 @@ -395,7 +400,8 @@ struct file *open_exec(const char *name)
95 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
96 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
97 + intent_release(&it);
99 err = deny_write_access(file);
101 @@ -407,6 +413,7 @@ out:
105 + intent_release(&it);
109 @@ -1296,7 +1303,7 @@ int do_coredump(long signr, int exit_cod
111 if (!file->f_op->write)
113 - if (do_truncate(file->f_dentry, 0) != 0)
114 + if (do_truncate(file->f_dentry, 0, 0) != 0)
117 retval = binfmt->core_dump(signr, regs, file);
118 --- linux-2.4.20-rh-20.9/fs/namei.c~vfs_intent-2.4.20-rh 2003-09-13 19:34:25.000000000 +0400
119 +++ linux-2.4.20-rh-20.9-alexey/fs/namei.c 2003-09-14 17:34:53.000000000 +0400
121 * XEmacs seems to be relying on it...
124 +void intent_release(struct lookup_intent *it)
126 + if (it && it->it_op_release)
127 + it->it_op_release(it);
131 /* In order to reduce some races, while at the same time doing additional
132 * checking and hopefully speeding things up, we copy filenames to the
133 * kernel data space before using them..
134 @@ -260,10 +267,19 @@ void path_release(struct nameidata *nd)
135 * Internal lookup() using the new generic dcache.
138 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
139 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
140 + int flags, struct lookup_intent *it)
142 struct dentry * dentry = d_lookup(parent, name);
144 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
145 + if (!dentry->d_op->d_revalidate_it(dentry, flags, it) &&
146 + !d_invalidate(dentry)) {
152 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
153 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
155 @@ -281,11 +297,15 @@ static struct dentry * cached_lookup(str
156 * make sure that nobody added the entry to the dcache in the meantime..
159 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
160 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
161 + int flags, struct lookup_intent *it)
163 struct dentry * result;
164 struct inode *dir = parent->d_inode;
171 * First re-do the cached lookup just in case it was created
172 @@ -300,6 +320,9 @@ static struct dentry * real_lookup(struc
173 result = ERR_PTR(-ENOMEM);
176 + if (dir->i_op->lookup_it)
177 + result = dir->i_op->lookup_it(dir, dentry, it, flags);
179 result = dir->i_op->lookup(dir, dentry);
182 @@ -321,6 +344,15 @@ static struct dentry * real_lookup(struc
184 result = ERR_PTR(-ENOENT);
186 + } else if (result->d_op && result->d_op->d_revalidate_it) {
187 + if (!result->d_op->d_revalidate_it(result, flags, it) &&
188 + !d_invalidate(result)) {
191 + result = ERR_PTR(-ESTALE);
192 + if (!IS_ERR(result))
198 @@ -334,7 +366,8 @@ int max_recursive_link = 5;
199 * Without that kind of total limit, nasty chains of consecutive
200 * symlinks can cause almost arbitrarily long lookups.
202 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
203 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
204 + struct lookup_intent *it)
207 if (current->link_count >= max_recursive_link)
208 @@ -348,10 +381,18 @@ static inline int do_follow_link(struct
209 current->link_count++;
210 current->total_link_count++;
211 UPDATE_ATIME(dentry->d_inode);
213 err = dentry->d_inode->i_op->follow_link(dentry, nd);
214 + if (!err && it != NULL && !(it->d.lustre.it_int_flags & IT_FL_FOLLOWED)) {
215 + /* vfs_follow_link was never called */
216 + intent_release(it);
220 current->link_count--;
223 + intent_release(it);
227 @@ -381,15 +422,26 @@ int follow_up(struct vfsmount **mnt, str
228 return __follow_up(mnt, dentry);
231 -static inline int __follow_down(struct vfsmount **mnt, struct dentry **dentry)
232 +static inline int __follow_down(struct vfsmount **mnt, struct dentry **dentry,
233 + struct lookup_intent *it)
235 struct vfsmount *mounted;
237 spin_lock(&dcache_lock);
238 mounted = lookup_mnt(*mnt, *dentry);
240 + int opc = 0, mode = 0;
241 *mnt = mntget(mounted);
242 spin_unlock(&dcache_lock);
245 + mode = it->it_create_mode;
247 + intent_release(it);
250 + it->it_create_mode = mode;
253 mntput(mounted->mnt_parent);
254 *dentry = dget(mounted->mnt_root);
255 @@ -401,7 +453,7 @@ static inline int __follow_down(struct v
257 int follow_down(struct vfsmount **mnt, struct dentry **dentry)
259 - return __follow_down(mnt,dentry);
260 + return __follow_down(mnt,dentry,NULL);
263 static inline void follow_dotdot(struct nameidata *nd)
264 @@ -437,7 +489,7 @@ static inline void follow_dotdot(struct
268 - while (d_mountpoint(nd->dentry) && __follow_down(&nd->mnt, &nd->dentry))
269 + while (d_mountpoint(nd->dentry) && __follow_down(&nd->mnt, &nd->dentry, NULL))
273 @@ -449,7 +501,8 @@ static inline void follow_dotdot(struct
275 * We expect 'base' to be positive and a directory.
277 -int link_path_walk(const char * name, struct nameidata *nd)
278 +int link_path_walk_it(const char *name, struct nameidata *nd,
279 + struct lookup_intent *it)
281 struct dentry *dentry;
283 @@ -526,19 +579,18 @@ int link_path_walk(const char * name, st
286 /* This does the actual lookups.. */
287 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
288 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
290 err = -EWOULDBLOCKIO;
293 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
294 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
295 err = PTR_ERR(dentry);
299 /* Check mountpoints.. */
300 - while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry))
302 + while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry, NULL));
305 inode = dentry->d_inode;
306 @@ -549,7 +601,7 @@ int link_path_walk(const char * name, st
309 if (inode->i_op->follow_link) {
310 - err = do_follow_link(dentry, nd);
311 + err = do_follow_link(dentry, nd, NULL);
315 @@ -565,7 +617,7 @@ int link_path_walk(const char * name, st
319 - if (!inode->i_op->lookup)
320 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
323 /* here ends the main loop */
324 @@ -592,22 +644,22 @@ last_component:
328 - dentry = cached_lookup(nd->dentry, &this, 0);
329 + dentry = cached_lookup(nd->dentry, &this, 0, it);
331 err = -EWOULDBLOCKIO;
334 - dentry = real_lookup(nd->dentry, &this, 0);
335 + dentry = real_lookup(nd->dentry, &this, 0, it);
336 err = PTR_ERR(dentry);
340 - while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry))
341 + while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry, it))
343 inode = dentry->d_inode;
344 if ((lookup_flags & LOOKUP_FOLLOW)
345 && inode && inode->i_op && inode->i_op->follow_link) {
346 - err = do_follow_link(dentry, nd);
347 + err = do_follow_link(dentry, nd, it);
351 @@ -621,7 +673,8 @@ last_component:
353 if (lookup_flags & LOOKUP_DIRECTORY) {
355 - if (!inode->i_op || !inode->i_op->lookup)
356 + if (!inode->i_op ||
357 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
361 @@ -645,6 +698,25 @@ return_reval:
362 * Check the cached dentry for staleness.
365 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
367 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
368 + struct dentry *new;
369 + err = permission(dentry->d_parent->d_inode,
373 + new = real_lookup(dentry->d_parent,
374 + &dentry->d_name, 0, NULL);
375 + d_invalidate(dentry);
378 + err = PTR_ERR(new);
384 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
386 if (!dentry->d_op->d_revalidate(dentry, 0)) {
387 @@ -658,15 +730,28 @@ out_dput:
392 + intent_release(it);
398 +int link_path_walk(const char * name, struct nameidata *nd)
400 + return link_path_walk_it(name, nd, NULL);
403 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
405 + current->total_link_count = 0;
406 + return link_path_walk_it(name, nd, it);
409 int path_walk(const char * name, struct nameidata *nd)
411 current->total_link_count = 0;
412 - return link_path_walk(name, nd);
413 + return link_path_walk_it(name, nd, NULL);
417 @@ -751,6 +836,17 @@ walk_init_root(const char *name, struct
421 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
422 + struct lookup_intent *it)
425 + if (path_init(path, flags, nd))
426 + error = path_walk_it(path, nd, it);
432 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
435 @@ -765,6 +861,7 @@ int path_init(const char *name, unsigned
437 nd->last_type = LAST_ROOT; /* if there are only slashes... */
441 return walk_init_root(name,nd);
442 read_lock(¤t->fs->lock);
443 @@ -779,7 +876,8 @@ int path_init(const char *name, unsigned
444 * needs parent already locked. Doesn't follow mounts.
447 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
448 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
449 + struct lookup_intent *it)
451 struct dentry * dentry;
453 @@ -802,13 +900,16 @@ struct dentry * lookup_hash(struct qstr
457 - dentry = cached_lookup(base, name, 0);
458 + dentry = cached_lookup(base, name, 0, it);
460 struct dentry *new = d_alloc(base, name);
461 dentry = ERR_PTR(-ENOMEM);
465 + if (inode->i_op->lookup_it)
466 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
468 dentry = inode->i_op->lookup(inode, new);
471 @@ -820,6 +921,12 @@ out:
475 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
477 + return lookup_hash_it(name, base, NULL);
482 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
484 @@ -841,7 +948,7 @@ struct dentry * lookup_one_len(const cha
486 this.hash = end_name_hash(hash);
488 - return lookup_hash(&this, base);
489 + return lookup_hash_it(&this, base, NULL);
491 return ERR_PTR(-EACCES);
493 @@ -872,6 +979,23 @@ int __user_walk(const char *name, unsign
497 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
498 + struct lookup_intent *it)
503 + tmp = getname(name);
504 + err = PTR_ERR(tmp);
505 + if (!IS_ERR(tmp)) {
507 + if (path_init(tmp, flags, nd))
508 + err = path_walk_it(tmp, nd, it);
515 * It's inline, so penalty for filesystems that don't use sticky bit is
517 @@ -969,7 +1093,8 @@ static inline int lookup_flags(unsigned
521 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
522 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
523 + struct lookup_intent *it)
527 @@ -982,12 +1107,15 @@ int vfs_create(struct inode *dir, struct
530 error = -EACCES; /* shouldn't it be ENOSYS? */
531 - if (!dir->i_op || !dir->i_op->create)
532 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
537 - error = dir->i_op->create(dir, dentry, mode);
538 + if (dir->i_op->create_it)
539 + error = dir->i_op->create_it(dir, dentry, mode, it);
541 + error = dir->i_op->create(dir, dentry, mode);
545 @@ -996,6 +1124,11 @@ exit_lock:
549 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
551 + return vfs_create_it(dir, dentry, mode, NULL);
557 @@ -1010,7 +1143,8 @@ exit_lock:
558 * for symlinks (where the permissions are checked later).
561 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
562 +int open_namei_it(const char *pathname, int flag, int mode,
563 + struct nameidata *nd, struct lookup_intent *it)
565 int acc_mode, error = 0;
567 @@ -1020,11 +1154,14 @@ int open_namei(const char * pathname, in
569 acc_mode = ACC_MODE(flag);
572 + it->it_flags = flag;
575 * The simplest case - just a plain lookup.
577 if (!(flag & O_CREAT)) {
578 - error = path_lookup(pathname, lookup_flags(flag), nd);
579 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
583 @@ -1034,6 +1171,10 @@ int open_namei(const char * pathname, in
585 * Create - we need to know the parent.
588 + it->it_create_mode = mode;
589 + it->it_op |= IT_CREAT;
591 error = path_lookup(pathname, LOOKUP_PARENT, nd);
594 @@ -1049,7 +1190,7 @@ int open_namei(const char * pathname, in
597 down(&dir->d_inode->i_sem);
598 - dentry = lookup_hash(&nd->last, nd->dentry);
599 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
602 error = PTR_ERR(dentry);
603 @@ -1058,10 +1199,11 @@ do_last:
607 + it->it_create_mode = mode;
608 /* Negative dentry, just create the file */
609 if (!dentry->d_inode) {
610 - error = vfs_create(dir->d_inode, dentry,
611 - mode & ~current->fs->umask);
612 + error = vfs_create_it(dir->d_inode, dentry,
613 + mode & ~current->fs->umask, it);
614 up(&dir->d_inode->i_sem);
617 @@ -1086,7 +1228,7 @@ do_last:
619 if (flag & O_NOFOLLOW)
621 - while (__follow_down(&nd->mnt,&dentry) && d_mountpoint(dentry));
622 + while (__follow_down(&nd->mnt,&dentry,it) && d_mountpoint(dentry));
625 if (!dentry->d_inode)
626 @@ -1165,7 +1307,7 @@ ok:
630 - error = do_truncate(dentry, 0);
631 + error = do_truncate(dentry, 0, 1);
633 put_write_access(inode);
635 @@ -1177,8 +1319,10 @@ ok:
639 + intent_release(it);
642 + intent_release(it);
646 @@ -1197,7 +1341,16 @@ do_link:
647 * are done. Procfs-like symlinks just set LAST_BIND.
649 UPDATE_ATIME(dentry->d_inode);
651 error = dentry->d_inode->i_op->follow_link(dentry, nd);
653 + intent_release(it);
654 + } else if (it != NULL && !(it->d.lustre.it_int_flags & IT_FL_FOLLOWED)) {
655 + /* vfs_follow_link was never called */
656 + intent_release(it);
663 @@ -1219,13 +1372,20 @@ do_link:
666 down(&dir->d_inode->i_sem);
667 - dentry = lookup_hash(&nd->last, nd->dentry);
668 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
669 putname(nd->last.name);
673 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
675 + return open_namei_it(pathname, flag, mode, nd, NULL);
680 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
681 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
682 + struct lookup_intent *it)
684 struct dentry *dentry;
686 @@ -1233,7 +1393,7 @@ static struct dentry *lookup_create(stru
687 dentry = ERR_PTR(-EEXIST);
688 if (nd->last_type != LAST_NORM)
690 - dentry = lookup_hash(&nd->last, nd->dentry);
691 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
694 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
695 @@ -1289,7 +1449,16 @@ asmlinkage long sys_mknod(const char * f
696 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
699 - dentry = lookup_create(&nd, 0);
701 + if (nd.dentry->d_inode->i_op->mknod_raw) {
702 + struct inode_operations *op = nd.dentry->d_inode->i_op;
703 + error = op->mknod_raw(&nd, mode, dev);
704 + /* the file system wants to use normal vfs path now */
705 + if (error != -EOPNOTSUPP)
709 + dentry = lookup_create(&nd, 0, NULL);
710 error = PTR_ERR(dentry);
712 mode &= ~current->fs->umask;
713 @@ -1310,6 +1479,7 @@ asmlinkage long sys_mknod(const char * f
716 up(&nd.dentry->d_inode->i_sem);
721 @@ -1357,7 +1527,14 @@ asmlinkage long sys_mkdir(const char * p
722 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
725 - dentry = lookup_create(&nd, 1);
726 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
727 + struct inode_operations *op = nd.dentry->d_inode->i_op;
728 + error = op->mkdir_raw(&nd, mode);
729 + /* the file system wants to use normal vfs path now */
730 + if (error != -EOPNOTSUPP)
733 + dentry = lookup_create(&nd, 1, NULL);
734 error = PTR_ERR(dentry);
735 if (!IS_ERR(dentry)) {
736 error = vfs_mkdir(nd.dentry->d_inode, dentry,
737 @@ -1365,6 +1542,7 @@ asmlinkage long sys_mkdir(const char * p
740 up(&nd.dentry->d_inode->i_sem);
745 @@ -1465,8 +1643,16 @@ asmlinkage long sys_rmdir(const char * p
749 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
750 + struct inode_operations *op = nd.dentry->d_inode->i_op;
752 + error = op->rmdir_raw(&nd);
753 + /* the file system wants to use normal vfs path now */
754 + if (error != -EOPNOTSUPP)
757 down(&nd.dentry->d_inode->i_sem);
758 - dentry = lookup_hash(&nd.last, nd.dentry);
759 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
760 error = PTR_ERR(dentry);
761 if (!IS_ERR(dentry)) {
762 error = vfs_rmdir(nd.dentry->d_inode, dentry);
763 @@ -1524,8 +1710,15 @@ asmlinkage long sys_unlink(const char *
765 if (nd.last_type != LAST_NORM)
767 + if (nd.dentry->d_inode->i_op->unlink_raw) {
768 + struct inode_operations *op = nd.dentry->d_inode->i_op;
769 + error = op->unlink_raw(&nd);
770 + /* the file system wants to use normal vfs path now */
771 + if (error != -EOPNOTSUPP)
774 down(&nd.dentry->d_inode->i_sem);
775 - dentry = lookup_hash(&nd.last, nd.dentry);
776 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
777 error = PTR_ERR(dentry);
778 if (!IS_ERR(dentry)) {
779 /* Why not before? Because we want correct error value */
780 @@ -1592,15 +1785,23 @@ asmlinkage long sys_symlink(const char *
781 error = path_lookup(to, LOOKUP_PARENT, &nd);
784 - dentry = lookup_create(&nd, 0);
785 + if (nd.dentry->d_inode->i_op->symlink_raw) {
786 + struct inode_operations *op = nd.dentry->d_inode->i_op;
787 + error = op->symlink_raw(&nd, from);
788 + /* the file system wants to use normal vfs path now */
789 + if (error != -EOPNOTSUPP)
792 + dentry = lookup_create(&nd, 0, NULL);
793 error = PTR_ERR(dentry);
794 if (!IS_ERR(dentry)) {
795 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
798 up(&nd.dentry->d_inode->i_sem);
806 @@ -1676,7 +1877,14 @@ asmlinkage long sys_link(const char * ol
808 if (old_nd.mnt != nd.mnt)
810 - new_dentry = lookup_create(&nd, 0);
811 + if (nd.dentry->d_inode->i_op->link_raw) {
812 + struct inode_operations *op = nd.dentry->d_inode->i_op;
813 + error = op->link_raw(&old_nd, &nd);
814 + /* the file system wants to use normal vfs path now */
815 + if (error != -EOPNOTSUPP)
818 + new_dentry = lookup_create(&nd, 0, NULL);
819 error = PTR_ERR(new_dentry);
820 if (!IS_ERR(new_dentry)) {
821 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
822 @@ -1720,7 +1928,7 @@ exit:
825 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
826 - struct inode *new_dir, struct dentry *new_dentry)
827 + struct inode *new_dir, struct dentry *new_dentry)
830 struct inode *target;
831 @@ -1799,7 +2007,7 @@ out_unlock:
834 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
835 - struct inode *new_dir, struct dentry *new_dentry)
836 + struct inode *new_dir, struct dentry *new_dentry)
840 @@ -1887,9 +2095,18 @@ static inline int do_rename(const char *
841 if (newnd.last_type != LAST_NORM)
844 + if (old_dir->d_inode->i_op->rename_raw) {
846 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
848 + /* the file system wants to use normal vfs path now */
849 + if (error != -EOPNOTSUPP)
853 double_lock(new_dir, old_dir);
855 - old_dentry = lookup_hash(&oldnd.last, old_dir);
856 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
857 error = PTR_ERR(old_dentry);
858 if (IS_ERR(old_dentry))
860 @@ -1905,16 +2122,16 @@ static inline int do_rename(const char *
861 if (newnd.last.name[newnd.last.len])
864 - new_dentry = lookup_hash(&newnd.last, new_dir);
865 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
866 error = PTR_ERR(new_dentry);
867 if (IS_ERR(new_dentry))
872 error = vfs_rename(old_dir->d_inode, old_dentry,
873 new_dir->d_inode, new_dentry);
879 @@ -1965,20 +2182,28 @@ out:
883 -__vfs_follow_link(struct nameidata *nd, const char *link)
884 +__vfs_follow_link(struct nameidata *nd, const char *link,
885 + struct lookup_intent *it)
894 + else if (it != nd->intent)
895 + printk("it != nd->intent: tell phil@clusterfs.com\n");
897 + it->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
901 if (!walk_init_root(link, nd))
902 /* weird __emul_prefix() stuff did it */
905 - res = link_path_walk(link, nd);
906 + res = link_path_walk_it(link, nd, it);
908 if (current->link_count || res || nd->last_type!=LAST_NORM)
910 @@ -2002,7 +2227,13 @@ fail:
912 int vfs_follow_link(struct nameidata *nd, const char *link)
914 - return __vfs_follow_link(nd, link);
915 + return __vfs_follow_link(nd, link, NULL);
918 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
919 + struct lookup_intent *it)
921 + return __vfs_follow_link(nd, link, it);
924 /* get the link contents into pagecache */
925 @@ -2044,7 +2275,7 @@ int page_follow_link(struct dentry *dent
927 struct page *page = NULL;
928 char *s = page_getlink(dentry, &page);
929 - int res = __vfs_follow_link(nd, s);
930 + int res = __vfs_follow_link(nd, s, NULL);
933 page_cache_release(page);
934 --- linux-2.4.20-rh-20.9/fs/namespace.c~vfs_intent-2.4.20-rh 2003-09-13 19:34:35.000000000 +0400
935 +++ linux-2.4.20-rh-20.9-alexey/fs/namespace.c 2003-09-14 17:34:53.000000000 +0400
936 @@ -99,6 +99,7 @@ static void detach_mnt(struct vfsmount *
938 old_nd->dentry = mnt->mnt_mountpoint;
939 old_nd->mnt = mnt->mnt_parent;
940 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
941 mnt->mnt_parent = mnt;
942 mnt->mnt_mountpoint = mnt->mnt_root;
943 list_del_init(&mnt->mnt_child);
944 @@ -110,6 +111,7 @@ static void attach_mnt(struct vfsmount *
946 mnt->mnt_parent = mntget(nd->mnt);
947 mnt->mnt_mountpoint = dget(nd->dentry);
948 + PIN(nd->dentry, nd->mnt, 1);
949 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
950 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
951 nd->dentry->d_mounted++;
952 @@ -485,14 +487,17 @@ static int do_loopback(struct nameidata
954 struct nameidata old_nd;
955 struct vfsmount *mnt = NULL;
956 + struct lookup_intent it = { .it_op = IT_GETATTR };
957 int err = mount_is_safe(nd);
960 if (!old_name || !*old_name)
962 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
964 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
966 + intent_release(&it);
970 down_write(¤t->namespace->sem);
972 @@ -515,6 +520,7 @@ static int do_loopback(struct nameidata
975 up_write(¤t->namespace->sem);
976 + intent_release(&it);
977 path_release(&old_nd);
980 @@ -698,6 +704,7 @@ long do_mount(char * dev_name, char * di
981 unsigned long flags, void *data_page)
984 + struct lookup_intent it = { .it_op = IT_GETATTR };
988 @@ -722,10 +729,11 @@ long do_mount(char * dev_name, char * di
989 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
991 /* ... and get the mountpoint */
992 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
994 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
996 + intent_release(&it);
1000 if (flags & MS_REMOUNT)
1001 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
1003 @@ -736,6 +744,8 @@ long do_mount(char * dev_name, char * di
1005 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
1006 dev_name, data_page);
1008 + intent_release(&it);
1012 @@ -901,6 +911,8 @@ asmlinkage long sys_pivot_root(const cha
1014 struct vfsmount *tmp;
1015 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
1016 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
1017 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
1020 if (!capable(CAP_SYS_ADMIN))
1021 @@ -908,14 +920,14 @@ asmlinkage long sys_pivot_root(const cha
1025 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
1026 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
1030 if (!check_mnt(new_nd.mnt))
1033 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
1034 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
1038 @@ -970,8 +982,10 @@ out2:
1039 up(&old_nd.dentry->d_inode->i_zombie);
1040 up_write(¤t->namespace->sem);
1041 path_release(&user_nd);
1042 + intent_release(&old_it);
1043 path_release(&old_nd);
1045 + intent_release(&new_it);
1046 path_release(&new_nd);
1049 --- linux-2.4.20-rh-20.9/fs/open.c~vfs_intent-2.4.20-rh 2003-09-13 19:34:25.000000000 +0400
1050 +++ linux-2.4.20-rh-20.9-alexey/fs/open.c 2003-09-14 17:34:53.000000000 +0400
1052 #include <asm/uaccess.h>
1054 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1055 +extern int path_walk_it(const char *name, struct nameidata *nd,
1056 + struct lookup_intent *it);
1058 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1060 @@ -95,9 +97,10 @@ void fd_install(unsigned int fd, struct
1061 write_unlock(&files->file_lock);
1064 -int do_truncate(struct dentry *dentry, loff_t length)
1065 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1067 struct inode *inode = dentry->d_inode;
1068 + struct inode_operations *op = dentry->d_inode->i_op;
1070 struct iattr newattrs;
1072 @@ -108,7 +111,13 @@ int do_truncate(struct dentry *dentry, l
1073 down(&inode->i_sem);
1074 newattrs.ia_size = length;
1075 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1076 - error = notify_change(dentry, &newattrs);
1077 + if (called_from_open)
1078 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1079 + if (op->setattr_raw) {
1080 + newattrs.ia_valid |= ATTR_RAW;
1081 + error = op->setattr_raw(inode, &newattrs);
1083 + error = notify_change(dentry, &newattrs);
1087 @@ -118,12 +127,13 @@ static inline long do_sys_truncate(const
1088 struct nameidata nd;
1089 struct inode * inode;
1091 + struct lookup_intent it = { .it_op = IT_GETATTR };
1094 if (length < 0) /* sorry, but loff_t says... */
1097 - error = user_path_walk(path, &nd);
1098 + error = user_path_walk_it(path, &nd, &it);
1101 inode = nd.dentry->d_inode;
1102 @@ -163,11 +173,13 @@ static inline long do_sys_truncate(const
1103 error = locks_verify_truncate(inode, NULL, length);
1106 - error = do_truncate(nd.dentry, length);
1107 + intent_release(&it);
1108 + error = do_truncate(nd.dentry, length, 0);
1110 put_write_access(inode);
1113 + intent_release(&it);
1117 @@ -215,7 +227,7 @@ static inline long do_sys_ftruncate(unsi
1119 error = locks_verify_truncate(inode, file, length);
1121 - error = do_truncate(dentry, length);
1122 + error = do_truncate(dentry, length, 0);
1126 @@ -260,11 +272,13 @@ asmlinkage long sys_utime(char * filenam
1127 struct inode * inode;
1128 struct iattr newattrs;
1130 - error = user_path_walk(filename, &nd);
1131 + error = user_path_walk_it(filename, &nd, NULL);
1134 inode = nd.dentry->d_inode;
1136 + /* this is safe without a Lustre lock because it only depends
1137 + on the super block */
1139 if (IS_RDONLY(inode))
1141 @@ -279,11 +293,25 @@ asmlinkage long sys_utime(char * filenam
1144 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1148 + if (inode->i_op->setattr_raw) {
1149 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1151 + newattrs.ia_valid |= ATTR_RAW;
1152 + error = op->setattr_raw(inode, &newattrs);
1153 + /* the file system wants to use normal vfs path now */
1154 + if (error != -EOPNOTSUPP)
1155 + goto dput_and_out;
1160 if (current->fsuid != inode->i_uid &&
1161 (error = permission(inode,MAY_WRITE)) != 0)
1165 error = notify_change(nd.dentry, &newattrs);
1168 @@ -304,12 +332,14 @@ asmlinkage long sys_utimes(char * filena
1169 struct inode * inode;
1170 struct iattr newattrs;
1172 - error = user_path_walk(filename, &nd);
1173 + error = user_path_walk_it(filename, &nd, NULL);
1177 inode = nd.dentry->d_inode;
1179 + /* this is safe without a Lustre lock because it only depends
1180 + on the super block */
1182 if (IS_RDONLY(inode))
1184 @@ -324,7 +354,20 @@ asmlinkage long sys_utimes(char * filena
1185 newattrs.ia_atime = times[0].tv_sec;
1186 newattrs.ia_mtime = times[1].tv_sec;
1187 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1191 + if (inode->i_op->setattr_raw) {
1192 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1194 + newattrs.ia_valid |= ATTR_RAW;
1195 + error = op->setattr_raw(inode, &newattrs);
1196 + /* the file system wants to use normal vfs path now */
1197 + if (error != -EOPNOTSUPP)
1198 + goto dput_and_out;
1203 if (current->fsuid != inode->i_uid &&
1204 (error = permission(inode,MAY_WRITE)) != 0)
1206 @@ -347,6 +390,7 @@ asmlinkage long sys_access(const char *
1207 int old_fsuid, old_fsgid;
1208 kernel_cap_t old_cap;
1210 + struct lookup_intent it = { .it_op = IT_GETATTR };
1212 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1214 @@ -364,13 +408,14 @@ asmlinkage long sys_access(const char *
1216 current->cap_effective = current->cap_permitted;
1218 - res = user_path_walk(filename, &nd);
1219 + res = user_path_walk_it(filename, &nd, &it);
1221 res = permission(nd.dentry->d_inode, mode);
1222 /* SuS v2 requires we report a read only fs too */
1223 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1224 && !special_file(nd.dentry->d_inode->i_mode))
1226 + intent_release(&it);
1230 @@ -385,8 +430,9 @@ asmlinkage long sys_chdir(const char * f
1233 struct nameidata nd;
1234 + struct lookup_intent it = { .it_op = IT_GETATTR };
1236 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1237 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1241 @@ -397,6 +443,7 @@ asmlinkage long sys_chdir(const char * f
1242 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1245 + intent_release(&it);
1249 @@ -436,9 +483,10 @@ asmlinkage long sys_chroot(const char *
1252 struct nameidata nd;
1253 + struct lookup_intent it = { .it_op = IT_GETATTR };
1255 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1256 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1257 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1258 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1262 @@ -454,39 +502,56 @@ asmlinkage long sys_chroot(const char *
1266 + intent_release(&it);
1272 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1273 +int chmod_common(struct dentry *dentry, mode_t mode)
1275 - struct inode * inode;
1276 - struct dentry * dentry;
1277 - struct file * file;
1279 + struct inode *inode = dentry->d_inode;
1280 struct iattr newattrs;
1285 + if (IS_RDONLY(inode))
1288 - dentry = file->f_dentry;
1289 - inode = dentry->d_inode;
1290 + if (inode->i_op->setattr_raw) {
1291 + newattrs.ia_mode = mode;
1292 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1293 + newattrs.ia_valid |= ATTR_RAW;
1294 + err = inode->i_op->setattr_raw(inode, &newattrs);
1295 + /* the file system wants to use normal vfs path now */
1296 + if (err != -EOPNOTSUPP)
1301 - if (IS_RDONLY(inode))
1304 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1308 if (mode == (mode_t) -1)
1309 mode = inode->i_mode;
1310 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1311 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1312 err = notify_change(dentry, &newattrs);
1319 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1321 + struct file * file;
1328 + err = chmod_common(file->f_dentry, mode);
1333 @@ -495,30 +560,14 @@ out:
1334 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1336 struct nameidata nd;
1337 - struct inode * inode;
1339 - struct iattr newattrs;
1341 error = user_path_walk(filename, &nd);
1344 - inode = nd.dentry->d_inode;
1347 - if (IS_RDONLY(inode))
1348 - goto dput_and_out;
1351 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1352 - goto dput_and_out;
1354 - if (mode == (mode_t) -1)
1355 - mode = inode->i_mode;
1356 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1357 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1358 - error = notify_change(nd.dentry, &newattrs);
1359 + error = chmod_common(nd.dentry, mode);
1365 @@ -538,6 +587,20 @@ static int chown_common(struct dentry *
1367 if (IS_RDONLY(inode))
1370 + if (inode->i_op->setattr_raw) {
1371 + struct inode_operations *op = dentry->d_inode->i_op;
1373 + newattrs.ia_uid = user;
1374 + newattrs.ia_gid = group;
1375 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1376 + newattrs.ia_valid |= ATTR_RAW;
1377 + error = op->setattr_raw(inode, &newattrs);
1378 + /* the file system wants to use normal vfs path now */
1379 + if (error != -EOPNOTSUPP)
1384 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1386 @@ -642,8 +705,9 @@ struct file *filp_open(const char * file
1388 int namei_flags, error;
1389 struct nameidata nd;
1391 - flags &= ~O_DIRECT;
1392 + struct lookup_intent it = { .it_op = IT_OPEN };
1394 + //flags &= ~O_DIRECT;
1396 namei_flags = flags;
1397 if ((namei_flags+1) & O_ACCMODE)
1398 @@ -651,14 +715,15 @@ struct file *filp_open(const char * file
1399 if (namei_flags & O_TRUNC)
1402 - error = open_namei(filename, namei_flags, mode, &nd);
1404 - return dentry_open(nd.dentry, nd.mnt, flags);
1405 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1407 + return ERR_PTR(error);
1409 - return ERR_PTR(error);
1410 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1413 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1414 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1415 + int flags, struct lookup_intent *it)
1418 struct inode *inode;
1419 @@ -695,12 +760,15 @@ struct file *dentry_open(struct dentry *
1422 if (f->f_op && f->f_op->open) {
1424 error = f->f_op->open(inode,f);
1429 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1431 + intent_release(it);
1435 @@ -715,11 +783,17 @@ cleanup_all:
1439 + intent_release(it);
1442 return ERR_PTR(error);
1445 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1447 + return dentry_open_it(dentry, mnt, flags, NULL);
1451 * Find an empty file descriptor entry, and mark it busy.
1453 --- linux-2.4.20-rh-20.9/fs/proc/base.c~vfs_intent-2.4.20-rh 2003-09-13 19:34:35.000000000 +0400
1454 +++ linux-2.4.20-rh-20.9-alexey/fs/proc/base.c 2003-09-14 17:34:53.000000000 +0400
1455 @@ -494,6 +494,9 @@ static int proc_pid_follow_link(struct d
1457 error = inode->u.proc_i.op.proc_get_link(inode, &nd->dentry, &nd->mnt);
1458 nd->last_type = LAST_BIND;
1460 + if (nd->intent != NULL)
1461 + nd->intent->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
1465 --- linux-2.4.20-rh-20.9/fs/stat.c~vfs_intent-2.4.20-rh 2003-09-13 19:34:35.000000000 +0400
1466 +++ linux-2.4.20-rh-20.9-alexey/fs/stat.c 2003-09-14 17:35:10.000000000 +0400
1468 * Revalidate the inode. This is required for proper NFS attribute caching.
1470 static __inline__ int
1471 -do_revalidate(struct dentry *dentry)
1472 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1474 struct inode * inode = dentry->d_inode;
1475 - if (inode->i_op && inode->i_op->revalidate)
1478 + if (inode->i_op && inode->i_op->revalidate_it)
1479 + return inode->i_op->revalidate_it(dentry, it);
1480 + else if (inode->i_op && inode->i_op->revalidate)
1481 return inode->i_op->revalidate(dentry);
1484 @@ -32,13 +36,13 @@ static inline nlink_t user_nlink(struct
1485 return inode->i_nlink;
1488 -static int do_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
1489 +static int do_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat, struct lookup_intent *it)
1492 unsigned int blocks, indirect;
1493 struct inode *inode = dentry->d_inode;
1495 - res = do_revalidate(dentry);
1496 + res = do_revalidate(dentry, it);
1500 @@ -111,10 +115,12 @@ int vfs_stat(char *name, struct kstat *s
1502 struct nameidata nd;
1504 + struct lookup_intent it = { .it_op = IT_GETATTR };
1506 - error = user_path_walk(name, &nd);
1507 + error = user_path_walk_it(name, &nd, &it);
1509 - error = do_getattr(nd.mnt, nd.dentry, stat);
1510 + error = do_getattr(nd.mnt, nd.dentry, stat, &it);
1511 + intent_release(&it);
1515 @@ -124,10 +130,12 @@ int vfs_lstat(char *name, struct kstat *
1517 struct nameidata nd;
1519 + struct lookup_intent it = { .it_op = IT_GETATTR };
1521 - error = user_path_walk_link(name, &nd);
1522 + error = user_path_walk_link_it(name, &nd, &it);
1524 - error = do_getattr(nd.mnt, nd.dentry, stat);
1525 + error = do_getattr(nd.mnt, nd.dentry, stat, &it);
1526 + intent_release(&it);
1530 @@ -139,7 +147,7 @@ int vfs_fstat(unsigned int fd, struct ks
1534 - error = do_getattr(f->f_vfsmnt, f->f_dentry, stat);
1535 + error = do_getattr(f->f_vfsmnt, f->f_dentry, stat, NULL);
1539 @@ -286,7 +294,7 @@ asmlinkage long sys_readlink(const char
1542 if (inode->i_op && inode->i_op->readlink &&
1543 - !(error = do_revalidate(nd.dentry))) {
1544 + !(error = do_revalidate(nd.dentry, NULL))) {
1545 UPDATE_ATIME(inode);
1546 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1548 --- linux-2.4.20-rh-20.9/include/linux/dcache.h~vfs_intent-2.4.20-rh 2003-09-13 19:34:28.000000000 +0400
1549 +++ linux-2.4.20-rh-20.9-alexey/include/linux/dcache.h 2003-09-14 17:34:53.000000000 +0400
1551 #include <asm/atomic.h>
1552 #include <linux/mount.h>
1553 #include <linux/kernel.h>
1554 +#include <linux/string.h>
1556 +#define IT_OPEN 0x0001
1557 +#define IT_CREAT 0x0002
1558 +#define IT_READDIR 0x0004
1559 +#define IT_GETATTR 0x0008
1560 +#define IT_LOOKUP 0x0010
1561 +#define IT_UNLINK 0x0020
1562 +#define IT_GETXATTR 0x0040
1563 +#define IT_EXEC 0x0080
1564 +#define IT_PIN 0x0100
1566 +#define IT_FL_LOCKED 0x0001
1567 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1569 +#define INTENT_MAGIC 0x19620323
1572 +struct lustre_intent_data {
1573 + int it_disposition;
1575 + __u64 it_lock_handle;
1580 +struct lookup_intent {
1582 + void (*it_op_release)(struct lookup_intent *);
1585 + int it_create_mode;
1587 + struct lustre_intent_data lustre;
1591 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1593 + memset(it, 0, sizeof(*it));
1594 + it->it_magic = INTENT_MAGIC;
1596 + it->it_flags = flags;
1601 * linux/include/linux/dcache.h
1602 @@ -96,8 +141,22 @@ struct dentry_operations {
1603 int (*d_delete)(struct dentry *);
1604 void (*d_release)(struct dentry *);
1605 void (*d_iput)(struct dentry *, struct inode *);
1606 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1607 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1608 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1611 +#define PIN(de,mnt,flag) if (de->d_op && de->d_op->d_pin) \
1612 + de->d_op->d_pin(de, mnt, flag);
1613 +#define UNPIN(de,mnt,flag) if (de->d_op && de->d_op->d_unpin) \
1614 + de->d_op->d_unpin(de, mnt, flag);
1617 +/* defined in fs/namei.c */
1618 +extern void intent_release(struct lookup_intent *it);
1619 +/* defined in fs/dcache.c */
1620 +extern void __d_rehash(struct dentry * entry, int lock);
1622 /* the dentry parameter passed to d_hash and d_compare is the parent
1623 * directory of the entries to be compared. It is used in case these
1624 * functions need any directory specific information for determining
1625 @@ -129,6 +188,7 @@ d_iput: no no yes
1626 * s_nfsd_free_path semaphore will be down
1628 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1629 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1631 extern spinlock_t dcache_lock;
1633 --- linux-2.4.20-rh-20.9/include/linux/fs.h~vfs_intent-2.4.20-rh 2003-09-14 17:34:50.000000000 +0400
1634 +++ linux-2.4.20-rh-20.9-alexey/include/linux/fs.h 2003-09-14 17:34:53.000000000 +0400
1635 @@ -73,6 +73,7 @@ extern int leases_enable, dir_notify_ena
1637 #define FMODE_READ 1
1638 #define FMODE_WRITE 2
1639 +#define FMODE_EXEC 4
1643 @@ -338,6 +339,9 @@ extern void set_bh_page(struct buffer_he
1644 #define ATTR_MTIME_SET 256
1645 #define ATTR_FORCE 512 /* Not a change, but a change it */
1646 #define ATTR_ATTR_FLAG 1024
1647 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1648 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1649 +#define ATTR_CTIME_SET 0x2000
1652 * This is the Inode Attributes structure, used for notify_change(). It
1653 @@ -473,6 +477,7 @@ struct inode {
1654 struct pipe_inode_info *i_pipe;
1655 struct block_device *i_bdev;
1656 struct char_device *i_cdev;
1657 + void *i_filterdata;
1659 unsigned long i_dnotify_mask; /* Directory notify events */
1660 struct dnotify_struct *i_dnotify; /* for directory notifications */
1661 @@ -575,6 +580,7 @@ struct file {
1663 /* needed for tty driver, and maybe others */
1665 + struct lookup_intent *f_it;
1667 /* preallocated helper kiobuf to speedup O_DIRECT */
1668 struct kiobuf *f_iobuf;
1669 @@ -702,6 +708,7 @@ struct nameidata {
1673 + struct lookup_intent *intent;
1677 @@ -822,7 +829,8 @@ extern int vfs_symlink(struct inode *, s
1678 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1679 extern int vfs_rmdir(struct inode *, struct dentry *);
1680 extern int vfs_unlink(struct inode *, struct dentry *);
1681 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1682 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1683 + struct inode *new_dir, struct dentry *new_dentry);
1687 @@ -882,21 +890,32 @@ struct file_operations {
1689 struct inode_operations {
1690 int (*create) (struct inode *,struct dentry *,int);
1691 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1692 struct dentry * (*lookup) (struct inode *,struct dentry *);
1693 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1694 int (*link) (struct dentry *,struct inode *,struct dentry *);
1695 + int (*link_raw) (struct nameidata *,struct nameidata *);
1696 int (*unlink) (struct inode *,struct dentry *);
1697 + int (*unlink_raw) (struct nameidata *);
1698 int (*symlink) (struct inode *,struct dentry *,const char *);
1699 + int (*symlink_raw) (struct nameidata *,const char *);
1700 int (*mkdir) (struct inode *,struct dentry *,int);
1701 + int (*mkdir_raw) (struct nameidata *,int);
1702 int (*rmdir) (struct inode *,struct dentry *);
1703 + int (*rmdir_raw) (struct nameidata *);
1704 int (*mknod) (struct inode *,struct dentry *,int,int);
1705 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1706 int (*rename) (struct inode *, struct dentry *,
1707 struct inode *, struct dentry *);
1708 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1709 int (*readlink) (struct dentry *, char *,int);
1710 int (*follow_link) (struct dentry *, struct nameidata *);
1711 void (*truncate) (struct inode *);
1712 int (*permission) (struct inode *, int);
1713 int (*revalidate) (struct dentry *);
1714 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1715 int (*setattr) (struct dentry *, struct iattr *);
1716 + int (*setattr_raw) (struct inode *, struct iattr *);
1717 int (*getattr) (struct dentry *, struct iattr *);
1718 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
1719 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1720 @@ -1092,10 +1111,14 @@ static inline int get_lease(struct inode
1722 asmlinkage long sys_open(const char *, int, int);
1723 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1724 -extern int do_truncate(struct dentry *, loff_t start);
1725 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1727 extern struct file *filp_open(const char *, int, int);
1728 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1729 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1730 + struct nameidata *nd, struct lookup_intent *it);
1731 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1732 + int flags, struct lookup_intent *it);
1733 extern int filp_close(struct file *, fl_owner_t id);
1734 extern char * getname(const char *);
1736 @@ -1386,6 +1409,7 @@ typedef int (*read_actor_t)(read_descrip
1737 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1739 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1740 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1741 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1742 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1743 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1744 @@ -1397,6 +1421,8 @@ extern struct dentry * lookup_one_len(co
1745 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1746 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1747 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1748 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1749 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1751 extern void inode_init_once(struct inode *);
1752 extern void iput(struct inode *);
1753 @@ -1504,6 +1530,8 @@ extern struct file_operations generic_ro
1755 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1756 extern int vfs_follow_link(struct nameidata *, const char *);
1757 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1758 + struct lookup_intent *it);
1759 extern int page_readlink(struct dentry *, char *, int);
1760 extern int page_follow_link(struct dentry *, struct nameidata *);
1761 extern struct inode_operations page_symlink_inode_operations;
1762 --- linux-2.4.20-rh-20.9/include/linux/fs_struct.h~vfs_intent-2.4.20-rh 2003-09-13 19:34:19.000000000 +0400
1763 +++ linux-2.4.20-rh-20.9-alexey/include/linux/fs_struct.h 2003-09-14 17:34:53.000000000 +0400
1764 @@ -37,10 +37,12 @@ static inline void set_fs_root(struct fs
1765 write_lock(&fs->lock);
1766 old_root = fs->root;
1767 old_rootmnt = fs->rootmnt;
1768 + PIN(dentry, mnt, 1);
1769 fs->rootmnt = mntget(mnt);
1770 fs->root = dget(dentry);
1771 write_unlock(&fs->lock);
1773 + UNPIN(old_root, old_rootmnt, 1);
1775 mntput(old_rootmnt);
1777 @@ -60,10 +62,12 @@ static inline void set_fs_pwd(struct fs_
1778 write_lock(&fs->lock);
1780 old_pwdmnt = fs->pwdmnt;
1781 + PIN(dentry, mnt, 0);
1782 fs->pwdmnt = mntget(mnt);
1783 fs->pwd = dget(dentry);
1784 write_unlock(&fs->lock);
1786 + UNPIN(old_pwd, old_pwdmnt, 0);
1790 --- linux-2.4.20-rh-20.9/kernel/ksyms.c~vfs_intent-2.4.20-rh 2003-09-14 17:34:51.000000000 +0400
1791 +++ linux-2.4.20-rh-20.9-alexey/kernel/ksyms.c 2003-09-14 17:34:53.000000000 +0400
1792 @@ -298,6 +298,7 @@ EXPORT_SYMBOL(read_cache_page);
1793 EXPORT_SYMBOL(set_page_dirty);
1794 EXPORT_SYMBOL(vfs_readlink);
1795 EXPORT_SYMBOL(vfs_follow_link);
1796 +EXPORT_SYMBOL(vfs_follow_link_it);
1797 EXPORT_SYMBOL(page_readlink);
1798 EXPORT_SYMBOL(page_follow_link);
1799 EXPORT_SYMBOL(page_symlink_inode_operations);
1800 --- linux-2.4.20-rh-20.9/kernel/fork.c~vfs_intent-2.4.20-rh 2003-09-13 19:34:35.000000000 +0400
1801 +++ linux-2.4.20-rh-20.9-alexey/kernel/fork.c 2003-09-14 17:34:53.000000000 +0400
1802 @@ -440,10 +440,13 @@ static inline struct fs_struct *__copy_f
1803 fs->umask = old->umask;
1804 read_lock(&old->lock);
1805 fs->rootmnt = mntget(old->rootmnt);
1806 + PIN(old->pwd, old->pwdmnt, 0);
1807 + PIN(old->root, old->rootmnt, 1);
1808 fs->root = dget(old->root);
1809 fs->pwdmnt = mntget(old->pwdmnt);
1810 fs->pwd = dget(old->pwd);
1812 + PIN(old->altroot, old->altrootmnt, 1);
1813 fs->altrootmnt = mntget(old->altrootmnt);
1814 fs->altroot = dget(old->altroot);
1816 --- linux-2.4.20-rh-20.9/kernel/exit.c~vfs_intent-2.4.20-rh 2003-09-13 19:34:35.000000000 +0400
1817 +++ linux-2.4.20-rh-20.9-alexey/kernel/exit.c 2003-09-14 17:34:53.000000000 +0400
1818 @@ -345,11 +345,14 @@ static inline void __put_fs_struct(struc
1820 /* No need to hold fs->lock if we are killing it */
1821 if (atomic_dec_and_test(&fs->count)) {
1822 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1823 + UNPIN(fs->root, fs->rootmnt, 1);
1825 mntput(fs->rootmnt);
1829 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1831 mntput(fs->altrootmnt);