2 fs/namei.c | 288 ++++++++++++++++++++++++++++++++++++++++---------
4 fs/open.c | 53 +++++++--
6 include/linux/dcache.h | 25 ++++
7 include/linux/fs.h | 22 +++
9 8 files changed, 345 insertions(+), 63 deletions(-)
11 --- linux-2.4.18-49chaos-lustre9/fs/dcache.c~vfs_intent-2.4.18-18 Wed Jan 29 12:43:32 2003
12 +++ linux-2.4.18-49chaos-lustre9-root/fs/dcache.c Wed Jan 29 12:43:32 2003
13 @@ -186,6 +186,13 @@ int d_invalidate(struct dentry * dentry)
14 spin_unlock(&dcache_lock);
18 + /* network invalidation by Lustre */
19 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
20 + spin_unlock(&dcache_lock);
25 * Check whether to do a partial shrink_dcache
26 * to get rid of unused child entries.
27 @@ -645,6 +652,7 @@ struct dentry * d_alloc(struct dentry *
28 dentry->d_fsdata = NULL;
29 dentry->d_extra_attributes = NULL;
30 dentry->d_mounted = 0;
31 + dentry->d_it = NULL;
32 INIT_LIST_HEAD(&dentry->d_hash);
33 INIT_LIST_HEAD(&dentry->d_lru);
34 INIT_LIST_HEAD(&dentry->d_subdirs);
35 --- linux-2.4.18-49chaos-lustre9/fs/namei.c~vfs_intent-2.4.18-18 Wed Jan 29 12:43:32 2003
36 +++ linux-2.4.18-49chaos-lustre9-root/fs/namei.c Wed Feb 5 16:23:06 2003
38 * XEmacs seems to be relying on it...
41 +void intent_release(struct dentry *de, struct lookup_intent *it)
43 + if (it && de->d_op && de->d_op->d_intent_release)
44 + de->d_op->d_intent_release(de, it);
48 /* In order to reduce some races, while at the same time doing additional
49 * checking and hopefully speeding things up, we copy filenames to the
50 * kernel data space before using them..
51 @@ -260,10 +267,19 @@ void path_release(struct nameidata *nd)
52 * Internal lookup() using the new generic dcache.
55 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
56 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
57 + int flags, struct lookup_intent *it)
59 struct dentry * dentry = d_lookup(parent, name);
61 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate2) {
62 + if (!dentry->d_op->d_revalidate2(dentry, flags, it) &&
63 + !d_invalidate(dentry)) {
69 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
70 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
72 @@ -281,11 +297,14 @@ static struct dentry * cached_lookup(str
73 * make sure that nobody added the entry to the dcache in the meantime..
76 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
77 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
78 + int flags, struct lookup_intent *it)
80 struct dentry * result;
81 struct inode *dir = parent->d_inode;
87 * First re-do the cached lookup just in case it was created
88 @@ -300,6 +319,9 @@ static struct dentry * real_lookup(struc
89 result = ERR_PTR(-ENOMEM);
92 + if (dir->i_op->lookup2)
93 + result = dir->i_op->lookup2(dir, dentry, it);
95 result = dir->i_op->lookup(dir, dentry);
98 @@ -321,6 +343,12 @@ static struct dentry * real_lookup(struc
100 result = ERR_PTR(-ENOENT);
102 + } else if (result->d_op && result->d_op->d_revalidate2) {
103 + if (!result->d_op->d_revalidate2(result, flags, it) &&
104 + !d_invalidate(result)) {
111 @@ -334,7 +362,8 @@ int max_recursive_link = 5;
112 * Without that kind of total limit, nasty chains of consecutive
113 * symlinks can cause almost arbitrarily long lookups.
115 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
116 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
117 + struct lookup_intent *it)
120 if (current->link_count >= max_recursive_link)
121 @@ -348,10 +377,14 @@ static inline int do_follow_link(struct
122 current->link_count++;
123 current->total_link_count++;
124 UPDATE_ATIME(dentry->d_inode);
125 - err = dentry->d_inode->i_op->follow_link(dentry, nd);
126 + if (dentry->d_inode->i_op->follow_link2)
127 + err = dentry->d_inode->i_op->follow_link2(dentry, nd, it);
129 + err = dentry->d_inode->i_op->follow_link(dentry, nd);
130 current->link_count--;
133 + intent_release(dentry, it);
137 @@ -449,7 +482,8 @@ static inline void follow_dotdot(struct
139 * We expect 'base' to be positive and a directory.
141 -int link_path_walk(const char * name, struct nameidata *nd)
142 +int link_path_walk_it(const char *name, struct nameidata *nd,
143 + struct lookup_intent *it)
145 struct dentry *dentry;
147 @@ -526,12 +560,12 @@ int link_path_walk(const char * name, st
150 /* This does the actual lookups.. */
151 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
152 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
154 err = -EWOULDBLOCKIO;
157 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
158 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
159 err = PTR_ERR(dentry);
162 @@ -548,8 +582,8 @@ int link_path_walk(const char * name, st
166 - if (inode->i_op->follow_link) {
167 - err = do_follow_link(dentry, nd);
168 + if (inode->i_op->follow_link || inode->i_op->follow_link2) {
169 + err = do_follow_link(dentry, nd, NULL);
173 @@ -565,7 +599,7 @@ int link_path_walk(const char * name, st
177 - if (!inode->i_op->lookup)
178 + if (!inode->i_op->lookup && !inode->i_op->lookup2)
181 /* here ends the main loop */
182 @@ -592,12 +626,12 @@ last_component:
186 - dentry = cached_lookup(nd->dentry, &this, 0);
187 + dentry = cached_lookup(nd->dentry, &this, 0, it);
189 err = -EWOULDBLOCKIO;
192 - dentry = real_lookup(nd->dentry, &this, 0);
193 + dentry = real_lookup(nd->dentry, &this, 0, it);
194 err = PTR_ERR(dentry);
197 @@ -606,8 +640,9 @@ last_component:
199 inode = dentry->d_inode;
200 if ((lookup_flags & LOOKUP_FOLLOW)
201 - && inode && inode->i_op && inode->i_op->follow_link) {
202 - err = do_follow_link(dentry, nd);
203 + && inode && inode->i_op &&
204 + (inode->i_op->follow_link || inode->i_op->follow_link2)) {
205 + err = do_follow_link(dentry, nd, it);
209 @@ -621,7 +656,8 @@ last_component:
211 if (lookup_flags & LOOKUP_DIRECTORY) {
213 - if (!inode->i_op || !inode->i_op->lookup)
214 + if (!inode->i_op ||
215 + (!inode->i_op->lookup && !inode->i_op->lookup2))
219 @@ -658,15 +694,28 @@ out_dput:
224 + intent_release(nd->dentry, it);
230 +int link_path_walk(const char * name, struct nameidata *nd)
232 + return link_path_walk_it(name, nd, NULL);
235 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
237 + current->total_link_count = 0;
238 + return link_path_walk_it(name, nd, it);
241 int path_walk(const char * name, struct nameidata *nd)
243 current->total_link_count = 0;
244 - return link_path_walk(name, nd);
245 + return link_path_walk_it(name, nd, NULL);
249 @@ -751,6 +800,17 @@ walk_init_root(const char *name, struct
253 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
254 + struct lookup_intent *it)
257 + if (path_init(path, flags, nd))
258 + error = path_walk_it(path, nd, it);
264 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
267 @@ -779,7 +839,8 @@ int path_init(const char *name, unsigned
268 * needs parent already locked. Doesn't follow mounts.
271 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
272 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
273 + struct lookup_intent *it)
275 struct dentry * dentry;
277 @@ -802,13 +863,16 @@ struct dentry * lookup_hash(struct qstr
281 - dentry = cached_lookup(base, name, 0);
282 + dentry = cached_lookup(base, name, 0, it);
284 struct dentry *new = d_alloc(base, name);
285 dentry = ERR_PTR(-ENOMEM);
289 + if (inode->i_op->lookup2)
290 + dentry = inode->i_op->lookup2(inode, new, it);
292 dentry = inode->i_op->lookup(inode, new);
295 @@ -820,6 +884,12 @@ out:
299 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
301 + return lookup_hash_it(name, base, NULL);
306 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
308 @@ -841,7 +911,7 @@ struct dentry * lookup_one_len(const cha
310 this.hash = end_name_hash(hash);
312 - return lookup_hash(&this, base);
313 + return lookup_hash_it(&this, base, NULL);
315 return ERR_PTR(-EACCES);
317 @@ -872,6 +942,23 @@ int __user_walk(const char *name, unsign
321 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
322 + struct lookup_intent *it)
327 + tmp = getname(name);
328 + err = PTR_ERR(tmp);
329 + if (!IS_ERR(tmp)) {
331 + if (path_init(tmp, flags, nd))
332 + err = path_walk_it(tmp, nd, it);
339 * It's inline, so penalty for filesystems that don't use sticky bit is
341 @@ -1045,14 +1132,17 @@ int may_open(struct nameidata *nd, int a
342 return get_lease(inode, flag);
345 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
346 + int flags, struct lookup_intent *it);
348 struct file *filp_open(const char * pathname, int open_flags, int mode)
350 int acc_mode, error = 0;
351 - struct inode *inode;
352 struct dentry *dentry;
354 int flag = open_flags;
356 + struct lookup_intent it = { .it_op = IT_OPEN, .it_flags = open_flags };
359 if ((flag+1) & O_ACCMODE)
360 @@ -1066,7 +1156,7 @@ struct file *filp_open(const char * path
361 * The simplest case - just a plain lookup.
363 if (!(flag & O_CREAT)) {
364 - error = path_lookup(pathname, lookup_flags(flag), &nd);
365 + error = path_lookup_it(pathname, lookup_flags(flag), &nd, &it);
367 return ERR_PTR(error);
369 @@ -1076,6 +1166,8 @@ struct file *filp_open(const char * path
371 * Create - we need to know the parent.
374 + it.it_op |= IT_CREAT;
375 error = path_lookup(pathname, LOOKUP_PARENT, &nd);
377 return ERR_PTR(error);
378 @@ -1091,7 +1183,7 @@ struct file *filp_open(const char * path
381 down(&dir->d_inode->i_sem);
382 - dentry = lookup_hash(&nd.last, nd.dentry);
383 + dentry = lookup_hash_it(&nd.last, nd.dentry, &it);
386 error = PTR_ERR(dentry);
387 @@ -1100,6 +1192,7 @@ do_last:
392 /* Negative dentry, just create the file */
393 if (!dentry->d_inode) {
394 error = vfs_create(dir->d_inode, dentry,
395 @@ -1134,7 +1227,8 @@ do_last:
397 if (!dentry->d_inode)
399 - if (dentry->d_inode->i_op && dentry->d_inode->i_op->follow_link)
400 + if (dentry->d_inode->i_op && (dentry->d_inode->i_op->follow_link ||
401 + dentry->d_inode->i_op->follow_link2))
405 @@ -1149,11 +1243,13 @@ ok:
406 if (!S_ISREG(nd.dentry->d_inode->i_mode))
407 open_flags &= ~O_TRUNC;
409 - return dentry_open(nd.dentry, nd.mnt, open_flags);
410 + return dentry_open_it(nd.dentry, nd.mnt, open_flags, &it);
413 + intent_release(dentry, &it);
416 + intent_release(nd.dentry, &it);
418 return ERR_PTR(error);
420 @@ -1172,7 +1268,12 @@ do_link:
421 * are done. Procfs-like symlinks just set LAST_BIND.
423 UPDATE_ATIME(dentry->d_inode);
424 - error = dentry->d_inode->i_op->follow_link(dentry, &nd);
425 + if (dentry->d_inode->i_op->follow_link2)
426 + error = dentry->d_inode->i_op->follow_link2(dentry, &nd, &it);
428 + error = dentry->d_inode->i_op->follow_link(dentry, &nd);
430 + intent_release(dentry, &it);
434 @@ -1194,13 +1295,15 @@ do_link:
437 down(&dir->d_inode->i_sem);
438 - dentry = lookup_hash(&nd.last, nd.dentry);
439 + dentry = lookup_hash_it(&nd.last, nd.dentry, &it);
440 putname(nd.last.name);
446 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
447 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
448 + struct lookup_intent *it)
450 struct dentry *dentry;
452 @@ -1208,7 +1311,7 @@ static struct dentry *lookup_create(stru
453 dentry = ERR_PTR(-EEXIST);
454 if (nd->last_type != LAST_NORM)
456 - dentry = lookup_hash(&nd->last, nd->dentry);
457 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
460 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
461 @@ -1264,7 +1367,19 @@ asmlinkage long sys_mknod(const char * f
462 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
465 - dentry = lookup_create(&nd, 0);
467 + if (nd.dentry->d_inode->i_op->mknod2) {
468 + struct inode_operations *op = nd.dentry->d_inode->i_op;
469 + error = op->mknod2(nd.dentry->d_inode,
473 + /* the file system want to use normal vfs path now */
474 + if (error != -EOPNOTSUPP)
478 + dentry = lookup_create(&nd, 0, NULL);
479 error = PTR_ERR(dentry);
481 mode &= ~current->fs->umask;
482 @@ -1285,6 +1400,7 @@ asmlinkage long sys_mknod(const char * f
485 up(&nd.dentry->d_inode->i_sem);
490 @@ -1332,7 +1448,17 @@ asmlinkage long sys_mkdir(const char * p
491 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
494 - dentry = lookup_create(&nd, 1);
495 + if (nd.dentry->d_inode->i_op->mkdir2) {
496 + struct inode_operations *op = nd.dentry->d_inode->i_op;
497 + error = op->mkdir2(nd.dentry->d_inode,
501 + /* the file system want to use normal vfs path now */
502 + if (error != -EOPNOTSUPP)
505 + dentry = lookup_create(&nd, 1, NULL);
506 error = PTR_ERR(dentry);
507 if (!IS_ERR(dentry)) {
508 error = vfs_mkdir(nd.dentry->d_inode, dentry,
509 @@ -1340,6 +1466,7 @@ asmlinkage long sys_mkdir(const char * p
512 up(&nd.dentry->d_inode->i_sem);
517 @@ -1440,8 +1567,17 @@ asmlinkage long sys_rmdir(const char * p
521 + if (nd.dentry->d_inode->i_op->rmdir2) {
522 + struct inode_operations *op = nd.dentry->d_inode->i_op;
523 + error = op->rmdir2(nd.dentry->d_inode,
526 + /* the file system want to use normal vfs path now */
527 + if (error != -EOPNOTSUPP)
530 down(&nd.dentry->d_inode->i_sem);
531 - dentry = lookup_hash(&nd.last, nd.dentry);
532 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
533 error = PTR_ERR(dentry);
534 if (!IS_ERR(dentry)) {
535 error = vfs_rmdir(nd.dentry->d_inode, dentry);
536 @@ -1499,8 +1635,17 @@ asmlinkage long sys_unlink(const char *
538 if (nd.last_type != LAST_NORM)
540 + if (nd.dentry->d_inode->i_op->unlink2) {
541 + struct inode_operations *op = nd.dentry->d_inode->i_op;
542 + error = op->unlink2(nd.dentry->d_inode,
545 + /* the file system want to use normal vfs path now */
546 + if (error != -EOPNOTSUPP)
549 down(&nd.dentry->d_inode->i_sem);
550 - dentry = lookup_hash(&nd.last, nd.dentry);
551 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
552 error = PTR_ERR(dentry);
553 if (!IS_ERR(dentry)) {
554 /* Why not before? Because we want correct error value */
555 @@ -1567,15 +1712,26 @@ asmlinkage long sys_symlink(const char *
556 error = path_lookup(to, LOOKUP_PARENT, &nd);
559 - dentry = lookup_create(&nd, 0);
560 + if (nd.dentry->d_inode->i_op->symlink2) {
561 + struct inode_operations *op = nd.dentry->d_inode->i_op;
562 + error = op->symlink2(nd.dentry->d_inode,
566 + /* the file system want to use normal vfs path now */
567 + if (error != -EOPNOTSUPP)
570 + dentry = lookup_create(&nd, 0, NULL);
571 error = PTR_ERR(dentry);
572 if (!IS_ERR(dentry)) {
573 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
576 up(&nd.dentry->d_inode->i_sem);
584 @@ -1642,7 +1798,7 @@ asmlinkage long sys_link(const char * ol
585 struct dentry *new_dentry;
586 struct nameidata nd, old_nd;
588 - error = __user_walk(oldname, LOOKUP_POSITIVE, &old_nd);
589 + error = __user_walk_it(oldname, LOOKUP_POSITIVE, &old_nd, NULL);
592 error = path_lookup(to, LOOKUP_PARENT, &nd);
593 @@ -1651,7 +1807,17 @@ asmlinkage long sys_link(const char * ol
595 if (old_nd.mnt != nd.mnt)
597 - new_dentry = lookup_create(&nd, 0);
598 + if (nd.dentry->d_inode->i_op->link2) {
599 + struct inode_operations *op = nd.dentry->d_inode->i_op;
600 + error = op->link2(old_nd.dentry->d_inode,
601 + nd.dentry->d_inode,
604 + /* the file system want to use normal vfs path now */
605 + if (error != -EOPNOTSUPP)
608 + new_dentry = lookup_create(&nd, 0, NULL);
609 error = PTR_ERR(new_dentry);
610 if (!IS_ERR(new_dentry)) {
611 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
612 @@ -1695,7 +1861,8 @@ exit:
615 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
616 - struct inode *new_dir, struct dentry *new_dentry)
617 + struct inode *new_dir, struct dentry *new_dentry,
618 + struct lookup_intent *it)
621 struct inode *target;
622 @@ -1753,6 +1920,7 @@ int vfs_rename_dir(struct inode *old_dir
625 error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
626 + intent_release(new_dentry, it);
629 target->i_flags |= S_DEAD;
630 @@ -1774,7 +1942,8 @@ out_unlock:
633 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
634 - struct inode *new_dir, struct dentry *new_dentry)
635 + struct inode *new_dir, struct dentry *new_dentry,
636 + struct lookup_intent *it)
640 @@ -1805,6 +1974,7 @@ int vfs_rename_other(struct inode *old_d
643 error = old_dir->i_op->rename(old_dir, old_dentry, new_dir, new_dentry);
644 + intent_release(new_dentry, it);
645 double_up(&old_dir->i_zombie, &new_dir->i_zombie);
648 @@ -1816,13 +1986,14 @@ int vfs_rename_other(struct inode *old_d
651 int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
652 - struct inode *new_dir, struct dentry *new_dentry)
653 + struct inode *new_dir, struct dentry *new_dentry,
654 + struct lookup_intent *it)
657 if (S_ISDIR(old_dentry->d_inode->i_mode))
658 - error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry);
659 + error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry,it);
661 - error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry);
662 + error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry,it);
664 if (old_dir == new_dir)
665 inode_dir_notify(old_dir, DN_RENAME);
666 @@ -1862,9 +2033,23 @@ static inline int do_rename(const char *
667 if (newnd.last_type != LAST_NORM)
670 + if (old_dir->d_inode->i_op->rename2) {
672 + error = old_dir->d_inode->i_op->rename2(old_dir->d_inode,
679 + /* the file system want to use normal vfs path now */
680 + if (error != -EOPNOTSUPP)
684 double_lock(new_dir, old_dir);
686 - old_dentry = lookup_hash(&oldnd.last, old_dir);
687 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
688 error = PTR_ERR(old_dentry);
689 if (IS_ERR(old_dentry))
691 @@ -1880,14 +2065,14 @@ static inline int do_rename(const char *
692 if (newnd.last.name[newnd.last.len])
695 - new_dentry = lookup_hash(&newnd.last, new_dir);
696 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
697 error = PTR_ERR(new_dentry);
698 if (IS_ERR(new_dentry))
702 error = vfs_rename(old_dir->d_inode, old_dentry,
703 - new_dir->d_inode, new_dentry);
704 + new_dir->d_inode, new_dentry, NULL);
708 @@ -1940,7 +2125,8 @@ out:
712 -__vfs_follow_link(struct nameidata *nd, const char *link)
713 +__vfs_follow_link(struct nameidata *nd, const char *link,
714 + struct lookup_intent *it)
718 @@ -1953,7 +2139,7 @@ __vfs_follow_link(struct nameidata *nd,
719 /* weird __emul_prefix() stuff did it */
722 - res = link_path_walk(link, nd);
723 + res = link_path_walk_it(link, nd, it);
725 if (current->link_count || res || nd->last_type!=LAST_NORM)
727 @@ -1975,7 +2161,13 @@ fail:
729 int vfs_follow_link(struct nameidata *nd, const char *link)
731 - return __vfs_follow_link(nd, link);
732 + return __vfs_follow_link(nd, link, NULL);
735 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
736 + struct lookup_intent *it)
738 + return __vfs_follow_link(nd, link, it);
741 /* get the link contents into pagecache */
742 @@ -2017,7 +2209,7 @@ int page_follow_link(struct dentry *dent
744 struct page *page = NULL;
745 char *s = page_getlink(dentry, &page);
746 - int res = __vfs_follow_link(nd, s);
747 + int res = __vfs_follow_link(nd, s, NULL);
750 page_cache_release(page);
751 --- linux-2.4.18-49chaos-lustre9/fs/nfsd/vfs.c~vfs_intent-2.4.18-18 Wed Jan 29 12:43:32 2003
752 +++ linux-2.4.18-49chaos-lustre9-root/fs/nfsd/vfs.c Wed Jan 29 12:43:32 2003
753 @@ -1298,7 +1298,7 @@ nfsd_rename(struct svc_rqst *rqstp, stru
757 - err = vfs_rename(fdir, odentry, tdir, ndentry);
758 + err = vfs_rename(fdir, odentry, tdir, ndentry, NULL);
760 if (!err && EX_ISSYNC(tfhp->fh_export)) {
761 nfsd_sync_dir(tdentry);
762 --- linux-2.4.18-49chaos-lustre9/fs/open.c~vfs_intent-2.4.18-18 Wed Jan 29 12:43:32 2003
763 +++ linux-2.4.18-49chaos-lustre9-root/fs/open.c Wed Jan 29 12:43:32 2003
765 #include <asm/uaccess.h>
767 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
768 +extern int path_walk_it(const char *name, struct nameidata *nd,
769 + struct lookup_intent *it);
770 +extern void intent_release(struct dentry *de, struct lookup_intent *it);
772 int vfs_statfs(struct super_block *sb, struct statfs *buf)
774 @@ -118,12 +121,13 @@ static inline long do_sys_truncate(const
776 struct inode * inode;
778 + struct lookup_intent it = { .it_op = IT_TRUNC };
781 if (length < 0) /* sorry, but loff_t says... */
784 - error = user_path_walk(path, &nd);
785 + error = user_path_walk_it(path, &nd, &it);
788 inode = nd.dentry->d_inode;
789 @@ -168,6 +172,7 @@ static inline long do_sys_truncate(const
790 put_write_access(inode);
793 + intent_release(nd.dentry, &it);
797 @@ -259,8 +264,9 @@ asmlinkage long sys_utime(char * filenam
799 struct inode * inode;
800 struct iattr newattrs;
801 + struct lookup_intent it = { .it_op = IT_SETATTR };
803 - error = user_path_walk(filename, &nd);
804 + error = user_path_walk_it(filename, &nd, &it);
807 inode = nd.dentry->d_inode;
808 @@ -286,6 +292,7 @@ asmlinkage long sys_utime(char * filenam
810 error = notify_change(nd.dentry, &newattrs);
812 + intent_release(nd.dentry, &it);
816 @@ -303,8 +310,9 @@ asmlinkage long sys_utimes(char * filena
818 struct inode * inode;
819 struct iattr newattrs;
820 + struct lookup_intent it = { .it_op = IT_SETATTR };
822 - error = user_path_walk(filename, &nd);
823 + error = user_path_walk_it(filename, &nd, &it);
827 @@ -331,6 +339,7 @@ asmlinkage long sys_utimes(char * filena
829 error = notify_change(nd.dentry, &newattrs);
831 + intent_release(nd.dentry, &it);
835 @@ -347,6 +356,7 @@ asmlinkage long sys_access(const char *
836 int old_fsuid, old_fsgid;
837 kernel_cap_t old_cap;
839 + struct lookup_intent it = { .it_op = IT_GETATTR };
841 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
843 @@ -364,13 +374,14 @@ asmlinkage long sys_access(const char *
845 current->cap_effective = current->cap_permitted;
847 - res = user_path_walk(filename, &nd);
848 + res = user_path_walk_it(filename, &nd, &it);
850 res = permission(nd.dentry->d_inode, mode);
851 /* SuS v2 requires we report a read only fs too */
852 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
853 && !special_file(nd.dentry->d_inode->i_mode))
855 + intent_release(nd.dentry, &it);
859 @@ -385,8 +396,11 @@ asmlinkage long sys_chdir(const char * f
863 + struct lookup_intent it = { .it_op = IT_GETATTR };
865 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
866 + error = __user_walk_it(filename,
867 + LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,
872 @@ -397,6 +411,7 @@ asmlinkage long sys_chdir(const char * f
873 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
876 + intent_release(nd.dentry, &it);
880 @@ -436,9 +451,10 @@ asmlinkage long sys_chroot(const char *
884 + struct lookup_intent it = { .it_op = IT_GETATTR };
886 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
887 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
888 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
889 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
893 @@ -454,6 +470,7 @@ asmlinkage long sys_chroot(const char *
897 + intent_release(nd.dentry, &it);
901 @@ -498,8 +515,9 @@ asmlinkage long sys_chmod(const char * f
902 struct inode * inode;
904 struct iattr newattrs;
905 + struct lookup_intent it = { .it_op = IT_SETATTR };
907 - error = user_path_walk(filename, &nd);
908 + error = user_path_walk_it(filename, &nd, &it);
911 inode = nd.dentry->d_inode;
912 @@ -519,6 +537,7 @@ asmlinkage long sys_chmod(const char * f
913 error = notify_change(nd.dentry, &newattrs);
916 + intent_release(nd.dentry, &it);
920 @@ -588,10 +607,12 @@ asmlinkage long sys_chown(const char * f
924 + struct lookup_intent it = { .it_op = IT_SETATTR };
926 - error = user_path_walk(filename, &nd);
927 + error = user_path_walk_it(filename, &nd, &it);
929 error = chown_common(nd.dentry, user, group);
930 + intent_release(nd.dentry, &it);
934 @@ -601,10 +622,12 @@ asmlinkage long sys_lchown(const char *
938 + struct lookup_intent it = { .it_op = IT_SETATTR };
940 - error = user_path_walk_link(filename, &nd);
941 + error = user_path_walk_link_it(filename, &nd, &it);
943 error = chown_common(nd.dentry, user, group);
944 + intent_release(nd.dentry, &it);
948 @@ -628,7 +651,8 @@ extern ssize_t do_readahead(struct file
949 /* for files over a certains size it doesn't pay to do readahead on open */
950 #define READAHEAD_CUTOFF 48000
952 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
953 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
954 + int flags, struct lookup_intent *it)
958 @@ -693,6 +717,7 @@ struct file *dentry_open(struct dentry *
959 do_readahead(f, 0, (48 * 1024) >> PAGE_SHIFT);
962 + intent_release(dentry, it);
966 @@ -707,11 +732,17 @@ cleanup_all:
970 + intent_release(dentry, it);
973 return ERR_PTR(error);
976 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
978 + return dentry_open_it(dentry, mnt, flags, NULL);
982 * Find an empty file descriptor entry, and mark it busy.
984 --- linux-2.4.18-49chaos-lustre9/fs/stat.c~vfs_intent-2.4.18-18 Wed Jan 29 12:43:32 2003
985 +++ linux-2.4.18-49chaos-lustre9-root/fs/stat.c Wed Jan 29 12:43:32 2003
988 #include <asm/uaccess.h>
990 +extern void intent_release(struct dentry *de, struct lookup_intent *it);
992 * Revalidate the inode. This is required for proper NFS attribute caching.
994 @@ -104,10 +105,12 @@ int vfs_stat(char *name, struct kstat *s
998 + struct lookup_intent it = { .it_op = IT_GETATTR };
1000 - error = user_path_walk(name, &nd);
1001 + error = user_path_walk_it(name, &nd, &it);
1003 error = do_getattr(nd.mnt, nd.dentry, stat);
1004 + intent_release(nd.dentry, &it);
1008 @@ -117,10 +120,12 @@ int vfs_lstat(char *name, struct kstat *
1010 struct nameidata nd;
1012 + struct lookup_intent it = { .it_op = IT_GETATTR };
1014 - error = user_path_walk_link(name, &nd);
1015 + error = user_path_walk_link_it(name, &nd, &it);
1017 error = do_getattr(nd.mnt, nd.dentry, stat);
1018 + intent_release(nd.dentry, &it);
1022 --- linux-2.4.18-49chaos-lustre9/include/linux/dcache.h~vfs_intent-2.4.18-18 Wed Jan 29 12:43:32 2003
1023 +++ linux-2.4.18-49chaos-lustre9-root/include/linux/dcache.h Wed Jan 29 12:43:32 2003
1025 #include <asm/atomic.h>
1026 #include <linux/mount.h>
1028 +#define IT_OPEN (1)
1029 +#define IT_CREAT (1<<1)
1030 +#define IT_READDIR (1<<2)
1031 +#define IT_GETATTR (1<<3)
1032 +#define IT_SETATTR (1<<4)
1033 +#define IT_TRUNC (1<<5)
1034 +#define IT_READLINK (1<<6)
1035 +#define IT_LOOKUP (1<<7)
1037 +struct lookup_intent {
1041 + int it_disposition;
1043 + struct iattr *it_iattr;
1044 + __u64 it_lock_handle[2];
1050 * linux/include/linux/dcache.h
1052 @@ -78,6 +99,7 @@ struct dentry {
1053 unsigned long d_time; /* used by d_revalidate */
1054 struct dentry_operations *d_op;
1055 struct super_block * d_sb; /* The root of the dentry tree */
1056 + struct lookup_intent *d_it;
1057 unsigned long d_vfs_flags;
1058 void * d_fsdata; /* fs-specific data */
1059 void * d_extra_attributes; /* TUX-specific data */
1060 @@ -91,6 +113,8 @@ struct dentry_operations {
1061 int (*d_delete)(struct dentry *);
1062 void (*d_release)(struct dentry *);
1063 void (*d_iput)(struct dentry *, struct inode *);
1064 + int (*d_revalidate2)(struct dentry *, int, struct lookup_intent *);
1065 + void (*d_intent_release)(struct dentry *, struct lookup_intent *);
1068 /* the dentry parameter passed to d_hash and d_compare is the parent
1069 @@ -124,6 +148,7 @@ d_iput: no no yes
1070 * s_nfsd_free_path semaphore will be down
1072 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1073 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1075 extern spinlock_t dcache_lock;
1077 --- linux-2.4.18-49chaos-lustre9/include/linux/fs.h~vfs_intent-2.4.18-18 Wed Jan 29 12:43:32 2003
1078 +++ linux-2.4.18-49chaos-lustre9-root/include/linux/fs.h Wed Jan 29 12:43:32 2003
1079 @@ -576,6 +576,7 @@ struct file {
1081 /* needed for tty driver, and maybe others */
1083 + struct lookup_intent *f_intent;
1085 /* preallocated helper kiobuf to speedup O_DIRECT */
1086 struct kiobuf *f_iobuf;
1087 @@ -836,7 +837,9 @@ extern int vfs_symlink(struct inode *, s
1088 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1089 extern int vfs_rmdir(struct inode *, struct dentry *);
1090 extern int vfs_unlink(struct inode *, struct dentry *);
1091 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1092 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1093 + struct inode *new_dir, struct dentry *new_dentry,
1094 + struct lookup_intent *it);
1098 @@ -897,16 +900,28 @@ struct file_operations {
1099 struct inode_operations {
1100 int (*create) (struct inode *,struct dentry *,int);
1101 struct dentry * (*lookup) (struct inode *,struct dentry *);
1102 + struct dentry * (*lookup2) (struct inode *,struct dentry *, struct lookup_intent *);
1103 int (*link) (struct dentry *,struct inode *,struct dentry *);
1104 + int (*link2) (struct inode *,struct inode *, const char *, int);
1105 int (*unlink) (struct inode *,struct dentry *);
1106 + int (*unlink2) (struct inode *, const char *, int);
1107 int (*symlink) (struct inode *,struct dentry *,const char *);
1108 + int (*symlink2) (struct inode *, const char *, int, const char *);
1109 int (*mkdir) (struct inode *,struct dentry *,int);
1110 + int (*mkdir2) (struct inode *, const char *, int,int);
1111 int (*rmdir) (struct inode *,struct dentry *);
1112 + int (*rmdir2) (struct inode *, const char *, int);
1113 int (*mknod) (struct inode *,struct dentry *,int,int);
1114 + int (*mknod2) (struct inode *, const char *, int,int,int);
1115 int (*rename) (struct inode *, struct dentry *,
1116 struct inode *, struct dentry *);
1117 + int (*rename2) (struct inode *, struct inode *,
1118 + const char *oldname, int oldlen,
1119 + const char *newname, int newlen);
1120 int (*readlink) (struct dentry *, char *,int);
1121 int (*follow_link) (struct dentry *, struct nameidata *);
1122 + int (*follow_link2) (struct dentry *, struct nameidata *,
1123 + struct lookup_intent *it);
1124 void (*truncate) (struct inode *);
1125 int (*permission) (struct inode *, int);
1126 int (*revalidate) (struct dentry *);
1127 @@ -1383,6 +1398,7 @@ typedef int (*read_actor_t)(read_descrip
1128 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1130 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1131 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1132 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1133 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1134 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1135 @@ -1394,6 +1410,8 @@ extern struct dentry * lookup_one_len(co
1136 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1137 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1138 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1139 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1140 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1142 extern void inode_init_once(struct inode *);
1143 extern void iput(struct inode *);
1144 @@ -1494,6 +1512,8 @@ extern struct file_operations generic_ro
1146 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1147 extern int vfs_follow_link(struct nameidata *, const char *);
1148 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1149 + struct lookup_intent *it);
1150 extern int page_readlink(struct dentry *, char *, int);
1151 extern int page_follow_link(struct dentry *, struct nameidata *);
1152 extern struct inode_operations page_symlink_inode_operations;
1153 --- linux-2.4.18-49chaos-lustre9/kernel/ksyms.c~vfs_intent-2.4.18-18 Wed Jan 29 12:43:32 2003
1154 +++ linux-2.4.18-49chaos-lustre9-root/kernel/ksyms.c Wed Jan 29 12:43:32 2003
1155 @@ -294,6 +294,7 @@ EXPORT_SYMBOL(read_cache_page);
1156 EXPORT_SYMBOL(set_page_dirty);
1157 EXPORT_SYMBOL(vfs_readlink);
1158 EXPORT_SYMBOL(vfs_follow_link);
1159 +EXPORT_SYMBOL(vfs_follow_link_it);
1160 EXPORT_SYMBOL(page_readlink);
1161 EXPORT_SYMBOL(page_follow_link);
1162 EXPORT_SYMBOL(page_symlink_inode_operations);