3 fs/namei.c | 330 +++++++++++++++++++++++++++++++++++++++-------
4 fs/namespace.c | 28 ++-
5 fs/open.c | 172 +++++++++++++++++------
8 include/linux/dcache.h | 60 ++++++++
9 include/linux/fs.h | 32 ++++
10 include/linux/fs_struct.h | 4
14 13 files changed, 591 insertions(+), 133 deletions(-)
16 --- linux-2.4.20-hp4-pnnl13/fs/exec.c~vfs_intent-2.4.20-hp 2003-09-13 15:19:27.000000000 +0400
17 +++ linux-2.4.20-hp4-pnnl13-alexey/fs/exec.c 2003-09-14 17:33:51.000000000 +0400
18 @@ -116,8 +116,10 @@ asmlinkage long sys_uselib(const char *
22 + struct lookup_intent it = { .it_op = IT_OPEN,
23 + .it_flags = FMODE_READ|FMODE_EXEC };
25 - error = user_path_walk(library, &nd);
26 + error = user_path_walk_it(library, &nd, &it);
30 @@ -129,7 +131,8 @@ asmlinkage long sys_uselib(const char *
34 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
35 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
36 + intent_release(&it);
37 error = PTR_ERR(file);
40 @@ -372,8 +375,10 @@ struct file *open_exec(const char *name)
44 + struct lookup_intent it = { .it_op = IT_OPEN,
45 + .it_flags = FMODE_READ|FMODE_EXEC };
47 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
48 + err = path_lookup_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
51 inode = nd.dentry->d_inode;
52 @@ -385,7 +390,8 @@ struct file *open_exec(const char *name)
56 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
57 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
58 + intent_release(&it);
60 err = deny_write_access(file);
62 @@ -397,6 +403,7 @@ out:
66 + intent_release(&it);
70 @@ -1128,7 +1135,7 @@ int do_coredump(long signr, struct pt_re
72 if (!file->f_op->write)
74 - if (do_truncate(file->f_dentry, 0) != 0)
75 + if (do_truncate(file->f_dentry, 0, 0) != 0)
78 retval = binfmt->core_dump(signr, regs, file);
79 --- linux-2.4.20-hp4-pnnl13/fs/dcache.c~vfs_intent-2.4.20-hp 2002-11-29 02:53:15.000000000 +0300
80 +++ linux-2.4.20-hp4-pnnl13-alexey/fs/dcache.c 2003-09-14 17:33:51.000000000 +0400
81 @@ -181,6 +181,13 @@ int d_invalidate(struct dentry * dentry)
82 spin_unlock(&dcache_lock);
86 + /* network invalidation by Lustre */
87 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
88 + spin_unlock(&dcache_lock);
93 * Check whether to do a partial shrink_dcache
94 * to get rid of unused child entries.
95 @@ -830,13 +837,19 @@ void d_delete(struct dentry * dentry)
96 * Adds a dentry to the hash according to its name.
99 -void d_rehash(struct dentry * entry)
100 +void __d_rehash(struct dentry * entry, int lock)
102 struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
103 if (!list_empty(&entry->d_hash)) BUG();
104 - spin_lock(&dcache_lock);
105 + if (lock) spin_lock(&dcache_lock);
106 list_add(&entry->d_hash, list);
107 - spin_unlock(&dcache_lock);
108 + if (lock) spin_unlock(&dcache_lock);
110 +EXPORT_SYMBOL(__d_rehash);
112 +void d_rehash(struct dentry * entry)
114 + __d_rehash(entry, 1);
117 #define do_switch(x,y) do { \
118 --- linux-2.4.20-hp4-pnnl13/fs/namespace.c~vfs_intent-2.4.20-hp 2002-11-29 02:53:15.000000000 +0300
119 +++ linux-2.4.20-hp4-pnnl13-alexey/fs/namespace.c 2003-09-14 17:33:51.000000000 +0400
120 @@ -99,6 +99,7 @@ static void detach_mnt(struct vfsmount *
122 old_nd->dentry = mnt->mnt_mountpoint;
123 old_nd->mnt = mnt->mnt_parent;
124 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
125 mnt->mnt_parent = mnt;
126 mnt->mnt_mountpoint = mnt->mnt_root;
127 list_del_init(&mnt->mnt_child);
128 @@ -110,6 +111,7 @@ static void attach_mnt(struct vfsmount *
130 mnt->mnt_parent = mntget(nd->mnt);
131 mnt->mnt_mountpoint = dget(nd->dentry);
132 + PIN(nd->dentry, nd->mnt, 1);
133 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
134 list_add(&mnt->mnt_child, &nd->mnt->mnt_mounts);
135 nd->dentry->d_mounted++;
136 @@ -485,14 +487,17 @@ static int do_loopback(struct nameidata
138 struct nameidata old_nd;
139 struct vfsmount *mnt = NULL;
140 + struct lookup_intent it = { .it_op = IT_GETATTR };
141 int err = mount_is_safe(nd);
144 if (!old_name || !*old_name)
146 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
148 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
150 + intent_release(&it);
154 down_write(¤t->namespace->sem);
156 @@ -515,6 +520,7 @@ static int do_loopback(struct nameidata
159 up_write(¤t->namespace->sem);
160 + intent_release(&it);
161 path_release(&old_nd);
164 @@ -698,6 +704,7 @@ long do_mount(char * dev_name, char * di
165 unsigned long flags, void *data_page)
168 + struct lookup_intent it = { .it_op = IT_GETATTR };
172 @@ -722,10 +729,11 @@ long do_mount(char * dev_name, char * di
173 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
175 /* ... and get the mountpoint */
176 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
178 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
180 + intent_release(&it);
184 if (flags & MS_REMOUNT)
185 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
187 @@ -736,6 +744,8 @@ long do_mount(char * dev_name, char * di
189 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
190 dev_name, data_page);
192 + intent_release(&it);
196 @@ -901,6 +911,8 @@ asmlinkage long sys_pivot_root(const cha
198 struct vfsmount *tmp;
199 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
200 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
201 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
204 if (!capable(CAP_SYS_ADMIN))
205 @@ -908,14 +920,14 @@ asmlinkage long sys_pivot_root(const cha
209 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
210 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
214 if (!check_mnt(new_nd.mnt))
217 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
218 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
222 @@ -970,8 +982,10 @@ out2:
223 up(&old_nd.dentry->d_inode->i_zombie);
224 up_write(¤t->namespace->sem);
225 path_release(&user_nd);
226 + intent_release(&old_it);
227 path_release(&old_nd);
229 + intent_release(&new_it);
230 path_release(&new_nd);
233 --- linux-2.4.20-hp4-pnnl13/fs/namei.c~vfs_intent-2.4.20-hp 2003-09-13 15:19:23.000000000 +0400
234 +++ linux-2.4.20-hp4-pnnl13-alexey/fs/namei.c 2003-09-14 17:33:51.000000000 +0400
236 * XEmacs seems to be relying on it...
239 +void intent_release(struct lookup_intent *it)
241 + if (it && it->it_op_release)
242 + it->it_op_release(it);
246 /* In order to reduce some races, while at the same time doing additional
247 * checking and hopefully speeding things up, we copy filenames to the
248 * kernel data space before using them..
249 @@ -260,10 +267,19 @@ void path_release(struct nameidata *nd)
250 * Internal lookup() using the new generic dcache.
253 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
254 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
255 + int flags, struct lookup_intent *it)
257 struct dentry * dentry = d_lookup(parent, name);
259 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
260 + if (!dentry->d_op->d_revalidate_it(dentry, flags, it) &&
261 + !d_invalidate(dentry)) {
267 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
268 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
270 @@ -281,11 +297,15 @@ static struct dentry * cached_lookup(str
271 * make sure that nobody added the entry to the dcache in the meantime..
274 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
275 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
276 + int flags, struct lookup_intent *it)
278 struct dentry * result;
279 struct inode *dir = parent->d_inode;
286 * First re-do the cached lookup just in case it was created
287 @@ -300,6 +320,9 @@ static struct dentry * real_lookup(struc
288 result = ERR_PTR(-ENOMEM);
291 + if (dir->i_op->lookup_it)
292 + result = dir->i_op->lookup_it(dir, dentry, it, flags);
294 result = dir->i_op->lookup(dir, dentry);
297 @@ -321,6 +344,15 @@ static struct dentry * real_lookup(struc
299 result = ERR_PTR(-ENOENT);
301 + } else if (result->d_op && result->d_op->d_revalidate_it) {
302 + if (!result->d_op->d_revalidate_it(result, flags, it) &&
303 + !d_invalidate(result)) {
306 + result = ERR_PTR(-ESTALE);
307 + if (!IS_ERR(result))
313 @@ -332,7 +364,8 @@ static struct dentry * real_lookup(struc
314 * Without that kind of total limit, nasty chains of consecutive
315 * symlinks can cause almost arbitrarily long lookups.
317 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
318 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
319 + struct lookup_intent *it)
322 if (current->link_count >= 5)
323 @@ -346,10 +379,18 @@ static inline int do_follow_link(struct
324 current->link_count++;
325 current->total_link_count++;
326 UPDATE_ATIME(dentry->d_inode);
328 err = dentry->d_inode->i_op->follow_link(dentry, nd);
329 + if (!err && it != NULL && !(it->d.lustre.it_int_flags & IT_FL_FOLLOWED)) {
330 + /* vfs_follow_link was never called */
331 + intent_release(it);
335 current->link_count--;
338 + intent_release(it);
342 @@ -379,15 +420,26 @@ int follow_up(struct vfsmount **mnt, str
343 return __follow_up(mnt, dentry);
346 -static inline int __follow_down(struct vfsmount **mnt, struct dentry **dentry)
347 +static inline int __follow_down(struct vfsmount **mnt, struct dentry **dentry,
348 + struct lookup_intent *it)
350 struct vfsmount *mounted;
352 spin_lock(&dcache_lock);
353 mounted = lookup_mnt(*mnt, *dentry);
355 + int opc = 0, mode = 0;
356 *mnt = mntget(mounted);
357 spin_unlock(&dcache_lock);
360 + mode = it->it_create_mode;
362 + intent_release(it);
365 + it->it_create_mode = mode;
368 mntput(mounted->mnt_parent);
369 *dentry = dget(mounted->mnt_root);
370 @@ -399,7 +451,7 @@ static inline int __follow_down(struct v
372 int follow_down(struct vfsmount **mnt, struct dentry **dentry)
374 - return __follow_down(mnt,dentry);
375 + return __follow_down(mnt,dentry,NULL);
378 static inline void follow_dotdot(struct nameidata *nd)
379 @@ -435,7 +487,7 @@ static inline void follow_dotdot(struct
383 - while (d_mountpoint(nd->dentry) && __follow_down(&nd->mnt, &nd->dentry))
384 + while (d_mountpoint(nd->dentry) && __follow_down(&nd->mnt, &nd->dentry, NULL))
388 @@ -447,7 +499,8 @@ static inline void follow_dotdot(struct
390 * We expect 'base' to be positive and a directory.
392 -int link_path_walk(const char * name, struct nameidata *nd)
393 +int link_path_walk_it(const char *name, struct nameidata *nd,
394 + struct lookup_intent *it)
396 struct dentry *dentry;
398 @@ -520,15 +573,15 @@ int link_path_walk(const char * name, st
401 /* This does the actual lookups.. */
402 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
403 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
405 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
406 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
407 err = PTR_ERR(dentry);
411 /* Check mountpoints.. */
412 - while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry))
413 + while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry, NULL))
417 @@ -540,7 +593,7 @@ int link_path_walk(const char * name, st
420 if (inode->i_op->follow_link) {
421 - err = do_follow_link(dentry, nd);
422 + err = do_follow_link(dentry, nd, NULL);
426 @@ -556,7 +609,7 @@ int link_path_walk(const char * name, st
430 - if (!inode->i_op->lookup)
431 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
434 /* here ends the main loop */
435 @@ -583,19 +636,19 @@ last_component:
439 - dentry = cached_lookup(nd->dentry, &this, 0);
440 + dentry = cached_lookup(nd->dentry, &this, 0, it);
442 - dentry = real_lookup(nd->dentry, &this, 0);
443 + dentry = real_lookup(nd->dentry, &this, 0, it);
444 err = PTR_ERR(dentry);
448 - while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry))
449 + while (d_mountpoint(dentry) && __follow_down(&nd->mnt, &dentry, it))
451 inode = dentry->d_inode;
452 if ((lookup_flags & LOOKUP_FOLLOW)
453 && inode && inode->i_op && inode->i_op->follow_link) {
454 - err = do_follow_link(dentry, nd);
455 + err = do_follow_link(dentry, nd, it);
459 @@ -609,7 +662,8 @@ last_component:
461 if (lookup_flags & LOOKUP_DIRECTORY) {
463 - if (!inode->i_op || !inode->i_op->lookup)
464 + if (!inode->i_op ||
465 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
469 @@ -633,6 +687,25 @@ return_reval:
470 * Check the cached dentry for staleness.
473 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
475 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
476 + struct dentry *new;
477 + err = permission(dentry->d_parent->d_inode,
481 + new = real_lookup(dentry->d_parent,
482 + &dentry->d_name, 0, NULL);
483 + d_invalidate(dentry);
486 + err = PTR_ERR(new);
492 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
494 if (!dentry->d_op->d_revalidate(dentry, 0)) {
495 @@ -646,15 +719,28 @@ out_dput:
500 + intent_release(it);
506 +int link_path_walk(const char * name, struct nameidata *nd)
508 + return link_path_walk_it(name, nd, NULL);
511 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
513 + current->total_link_count = 0;
514 + return link_path_walk_it(name, nd, it);
517 int path_walk(const char * name, struct nameidata *nd)
519 current->total_link_count = 0;
520 - return link_path_walk(name, nd);
521 + return link_path_walk_it(name, nd, NULL);
525 @@ -739,6 +825,17 @@ walk_init_root(const char *name, struct
529 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
530 + struct lookup_intent *it)
533 + if (path_init(path, flags, nd))
534 + error = path_walk_it(path, nd, it);
540 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
543 @@ -753,6 +850,7 @@ int path_init(const char *name, unsigned
545 nd->last_type = LAST_ROOT; /* if there are only slashes... */
549 return walk_init_root(name,nd);
550 read_lock(¤t->fs->lock);
551 @@ -767,7 +865,8 @@ int path_init(const char *name, unsigned
552 * needs parent already locked. Doesn't follow mounts.
555 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
556 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
557 + struct lookup_intent *it)
559 struct dentry * dentry;
561 @@ -790,13 +889,16 @@ struct dentry * lookup_hash(struct qstr
565 - dentry = cached_lookup(base, name, 0);
566 + dentry = cached_lookup(base, name, 0, it);
568 struct dentry *new = d_alloc(base, name);
569 dentry = ERR_PTR(-ENOMEM);
573 + if (inode->i_op->lookup_it)
574 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
576 dentry = inode->i_op->lookup(inode, new);
579 @@ -808,6 +910,12 @@ out:
583 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
585 + return lookup_hash_it(name, base, NULL);
590 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
592 @@ -829,7 +937,7 @@ struct dentry * lookup_one_len(const cha
594 this.hash = end_name_hash(hash);
596 - return lookup_hash(&this, base);
597 + return lookup_hash_it(&this, base, NULL);
599 return ERR_PTR(-EACCES);
601 @@ -860,6 +968,23 @@ int __user_walk(const char *name, unsign
605 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
606 + struct lookup_intent *it)
611 + tmp = getname(name);
612 + err = PTR_ERR(tmp);
613 + if (!IS_ERR(tmp)) {
615 + if (path_init(tmp, flags, nd))
616 + err = path_walk_it(tmp, nd, it);
623 * It's inline, so penalty for filesystems that don't use sticky bit is
625 @@ -955,7 +1080,8 @@ static inline int lookup_flags(unsigned
629 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
630 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
631 + struct lookup_intent *it)
635 @@ -968,12 +1094,15 @@ int vfs_create(struct inode *dir, struct
638 error = -EACCES; /* shouldn't it be ENOSYS? */
639 - if (!dir->i_op || !dir->i_op->create)
640 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
645 - error = dir->i_op->create(dir, dentry, mode);
646 + if (dir->i_op->create_it)
647 + error = dir->i_op->create_it(dir, dentry, mode, it);
649 + error = dir->i_op->create(dir, dentry, mode);
653 @@ -982,6 +1111,11 @@ exit_lock:
657 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
659 + return vfs_create_it(dir, dentry, mode, NULL);
665 @@ -996,7 +1130,8 @@ exit_lock:
666 * for symlinks (where the permissions are checked later).
669 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
670 +int open_namei_it(const char *pathname, int flag, int mode,
671 + struct nameidata *nd, struct lookup_intent *it)
673 int acc_mode, error = 0;
675 @@ -1006,11 +1141,14 @@ int open_namei(const char * pathname, in
677 acc_mode = ACC_MODE(flag);
680 + it->it_flags = flag;
683 * The simplest case - just a plain lookup.
685 if (!(flag & O_CREAT)) {
686 - error = path_lookup(pathname, lookup_flags(flag), nd);
687 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
691 @@ -1020,6 +1158,10 @@ int open_namei(const char * pathname, in
693 * Create - we need to know the parent.
696 + it->it_create_mode = mode;
697 + it->it_op |= IT_CREAT;
699 error = path_lookup(pathname, LOOKUP_PARENT, nd);
702 @@ -1035,7 +1177,7 @@ int open_namei(const char * pathname, in
705 down(&dir->d_inode->i_sem);
706 - dentry = lookup_hash(&nd->last, nd->dentry);
707 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
710 error = PTR_ERR(dentry);
711 @@ -1044,11 +1186,12 @@ do_last:
715 + it->it_create_mode = mode;
716 /* Negative dentry, just create the file */
717 if (!dentry->d_inode) {
718 if (!IS_POSIXACL(dir->d_inode))
719 mode &= ~current->fs->umask;
720 - error = vfs_create(dir->d_inode, dentry, mode);
721 + error = vfs_create_it(dir->d_inode, dentry, mode, it);
722 up(&dir->d_inode->i_sem);
725 @@ -1073,7 +1216,7 @@ do_last:
727 if (flag & O_NOFOLLOW)
729 - while (__follow_down(&nd->mnt,&dentry) && d_mountpoint(dentry));
730 + while (__follow_down(&nd->mnt,&dentry,it) && d_mountpoint(dentry));
733 if (!dentry->d_inode)
734 @@ -1152,7 +1295,7 @@ ok:
738 - error = do_truncate(dentry, 0);
739 + error = do_truncate(dentry, 0, 1);
741 put_write_access(inode);
743 @@ -1164,8 +1307,10 @@ ok:
747 + intent_release(it);
750 + intent_release(it);
754 @@ -1184,7 +1329,16 @@ do_link:
755 * are done. Procfs-like symlinks just set LAST_BIND.
757 UPDATE_ATIME(dentry->d_inode);
759 error = dentry->d_inode->i_op->follow_link(dentry, nd);
761 + intent_release(it);
762 + } else if (it != NULL && !(it->d.lustre.it_int_flags & IT_FL_FOLLOWED)) {
763 + /* vfs_follow_link was never called */
764 + intent_release(it);
771 @@ -1206,13 +1360,20 @@ do_link:
774 down(&dir->d_inode->i_sem);
775 - dentry = lookup_hash(&nd->last, nd->dentry);
776 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
777 putname(nd->last.name);
781 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
783 + return open_namei_it(pathname, flag, mode, nd, NULL);
788 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
789 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
790 + struct lookup_intent *it)
792 struct dentry *dentry;
794 @@ -1220,7 +1381,7 @@ static struct dentry *lookup_create(stru
795 dentry = ERR_PTR(-EEXIST);
796 if (nd->last_type != LAST_NORM)
798 - dentry = lookup_hash(&nd->last, nd->dentry);
799 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
802 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
803 @@ -1276,7 +1437,16 @@ asmlinkage long sys_mknod(const char * f
804 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
807 - dentry = lookup_create(&nd, 0);
809 + if (nd.dentry->d_inode->i_op->mknod_raw) {
810 + struct inode_operations *op = nd.dentry->d_inode->i_op;
811 + error = op->mknod_raw(&nd, mode, dev);
812 + /* the file system wants to use normal vfs path now */
813 + if (error != -EOPNOTSUPP)
817 + dentry = lookup_create(&nd, 0, NULL);
818 error = PTR_ERR(dentry);
820 if (!IS_POSIXACL(nd.dentry->d_inode))
821 @@ -1298,6 +1468,7 @@ asmlinkage long sys_mknod(const char * f
824 up(&nd.dentry->d_inode->i_sem);
829 @@ -1345,7 +1516,14 @@ asmlinkage long sys_mkdir(const char * p
830 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
833 - dentry = lookup_create(&nd, 1);
834 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
835 + struct inode_operations *op = nd.dentry->d_inode->i_op;
836 + error = op->mkdir_raw(&nd, mode);
837 + /* the file system wants to use normal vfs path now */
838 + if (error != -EOPNOTSUPP)
841 + dentry = lookup_create(&nd, 1, NULL);
842 error = PTR_ERR(dentry);
843 if (!IS_ERR(dentry)) {
844 if (!IS_POSIXACL(nd.dentry->d_inode))
845 @@ -1354,6 +1532,7 @@ asmlinkage long sys_mkdir(const char * p
848 up(&nd.dentry->d_inode->i_sem);
853 @@ -1454,8 +1633,16 @@ asmlinkage long sys_rmdir(const char * p
857 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
858 + struct inode_operations *op = nd.dentry->d_inode->i_op;
860 + error = op->rmdir_raw(&nd);
861 + /* the file system wants to use normal vfs path now */
862 + if (error != -EOPNOTSUPP)
865 down(&nd.dentry->d_inode->i_sem);
866 - dentry = lookup_hash(&nd.last, nd.dentry);
867 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
868 error = PTR_ERR(dentry);
869 if (!IS_ERR(dentry)) {
870 error = vfs_rmdir(nd.dentry->d_inode, dentry);
871 @@ -1513,8 +1700,15 @@ asmlinkage long sys_unlink(const char *
873 if (nd.last_type != LAST_NORM)
875 + if (nd.dentry->d_inode->i_op->unlink_raw) {
876 + struct inode_operations *op = nd.dentry->d_inode->i_op;
877 + error = op->unlink_raw(&nd);
878 + /* the file system wants to use normal vfs path now */
879 + if (error != -EOPNOTSUPP)
882 down(&nd.dentry->d_inode->i_sem);
883 - dentry = lookup_hash(&nd.last, nd.dentry);
884 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
885 error = PTR_ERR(dentry);
886 if (!IS_ERR(dentry)) {
887 /* Why not before? Because we want correct error value */
888 @@ -1581,15 +1775,23 @@ asmlinkage long sys_symlink(const char *
889 error = path_lookup(to, LOOKUP_PARENT, &nd);
892 - dentry = lookup_create(&nd, 0);
893 + if (nd.dentry->d_inode->i_op->symlink_raw) {
894 + struct inode_operations *op = nd.dentry->d_inode->i_op;
895 + error = op->symlink_raw(&nd, from);
896 + /* the file system wants to use normal vfs path now */
897 + if (error != -EOPNOTSUPP)
900 + dentry = lookup_create(&nd, 0, NULL);
901 error = PTR_ERR(dentry);
902 if (!IS_ERR(dentry)) {
903 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
906 up(&nd.dentry->d_inode->i_sem);
914 @@ -1665,7 +1867,14 @@ asmlinkage long sys_link(const char * ol
916 if (old_nd.mnt != nd.mnt)
918 - new_dentry = lookup_create(&nd, 0);
919 + if (nd.dentry->d_inode->i_op->link_raw) {
920 + struct inode_operations *op = nd.dentry->d_inode->i_op;
921 + error = op->link_raw(&old_nd, &nd);
922 + /* the file system wants to use normal vfs path now */
923 + if (error != -EOPNOTSUPP)
926 + new_dentry = lookup_create(&nd, 0, NULL);
927 error = PTR_ERR(new_dentry);
928 if (!IS_ERR(new_dentry)) {
929 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
930 @@ -1709,7 +1918,7 @@ exit:
933 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
934 - struct inode *new_dir, struct dentry *new_dentry)
935 + struct inode *new_dir, struct dentry *new_dentry)
938 struct inode *target;
939 @@ -1788,7 +1997,7 @@ out_unlock:
942 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
943 - struct inode *new_dir, struct dentry *new_dentry)
944 + struct inode *new_dir, struct dentry *new_dentry)
948 @@ -1876,9 +2085,18 @@ static inline int do_rename(const char *
949 if (newnd.last_type != LAST_NORM)
952 + if (old_dir->d_inode->i_op->rename_raw) {
954 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
956 + /* the file system wants to use normal vfs path now */
957 + if (error != -EOPNOTSUPP)
961 double_lock(new_dir, old_dir);
963 - old_dentry = lookup_hash(&oldnd.last, old_dir);
964 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
965 error = PTR_ERR(old_dentry);
966 if (IS_ERR(old_dentry))
968 @@ -1894,16 +2112,16 @@ static inline int do_rename(const char *
969 if (newnd.last.name[newnd.last.len])
972 - new_dentry = lookup_hash(&newnd.last, new_dir);
973 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
974 error = PTR_ERR(new_dentry);
975 if (IS_ERR(new_dentry))
980 error = vfs_rename(old_dir->d_inode, old_dentry,
981 new_dir->d_inode, new_dentry);
987 @@ -1954,20 +2172,28 @@ out:
991 -__vfs_follow_link(struct nameidata *nd, const char *link)
992 +__vfs_follow_link(struct nameidata *nd, const char *link,
993 + struct lookup_intent *it)
1002 + else if (it != nd->intent)
1003 + printk("it != nd->intent: tell phil@clusterfs.com\n");
1005 + it->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
1009 if (!walk_init_root(link, nd))
1010 /* weird __emul_prefix() stuff did it */
1013 - res = link_path_walk(link, nd);
1014 + res = link_path_walk_it(link, nd, it);
1016 if (current->link_count || res || nd->last_type!=LAST_NORM)
1018 @@ -1989,7 +2215,13 @@ fail:
1020 int vfs_follow_link(struct nameidata *nd, const char *link)
1022 - return __vfs_follow_link(nd, link);
1023 + return __vfs_follow_link(nd, link, NULL);
1026 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
1027 + struct lookup_intent *it)
1029 + return __vfs_follow_link(nd, link, it);
1032 /* get the link contents into pagecache */
1033 @@ -2031,7 +2263,7 @@ int page_follow_link(struct dentry *dent
1035 struct page *page = NULL;
1036 char *s = page_getlink(dentry, &page);
1037 - int res = __vfs_follow_link(nd, s);
1038 + int res = __vfs_follow_link(nd, s, NULL);
1041 page_cache_release(page);
1042 --- linux-2.4.20-hp4-pnnl13/fs/open.c~vfs_intent-2.4.20-hp 2002-11-29 02:53:15.000000000 +0300
1043 +++ linux-2.4.20-hp4-pnnl13-alexey/fs/open.c 2003-09-14 17:33:51.000000000 +0400
1045 #include <asm/uaccess.h>
1047 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
1048 +extern int path_walk_it(const char *name, struct nameidata *nd,
1049 + struct lookup_intent *it);
1051 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1053 @@ -95,9 +97,10 @@ void fd_install(unsigned int fd, struct
1054 write_unlock(&files->file_lock);
1057 -int do_truncate(struct dentry *dentry, loff_t length)
1058 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1060 struct inode *inode = dentry->d_inode;
1061 + struct inode_operations *op = dentry->d_inode->i_op;
1063 struct iattr newattrs;
1065 @@ -108,7 +111,13 @@ int do_truncate(struct dentry *dentry, l
1066 down(&inode->i_sem);
1067 newattrs.ia_size = length;
1068 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1069 - error = notify_change(dentry, &newattrs);
1070 + if (called_from_open)
1071 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1072 + if (op->setattr_raw) {
1073 + newattrs.ia_valid |= ATTR_RAW;
1074 + error = op->setattr_raw(inode, &newattrs);
1076 + error = notify_change(dentry, &newattrs);
1080 @@ -118,12 +127,13 @@ static inline long do_sys_truncate(const
1081 struct nameidata nd;
1082 struct inode * inode;
1084 + struct lookup_intent it = { .it_op = IT_GETATTR };
1087 if (length < 0) /* sorry, but loff_t says... */
1090 - error = user_path_walk(path, &nd);
1091 + error = user_path_walk_it(path, &nd, &it);
1094 inode = nd.dentry->d_inode;
1095 @@ -163,11 +173,13 @@ static inline long do_sys_truncate(const
1096 error = locks_verify_truncate(inode, NULL, length);
1099 - error = do_truncate(nd.dentry, length);
1100 + intent_release(&it);
1101 + error = do_truncate(nd.dentry, length, 0);
1103 put_write_access(inode);
1106 + intent_release(&it);
1110 @@ -215,7 +227,7 @@ static inline long do_sys_ftruncate(unsi
1112 error = locks_verify_truncate(inode, file, length);
1114 - error = do_truncate(dentry, length);
1115 + error = do_truncate(dentry, length, 0);
1119 @@ -260,11 +272,13 @@ asmlinkage long sys_utime(char * filenam
1120 struct inode * inode;
1121 struct iattr newattrs;
1123 - error = user_path_walk(filename, &nd);
1124 + error = user_path_walk_it(filename, &nd, NULL);
1127 inode = nd.dentry->d_inode;
1129 + /* this is safe without a Lustre lock because it only depends
1130 + on the super block */
1132 if (IS_RDONLY(inode))
1134 @@ -279,11 +293,25 @@ asmlinkage long sys_utime(char * filenam
1137 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1141 + if (inode->i_op->setattr_raw) {
1142 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1144 + newattrs.ia_valid |= ATTR_RAW;
1145 + error = op->setattr_raw(inode, &newattrs);
1146 + /* the file system wants to use normal vfs path now */
1147 + if (error != -EOPNOTSUPP)
1148 + goto dput_and_out;
1153 if (current->fsuid != inode->i_uid &&
1154 (error = permission(inode,MAY_WRITE)) != 0)
1158 error = notify_change(nd.dentry, &newattrs);
1161 @@ -304,12 +332,14 @@ asmlinkage long sys_utimes(char * filena
1162 struct inode * inode;
1163 struct iattr newattrs;
1165 - error = user_path_walk(filename, &nd);
1166 + error = user_path_walk_it(filename, &nd, NULL);
1170 inode = nd.dentry->d_inode;
1172 + /* this is safe without a Lustre lock because it only depends
1173 + on the super block */
1175 if (IS_RDONLY(inode))
1177 @@ -324,7 +354,20 @@ asmlinkage long sys_utimes(char * filena
1178 newattrs.ia_atime = times[0].tv_sec;
1179 newattrs.ia_mtime = times[1].tv_sec;
1180 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1184 + if (inode->i_op->setattr_raw) {
1185 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1187 + newattrs.ia_valid |= ATTR_RAW;
1188 + error = op->setattr_raw(inode, &newattrs);
1189 + /* the file system wants to use normal vfs path now */
1190 + if (error != -EOPNOTSUPP)
1191 + goto dput_and_out;
1196 if (current->fsuid != inode->i_uid &&
1197 (error = permission(inode,MAY_WRITE)) != 0)
1199 @@ -347,6 +390,7 @@ asmlinkage long sys_access(const char *
1200 int old_fsuid, old_fsgid;
1201 kernel_cap_t old_cap;
1203 + struct lookup_intent it = { .it_op = IT_GETATTR };
1205 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1207 @@ -364,13 +408,14 @@ asmlinkage long sys_access(const char *
1209 current->cap_effective = current->cap_permitted;
1211 - res = user_path_walk(filename, &nd);
1212 + res = user_path_walk_it(filename, &nd, &it);
1214 res = permission(nd.dentry->d_inode, mode);
1215 /* SuS v2 requires we report a read only fs too */
1216 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1217 && !special_file(nd.dentry->d_inode->i_mode))
1219 + intent_release(&it);
1223 @@ -385,8 +430,9 @@ asmlinkage long sys_chdir(const char * f
1226 struct nameidata nd;
1227 + struct lookup_intent it = { .it_op = IT_GETATTR };
1229 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1230 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1234 @@ -397,6 +443,7 @@ asmlinkage long sys_chdir(const char * f
1235 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1238 + intent_release(&it);
1242 @@ -436,9 +483,10 @@ asmlinkage long sys_chroot(const char *
1245 struct nameidata nd;
1246 + struct lookup_intent it = { .it_op = IT_GETATTR };
1248 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1249 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1250 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1251 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1255 @@ -454,39 +502,56 @@ asmlinkage long sys_chroot(const char *
1259 + intent_release(&it);
1265 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1266 +int chmod_common(struct dentry *dentry, mode_t mode)
1268 - struct inode * inode;
1269 - struct dentry * dentry;
1270 - struct file * file;
1272 + struct inode *inode = dentry->d_inode;
1273 struct iattr newattrs;
1278 + if (IS_RDONLY(inode))
1281 - dentry = file->f_dentry;
1282 - inode = dentry->d_inode;
1283 + if (inode->i_op->setattr_raw) {
1284 + newattrs.ia_mode = mode;
1285 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1286 + newattrs.ia_valid |= ATTR_RAW;
1287 + err = inode->i_op->setattr_raw(inode, &newattrs);
1288 + /* the file system wants to use normal vfs path now */
1289 + if (err != -EOPNOTSUPP)
1294 - if (IS_RDONLY(inode))
1297 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1301 if (mode == (mode_t) -1)
1302 mode = inode->i_mode;
1303 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1304 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1305 err = notify_change(dentry, &newattrs);
1312 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1314 + struct file * file;
1321 + err = chmod_common(file->f_dentry, mode);
1326 @@ -495,30 +560,14 @@ out:
1327 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1329 struct nameidata nd;
1330 - struct inode * inode;
1332 - struct iattr newattrs;
1334 error = user_path_walk(filename, &nd);
1337 - inode = nd.dentry->d_inode;
1340 - if (IS_RDONLY(inode))
1341 - goto dput_and_out;
1344 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1345 - goto dput_and_out;
1346 + error = chmod_common(nd.dentry, mode);
1348 - if (mode == (mode_t) -1)
1349 - mode = inode->i_mode;
1350 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1351 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1352 - error = notify_change(nd.dentry, &newattrs);
1358 @@ -538,6 +587,20 @@ static int chown_common(struct dentry *
1360 if (IS_RDONLY(inode))
1363 + if (inode->i_op->setattr_raw) {
1364 + struct inode_operations *op = dentry->d_inode->i_op;
1366 + newattrs.ia_uid = user;
1367 + newattrs.ia_gid = group;
1368 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1369 + newattrs.ia_valid |= ATTR_RAW;
1370 + error = op->setattr_raw(inode, &newattrs);
1371 + /* the file system wants to use normal vfs path now */
1372 + if (error != -EOPNOTSUPP)
1377 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1379 @@ -642,6 +705,7 @@ struct file *filp_open(const char * file
1381 int namei_flags, error;
1382 struct nameidata nd;
1383 + struct lookup_intent it = { .it_op = IT_OPEN };
1385 namei_flags = flags;
1386 if ((namei_flags+1) & O_ACCMODE)
1387 @@ -649,14 +713,15 @@ struct file *filp_open(const char * file
1388 if (namei_flags & O_TRUNC)
1391 - error = open_namei(filename, namei_flags, mode, &nd);
1393 - return dentry_open(nd.dentry, nd.mnt, flags);
1394 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1396 + return ERR_PTR(error);
1398 - return ERR_PTR(error);
1399 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1402 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1403 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1404 + int flags, struct lookup_intent *it)
1407 struct inode *inode;
1408 @@ -693,12 +758,15 @@ struct file *dentry_open(struct dentry *
1411 if (f->f_op && f->f_op->open) {
1413 error = f->f_op->open(inode,f);
1418 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1420 + intent_release(it);
1424 @@ -713,11 +781,17 @@ cleanup_all:
1428 + intent_release(it);
1431 return ERR_PTR(error);
1434 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1436 + return dentry_open_it(dentry, mnt, flags, NULL);
1440 * Find an empty file descriptor entry, and mark it busy.
1442 --- linux-2.4.20-hp4-pnnl13/fs/stat.c~vfs_intent-2.4.20-hp 2001-09-14 03:04:43.000000000 +0400
1443 +++ linux-2.4.20-hp4-pnnl13-alexey/fs/stat.c 2003-09-14 17:34:07.000000000 +0400
1445 * Revalidate the inode. This is required for proper NFS attribute caching.
1447 static __inline__ int
1448 -do_revalidate(struct dentry *dentry)
1449 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1451 struct inode * inode = dentry->d_inode;
1452 - if (inode->i_op && inode->i_op->revalidate)
1455 + if (inode->i_op && inode->i_op->revalidate_it)
1456 + return inode->i_op->revalidate_it(dentry, it);
1457 + else if (inode->i_op && inode->i_op->revalidate)
1458 return inode->i_op->revalidate(dentry);
1461 @@ -135,13 +139,15 @@ static int cp_new_stat(struct inode * in
1462 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1464 struct nameidata nd;
1465 + struct lookup_intent it = { .it_op = IT_GETATTR };
1468 - error = user_path_walk(filename, &nd);
1469 + error = user_path_walk_it(filename, &nd, &it);
1471 - error = do_revalidate(nd.dentry);
1472 + error = do_revalidate(nd.dentry, &it);
1474 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1475 + intent_release(&it);
1479 @@ -151,13 +157,15 @@ asmlinkage long sys_stat(char * filename
1480 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1482 struct nameidata nd;
1483 + struct lookup_intent it = { .it_op = IT_GETATTR };
1486 - error = user_path_walk(filename, &nd);
1487 + error = user_path_walk_it(filename, &nd, &it);
1489 - error = do_revalidate(nd.dentry);
1490 + error = do_revalidate(nd.dentry, &it);
1492 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1493 + intent_release(&it);
1497 @@ -172,13 +180,15 @@ asmlinkage long sys_newstat(char * filen
1498 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1500 struct nameidata nd;
1501 + struct lookup_intent it = { .it_op = IT_GETATTR };
1504 - error = user_path_walk_link(filename, &nd);
1505 + error = user_path_walk_link_it(filename, &nd, &it);
1507 - error = do_revalidate(nd.dentry);
1508 + error = do_revalidate(nd.dentry, &it);
1510 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1511 + intent_release(&it);
1515 @@ -189,13 +199,15 @@ asmlinkage long sys_lstat(char * filenam
1516 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1518 struct nameidata nd;
1519 + struct lookup_intent it = { .it_op = IT_GETATTR };
1522 - error = user_path_walk_link(filename, &nd);
1523 + error = user_path_walk_link_it(filename, &nd, &it);
1525 - error = do_revalidate(nd.dentry);
1526 + error = do_revalidate(nd.dentry, &it);
1528 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1529 + intent_release(&it);
1533 @@ -216,7 +228,7 @@ asmlinkage long sys_fstat(unsigned int f
1535 struct dentry * dentry = f->f_dentry;
1537 - err = do_revalidate(dentry);
1538 + err = do_revalidate(dentry, NULL);
1540 err = cp_old_stat(dentry->d_inode, statbuf);
1542 @@ -235,7 +247,7 @@ asmlinkage long sys_newfstat(unsigned in
1544 struct dentry * dentry = f->f_dentry;
1546 - err = do_revalidate(dentry);
1547 + err = do_revalidate(dentry, NULL);
1549 err = cp_new_stat(dentry->d_inode, statbuf);
1551 @@ -257,7 +269,7 @@ asmlinkage long sys_readlink(const char
1554 if (inode->i_op && inode->i_op->readlink &&
1555 - !(error = do_revalidate(nd.dentry))) {
1556 + !(error = do_revalidate(nd.dentry, NULL))) {
1557 UPDATE_ATIME(inode);
1558 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1560 @@ -333,12 +345,14 @@ asmlinkage long sys_stat64(char * filena
1562 struct nameidata nd;
1564 + struct lookup_intent it = { .it_op = IT_GETATTR };
1566 - error = user_path_walk(filename, &nd);
1567 + error = user_path_walk_it(filename, &nd, &it);
1569 - error = do_revalidate(nd.dentry);
1570 + error = do_revalidate(nd.dentry, &it);
1572 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1573 + intent_release(&it);
1577 @@ -348,12 +362,14 @@ asmlinkage long sys_lstat64(char * filen
1579 struct nameidata nd;
1581 + struct lookup_intent it = { .it_op = IT_GETATTR };
1583 - error = user_path_walk_link(filename, &nd);
1584 + error = user_path_walk_link_it(filename, &nd, &it);
1586 - error = do_revalidate(nd.dentry);
1587 + error = do_revalidate(nd.dentry, &it);
1589 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1590 + intent_release(&it);
1594 @@ -368,7 +384,7 @@ asmlinkage long sys_fstat64(unsigned lon
1596 struct dentry * dentry = f->f_dentry;
1598 - err = do_revalidate(dentry);
1599 + err = do_revalidate(dentry, NULL);
1601 err = cp_new_stat64(dentry->d_inode, statbuf);
1603 --- linux-2.4.20-hp4-pnnl13/fs/proc/base.c~vfs_intent-2.4.20-hp 2003-09-13 15:19:19.000000000 +0400
1604 +++ linux-2.4.20-hp4-pnnl13-alexey/fs/proc/base.c 2003-09-14 17:33:51.000000000 +0400
1605 @@ -481,6 +481,9 @@ static int proc_pid_follow_link(struct d
1607 error = inode->u.proc_i.op.proc_get_link(inode, &nd->dentry, &nd->mnt);
1608 nd->last_type = LAST_BIND;
1610 + if (nd->intent != NULL)
1611 + nd->intent->d.lustre.it_int_flags |= IT_FL_FOLLOWED;
1615 --- linux-2.4.20-hp4-pnnl13/include/linux/dcache.h~vfs_intent-2.4.20-hp 2002-11-29 02:53:15.000000000 +0300
1616 +++ linux-2.4.20-hp4-pnnl13-alexey/include/linux/dcache.h 2003-09-14 17:33:51.000000000 +0400
1618 #include <asm/atomic.h>
1619 #include <linux/mount.h>
1620 #include <linux/kernel.h>
1621 +#include <linux/string.h>
1623 +#define IT_OPEN 0x0001
1624 +#define IT_CREAT 0x0002
1625 +#define IT_READDIR 0x0004
1626 +#define IT_GETATTR 0x0008
1627 +#define IT_LOOKUP 0x0010
1628 +#define IT_UNLINK 0x0020
1629 +#define IT_GETXATTR 0x0040
1630 +#define IT_EXEC 0x0080
1631 +#define IT_PIN 0x0100
1633 +#define IT_FL_LOCKED 0x0001
1634 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1636 +#define INTENT_MAGIC 0x19620323
1639 +struct lustre_intent_data {
1640 + int it_disposition;
1642 + __u64 it_lock_handle;
1647 +struct lookup_intent {
1649 + void (*it_op_release)(struct lookup_intent *);
1652 + int it_create_mode;
1654 + struct lustre_intent_data lustre;
1658 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1660 + memset(it, 0, sizeof(*it));
1661 + it->it_magic = INTENT_MAGIC;
1663 + it->it_flags = flags;
1668 * linux/include/linux/dcache.h
1669 @@ -91,8 +136,22 @@ struct dentry_operations {
1670 int (*d_delete)(struct dentry *);
1671 void (*d_release)(struct dentry *);
1672 void (*d_iput)(struct dentry *, struct inode *);
1673 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1674 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1675 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1678 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1679 + de->d_op->d_pin(de, mnt, flag);
1680 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1681 + de->d_op->d_unpin(de, mnt, flag);
1684 +/* defined in fs/namei.c */
1685 +extern void intent_release(struct lookup_intent *it);
1686 +/* defined in fs/dcache.c */
1687 +extern void __d_rehash(struct dentry * entry, int lock);
1689 /* the dentry parameter passed to d_hash and d_compare is the parent
1690 * directory of the entries to be compared. It is used in case these
1691 * functions need any directory specific information for determining
1692 @@ -124,6 +183,7 @@ d_iput: no no yes
1693 * s_nfsd_free_path semaphore will be down
1695 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1696 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1698 extern spinlock_t dcache_lock;
1700 --- linux-2.4.20-hp4-pnnl13/include/linux/fs.h~vfs_intent-2.4.20-hp 2003-09-14 17:33:50.000000000 +0400
1701 +++ linux-2.4.20-hp4-pnnl13-alexey/include/linux/fs.h 2003-09-14 17:33:51.000000000 +0400
1702 @@ -73,6 +73,7 @@ extern int leases_enable, dir_notify_ena
1704 #define FMODE_READ 1
1705 #define FMODE_WRITE 2
1706 +#define FMODE_EXEC 4
1710 @@ -340,6 +341,9 @@ extern void set_bh_page(struct buffer_he
1711 #define ATTR_MTIME_SET 256
1712 #define ATTR_FORCE 512 /* Not a change, but a change it */
1713 #define ATTR_ATTR_FLAG 1024
1714 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1715 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1716 +#define ATTR_CTIME_SET 0x2000
1719 * This is the Inode Attributes structure, used for notify_change(). It
1720 @@ -474,6 +478,7 @@ struct inode {
1721 struct pipe_inode_info *i_pipe;
1722 struct block_device *i_bdev;
1723 struct char_device *i_cdev;
1724 + void *i_filterdata;
1726 unsigned long i_dnotify_mask; /* Directory notify events */
1727 struct dnotify_struct *i_dnotify; /* for directory notifications */
1728 @@ -576,6 +581,7 @@ struct file {
1730 /* needed for tty driver, and maybe others */
1732 + struct lookup_intent *f_it;
1734 /* preallocated helper kiobuf to speedup O_DIRECT */
1735 struct kiobuf *f_iobuf;
1736 @@ -697,6 +703,7 @@ struct nameidata {
1740 + struct lookup_intent *intent;
1744 @@ -817,7 +824,8 @@ extern int vfs_symlink(struct inode *, s
1745 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1746 extern int vfs_rmdir(struct inode *, struct dentry *);
1747 extern int vfs_unlink(struct inode *, struct dentry *);
1748 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1749 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1750 + struct inode *new_dir, struct dentry *new_dentry);
1754 @@ -877,21 +885,32 @@ struct file_operations {
1756 struct inode_operations {
1757 int (*create) (struct inode *,struct dentry *,int);
1758 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1759 struct dentry * (*lookup) (struct inode *,struct dentry *);
1760 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1761 int (*link) (struct dentry *,struct inode *,struct dentry *);
1762 + int (*link_raw) (struct nameidata *,struct nameidata *);
1763 int (*unlink) (struct inode *,struct dentry *);
1764 + int (*unlink_raw) (struct nameidata *);
1765 int (*symlink) (struct inode *,struct dentry *,const char *);
1766 + int (*symlink_raw) (struct nameidata *,const char *);
1767 int (*mkdir) (struct inode *,struct dentry *,int);
1768 + int (*mkdir_raw) (struct nameidata *,int);
1769 int (*rmdir) (struct inode *,struct dentry *);
1770 + int (*rmdir_raw) (struct nameidata *);
1771 int (*mknod) (struct inode *,struct dentry *,int,int);
1772 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1773 int (*rename) (struct inode *, struct dentry *,
1774 struct inode *, struct dentry *);
1775 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1776 int (*readlink) (struct dentry *, char *,int);
1777 int (*follow_link) (struct dentry *, struct nameidata *);
1778 void (*truncate) (struct inode *);
1779 int (*permission) (struct inode *, int);
1780 int (*revalidate) (struct dentry *);
1781 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1782 int (*setattr) (struct dentry *, struct iattr *);
1783 + int (*setattr_raw) (struct inode *, struct iattr *);
1784 int (*getattr) (struct dentry *, struct iattr *);
1785 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
1786 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1787 @@ -1088,10 +1107,14 @@ static inline int get_lease(struct inode
1789 asmlinkage long sys_open(const char *, int, int);
1790 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1791 -extern int do_truncate(struct dentry *, loff_t start);
1792 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1794 extern struct file *filp_open(const char *, int, int);
1795 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1796 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1797 + struct nameidata *nd, struct lookup_intent *it);
1798 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1799 + int flags, struct lookup_intent *it);
1800 extern int filp_close(struct file *, fl_owner_t id);
1801 extern char * getname(const char *);
1803 @@ -1353,6 +1376,7 @@ typedef int (*read_actor_t)(read_descrip
1804 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1806 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1807 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1808 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1809 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1810 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1811 @@ -1364,6 +1388,8 @@ extern struct dentry * lookup_one_len(co
1812 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1813 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1814 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1815 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1816 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1818 extern void inode_init_once(struct inode *);
1819 extern void iput(struct inode *);
1820 @@ -1499,6 +1525,8 @@ extern struct file_operations generic_ro
1822 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1823 extern int vfs_follow_link(struct nameidata *, const char *);
1824 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1825 + struct lookup_intent *it);
1826 extern int page_readlink(struct dentry *, char *, int);
1827 extern int page_follow_link(struct dentry *, struct nameidata *);
1828 extern struct inode_operations page_symlink_inode_operations;
1829 --- linux-2.4.20-hp4-pnnl13/include/linux/fs_struct.h~vfs_intent-2.4.20-hp 2001-07-14 02:10:44.000000000 +0400
1830 +++ linux-2.4.20-hp4-pnnl13-alexey/include/linux/fs_struct.h 2003-09-14 17:33:51.000000000 +0400
1831 @@ -34,10 +34,12 @@ static inline void set_fs_root(struct fs
1832 write_lock(&fs->lock);
1833 old_root = fs->root;
1834 old_rootmnt = fs->rootmnt;
1835 + PIN(dentry, mnt, 1);
1836 fs->rootmnt = mntget(mnt);
1837 fs->root = dget(dentry);
1838 write_unlock(&fs->lock);
1840 + UNPIN(old_root, old_rootmnt, 1);
1842 mntput(old_rootmnt);
1844 @@ -57,10 +59,12 @@ static inline void set_fs_pwd(struct fs_
1845 write_lock(&fs->lock);
1847 old_pwdmnt = fs->pwdmnt;
1848 + PIN(dentry, mnt, 0);
1849 fs->pwdmnt = mntget(mnt);
1850 fs->pwd = dget(dentry);
1851 write_unlock(&fs->lock);
1853 + UNPIN(old_pwd, old_pwdmnt, 0);
1857 --- linux-2.4.20-hp4-pnnl13/kernel/ksyms.c~vfs_intent-2.4.20-hp 2003-09-14 17:33:50.000000000 +0400
1858 +++ linux-2.4.20-hp4-pnnl13-alexey/kernel/ksyms.c 2003-09-14 17:33:51.000000000 +0400
1859 @@ -296,6 +296,7 @@ EXPORT_SYMBOL(read_cache_page);
1860 EXPORT_SYMBOL(set_page_dirty);
1861 EXPORT_SYMBOL(vfs_readlink);
1862 EXPORT_SYMBOL(vfs_follow_link);
1863 +EXPORT_SYMBOL(vfs_follow_link_it);
1864 EXPORT_SYMBOL(page_readlink);
1865 EXPORT_SYMBOL(page_follow_link);
1866 EXPORT_SYMBOL(page_symlink_inode_operations);
1867 --- linux-2.4.20-hp4-pnnl13/kernel/fork.c~vfs_intent-2.4.20-hp 2003-09-13 15:19:27.000000000 +0400
1868 +++ linux-2.4.20-hp4-pnnl13-alexey/kernel/fork.c 2003-09-14 17:33:51.000000000 +0400
1869 @@ -388,10 +388,13 @@ static inline struct fs_struct *__copy_f
1870 fs->umask = old->umask;
1871 read_lock(&old->lock);
1872 fs->rootmnt = mntget(old->rootmnt);
1873 + PIN(old->pwd, old->pwdmnt, 0);
1874 + PIN(old->root, old->rootmnt, 1);
1875 fs->root = dget(old->root);
1876 fs->pwdmnt = mntget(old->pwdmnt);
1877 fs->pwd = dget(old->pwd);
1879 + PIN(old->altroot, old->altrootmnt, 1);
1880 fs->altrootmnt = mntget(old->altrootmnt);
1881 fs->altroot = dget(old->altroot);
1883 --- linux-2.4.20-hp4-pnnl13/kernel/exit.c~vfs_intent-2.4.20-hp 2003-09-13 15:19:27.000000000 +0400
1884 +++ linux-2.4.20-hp4-pnnl13-alexey/kernel/exit.c 2003-09-14 17:33:51.000000000 +0400
1885 @@ -239,11 +239,14 @@ static inline void __put_fs_struct(struc
1887 /* No need to hold fs->lock if we are killing it */
1888 if (atomic_dec_and_test(&fs->count)) {
1889 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1890 + UNPIN(fs->root, fs->rootmnt, 1);
1892 mntput(fs->rootmnt);
1896 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1898 mntput(fs->altrootmnt);