3 fs/namei.c | 295 +++++++++++++++++++++++++++++++++++++++-------
4 fs/namespace.c | 28 +++-
5 fs/open.c | 172 +++++++++++++++++++-------
6 fs/stat.c | 52 +++++---
7 include/linux/dcache.h | 60 +++++++++
8 include/linux/fs.h | 32 ++++
9 include/linux/fs_struct.h | 4
13 12 files changed, 558 insertions(+), 128 deletions(-)
15 Index: linux-2.4.24/fs/exec.c
16 ===================================================================
17 --- linux-2.4.24.orig/fs/exec.c Fri Nov 28 10:26:21 2003
18 +++ linux-2.4.24/fs/exec.c Wed Mar 17 17:36:14 2004
19 @@ -112,8 +112,10 @@ asmlinkage long sys_uselib(const char *
23 + struct lookup_intent it = { .it_op = IT_OPEN,
24 + .it_flags = FMODE_READ|FMODE_EXEC };
26 - error = user_path_walk(library, &nd);
27 + error = user_path_walk_it(library, &nd, &it);
31 @@ -125,7 +127,8 @@ asmlinkage long sys_uselib(const char *
35 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
36 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
37 + intent_release(&it);
38 error = PTR_ERR(file);
41 @@ -374,8 +377,10 @@ struct file *open_exec(const char *name)
45 + struct lookup_intent it = { .it_op = IT_OPEN,
46 + .it_flags = FMODE_READ|FMODE_EXEC };
48 - err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
49 + err = path_lookup_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
52 inode = nd.dentry->d_inode;
53 @@ -387,7 +392,8 @@ struct file *open_exec(const char *name)
57 - file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
58 + file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &it);
59 + intent_release(&it);
61 err = deny_write_access(file);
63 @@ -399,6 +405,7 @@ out:
67 + intent_release(&it);
71 @@ -1132,7 +1139,7 @@ int do_coredump(long signr, struct pt_re
73 if (!file->f_op->write)
75 - if (do_truncate(file->f_dentry, 0) != 0)
76 + if (do_truncate(file->f_dentry, 0, 0) != 0)
79 retval = binfmt->core_dump(signr, regs, file);
80 Index: linux-2.4.24/fs/dcache.c
81 ===================================================================
82 --- linux-2.4.24.orig/fs/dcache.c Fri Jun 13 07:51:37 2003
83 +++ linux-2.4.24/fs/dcache.c Wed Mar 17 17:36:14 2004
84 @@ -181,6 +181,13 @@ int d_invalidate(struct dentry * dentry)
85 spin_unlock(&dcache_lock);
89 + /* network invalidation by Lustre */
90 + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
91 + spin_unlock(&dcache_lock);
96 * Check whether to do a partial shrink_dcache
97 * to get rid of unused child entries.
98 @@ -830,13 +837,19 @@ void d_delete(struct dentry * dentry)
99 * Adds a dentry to the hash according to its name.
102 -void d_rehash(struct dentry * entry)
103 +void __d_rehash(struct dentry * entry, int lock)
105 struct list_head *list = d_hash(entry->d_parent, entry->d_name.hash);
106 if (!list_empty(&entry->d_hash)) BUG();
107 - spin_lock(&dcache_lock);
108 + if (lock) spin_lock(&dcache_lock);
109 list_add(&entry->d_hash, list);
110 - spin_unlock(&dcache_lock);
111 + if (lock) spin_unlock(&dcache_lock);
113 +EXPORT_SYMBOL(__d_rehash);
115 +void d_rehash(struct dentry * entry)
117 + __d_rehash(entry, 1);
120 #define do_switch(x,y) do { \
121 Index: linux-2.4.24/fs/namespace.c
122 ===================================================================
123 --- linux-2.4.24.orig/fs/namespace.c Fri Nov 28 10:26:21 2003
124 +++ linux-2.4.24/fs/namespace.c Wed Mar 17 17:36:14 2004
125 @@ -98,6 +98,7 @@ static void detach_mnt(struct vfsmount *
127 old_nd->dentry = mnt->mnt_mountpoint;
128 old_nd->mnt = mnt->mnt_parent;
129 + UNPIN(old_nd->dentry, old_nd->mnt, 1);
130 mnt->mnt_parent = mnt;
131 mnt->mnt_mountpoint = mnt->mnt_root;
132 list_del_init(&mnt->mnt_child);
133 @@ -109,6 +110,7 @@ static void attach_mnt(struct vfsmount *
135 mnt->mnt_parent = mntget(nd->mnt);
136 mnt->mnt_mountpoint = dget(nd->dentry);
137 + PIN(nd->dentry, nd->mnt, 1);
138 list_add(&mnt->mnt_hash, mount_hashtable+hash(nd->mnt, nd->dentry));
139 list_add_tail(&mnt->mnt_child, &nd->mnt->mnt_mounts);
140 nd->dentry->d_mounted++;
141 @@ -488,14 +490,17 @@ static int do_loopback(struct nameidata
143 struct nameidata old_nd;
144 struct vfsmount *mnt = NULL;
145 + struct lookup_intent it = { .it_op = IT_GETATTR };
146 int err = mount_is_safe(nd);
149 if (!old_name || !*old_name)
151 - err = path_lookup(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd);
153 + err = path_lookup_it(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd, &it);
155 + intent_release(&it);
159 down_write(¤t->namespace->sem);
161 @@ -518,6 +523,7 @@ static int do_loopback(struct nameidata
164 up_write(¤t->namespace->sem);
165 + intent_release(&it);
166 path_release(&old_nd);
169 @@ -701,6 +707,7 @@ long do_mount(char * dev_name, char * di
170 unsigned long flags, void *data_page)
173 + struct lookup_intent it = { .it_op = IT_GETATTR };
177 @@ -725,10 +732,11 @@ long do_mount(char * dev_name, char * di
178 flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV);
180 /* ... and get the mountpoint */
181 - retval = path_lookup(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd);
183 + retval = path_lookup_it(dir_name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, &nd, &it);
185 + intent_release(&it);
189 if (flags & MS_REMOUNT)
190 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
192 @@ -739,6 +747,8 @@ long do_mount(char * dev_name, char * di
194 retval = do_add_mount(&nd, type_page, flags, mnt_flags,
195 dev_name, data_page);
197 + intent_release(&it);
201 @@ -904,6 +914,8 @@ asmlinkage long sys_pivot_root(const cha
203 struct vfsmount *tmp;
204 struct nameidata new_nd, old_nd, parent_nd, root_parent, user_nd;
205 + struct lookup_intent new_it = { .it_op = IT_GETATTR };
206 + struct lookup_intent old_it = { .it_op = IT_GETATTR };
209 if (!capable(CAP_SYS_ADMIN))
210 @@ -911,14 +923,14 @@ asmlinkage long sys_pivot_root(const cha
214 - error = __user_walk(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd);
215 + error = __user_walk_it(new_root, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &new_nd, &new_it);
219 if (!check_mnt(new_nd.mnt))
222 - error = __user_walk(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd);
223 + error = __user_walk_it(put_old, LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &old_nd, &old_it);
227 @@ -973,8 +985,10 @@ out2:
228 up(&old_nd.dentry->d_inode->i_zombie);
229 up_write(¤t->namespace->sem);
230 path_release(&user_nd);
231 + intent_release(&old_it);
232 path_release(&old_nd);
234 + intent_release(&new_it);
235 path_release(&new_nd);
238 Index: linux-2.4.24/fs/namei.c
239 ===================================================================
240 --- linux-2.4.24.orig/fs/namei.c Mon Aug 25 04:44:43 2003
241 +++ linux-2.4.24/fs/namei.c Wed Mar 17 17:36:52 2004
243 * XEmacs seems to be relying on it...
246 +void intent_release(struct lookup_intent *it)
248 + if (it && it->it_op_release)
249 + it->it_op_release(it);
253 /* In order to reduce some races, while at the same time doing additional
254 * checking and hopefully speeding things up, we copy filenames to the
255 * kernel data space before using them..
256 @@ -260,10 +267,19 @@ void path_release(struct nameidata *nd)
257 * Internal lookup() using the new generic dcache.
260 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
261 +static struct dentry *cached_lookup(struct dentry *parent, struct qstr *name,
262 + int flags, struct lookup_intent *it)
264 struct dentry * dentry = d_lookup(parent, name);
266 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
267 + if (!dentry->d_op->d_revalidate_it(dentry, flags, it) &&
268 + !d_invalidate(dentry)) {
274 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
275 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
277 @@ -281,11 +297,15 @@ static struct dentry * cached_lookup(str
278 * make sure that nobody added the entry to the dcache in the meantime..
281 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
282 +static struct dentry *real_lookup(struct dentry *parent, struct qstr *name,
283 + int flags, struct lookup_intent *it)
285 struct dentry * result;
286 struct inode *dir = parent->d_inode;
293 * First re-do the cached lookup just in case it was created
294 @@ -300,6 +320,9 @@ static struct dentry * real_lookup(struc
295 result = ERR_PTR(-ENOMEM);
298 + if (dir->i_op->lookup_it)
299 + result = dir->i_op->lookup_it(dir, dentry, it, flags);
301 result = dir->i_op->lookup(dir, dentry);
304 @@ -321,6 +344,15 @@ static struct dentry * real_lookup(struc
306 result = ERR_PTR(-ENOENT);
308 + } else if (result->d_op && result->d_op->d_revalidate_it) {
309 + if (!result->d_op->d_revalidate_it(result, flags, it) &&
310 + !d_invalidate(result)) {
313 + result = ERR_PTR(-ESTALE);
314 + if (!IS_ERR(result))
320 @@ -332,7 +364,8 @@ static struct dentry * real_lookup(struc
321 * Without that kind of total limit, nasty chains of consecutive
322 * symlinks can cause almost arbitrarily long lookups.
324 -static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
325 +static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd,
326 + struct lookup_intent *it)
329 if (current->link_count >= 5)
330 @@ -346,10 +379,12 @@ static inline int do_follow_link(struct
331 current->link_count++;
332 current->total_link_count++;
333 UPDATE_ATIME(dentry->d_inode);
335 err = dentry->d_inode->i_op->follow_link(dentry, nd);
336 current->link_count--;
339 + intent_release(it);
343 @@ -447,7 +482,8 @@ static inline void follow_dotdot(struct
345 * We expect 'base' to be positive and a directory.
347 -int link_path_walk(const char * name, struct nameidata *nd)
348 +int link_path_walk_it(const char *name, struct nameidata *nd,
349 + struct lookup_intent *it)
351 struct dentry *dentry;
353 @@ -520,9 +556,9 @@ int link_path_walk(const char * name, st
356 /* This does the actual lookups.. */
357 - dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
358 + dentry = cached_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
360 - dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE);
361 + dentry = real_lookup(nd->dentry, &this, LOOKUP_CONTINUE, NULL);
362 err = PTR_ERR(dentry);
365 @@ -540,7 +576,7 @@ int link_path_walk(const char * name, st
368 if (inode->i_op->follow_link) {
369 - err = do_follow_link(dentry, nd);
370 + err = do_follow_link(dentry, nd, NULL);
374 @@ -556,7 +592,7 @@ int link_path_walk(const char * name, st
378 - if (!inode->i_op->lookup)
379 + if (!inode->i_op->lookup && !inode->i_op->lookup_it)
382 /* here ends the main loop */
383 @@ -583,9 +619,9 @@ last_component:
387 - dentry = cached_lookup(nd->dentry, &this, 0);
388 + dentry = cached_lookup(nd->dentry, &this, 0, it);
390 - dentry = real_lookup(nd->dentry, &this, 0);
391 + dentry = real_lookup(nd->dentry, &this, 0, it);
392 err = PTR_ERR(dentry);
395 @@ -595,7 +631,7 @@ last_component:
396 inode = dentry->d_inode;
397 if ((lookup_flags & LOOKUP_FOLLOW)
398 && inode && inode->i_op && inode->i_op->follow_link) {
399 - err = do_follow_link(dentry, nd);
400 + err = do_follow_link(dentry, nd, it);
404 @@ -609,7 +645,8 @@ last_component:
406 if (lookup_flags & LOOKUP_DIRECTORY) {
408 - if (!inode->i_op || !inode->i_op->lookup)
409 + if (!inode->i_op ||
410 + (!inode->i_op->lookup && !inode->i_op->lookup_it))
414 @@ -635,6 +672,27 @@ return_reval:
415 * Check the cached dentry for staleness.
418 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
420 + if (!dentry->d_op->d_revalidate_it(dentry, 0, it)) {
421 + struct dentry *new;
422 + err = permission(dentry->d_parent->d_inode,
426 + new = real_lookup(dentry->d_parent,
427 + &dentry->d_name, 0, NULL);
428 + d_invalidate(dentry);
431 + err = PTR_ERR(new);
436 + if (!nd->dentry->d_inode)
439 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
441 if (!dentry->d_op->d_revalidate(dentry, 0)) {
442 @@ -648,15 +706,28 @@ out_dput:
447 + intent_release(it);
453 +int link_path_walk(const char * name, struct nameidata *nd)
455 + return link_path_walk_it(name, nd, NULL);
458 +int path_walk_it(const char * name, struct nameidata *nd, struct lookup_intent *it)
460 + current->total_link_count = 0;
461 + return link_path_walk_it(name, nd, it);
464 int path_walk(const char * name, struct nameidata *nd)
466 current->total_link_count = 0;
467 - return link_path_walk(name, nd);
468 + return link_path_walk_it(name, nd, NULL);
472 @@ -741,6 +812,17 @@ walk_init_root(const char *name, struct
476 +int path_lookup_it(const char *path, unsigned flags, struct nameidata *nd,
477 + struct lookup_intent *it)
480 + if (path_init(path, flags, nd))
481 + error = path_walk_it(path, nd, it);
487 int path_lookup(const char *path, unsigned flags, struct nameidata *nd)
490 @@ -755,6 +837,7 @@ int path_init(const char *name, unsigned
492 nd->last_type = LAST_ROOT; /* if there are only slashes... */
496 return walk_init_root(name,nd);
497 read_lock(¤t->fs->lock);
498 @@ -769,7 +852,8 @@ int path_init(const char *name, unsigned
499 * needs parent already locked. Doesn't follow mounts.
502 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
503 +struct dentry * lookup_hash_it(struct qstr *name, struct dentry * base,
504 + struct lookup_intent *it)
506 struct dentry * dentry;
508 @@ -792,13 +876,16 @@ struct dentry * lookup_hash(struct qstr
512 - dentry = cached_lookup(base, name, 0);
513 + dentry = cached_lookup(base, name, 0, it);
515 struct dentry *new = d_alloc(base, name);
516 dentry = ERR_PTR(-ENOMEM);
520 + if (inode->i_op->lookup_it)
521 + dentry = inode->i_op->lookup_it(inode, new, it, 0);
523 dentry = inode->i_op->lookup(inode, new);
526 @@ -810,6 +897,12 @@ out:
530 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
532 + return lookup_hash_it(name, base, NULL);
537 struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
539 @@ -831,7 +924,7 @@ struct dentry * lookup_one_len(const cha
541 this.hash = end_name_hash(hash);
543 - return lookup_hash(&this, base);
544 + return lookup_hash_it(&this, base, NULL);
546 return ERR_PTR(-EACCES);
548 @@ -862,6 +955,23 @@ int __user_walk(const char *name, unsign
552 +int __user_walk_it(const char *name, unsigned flags, struct nameidata *nd,
553 + struct lookup_intent *it)
558 + tmp = getname(name);
559 + err = PTR_ERR(tmp);
560 + if (!IS_ERR(tmp)) {
562 + if (path_init(tmp, flags, nd))
563 + err = path_walk_it(tmp, nd, it);
570 * It's inline, so penalty for filesystems that don't use sticky bit is
572 @@ -957,7 +1067,8 @@ static inline int lookup_flags(unsigned
576 -int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
577 +static int vfs_create_it(struct inode *dir, struct dentry *dentry, int mode,
578 + struct lookup_intent *it)
582 @@ -970,12 +1081,15 @@ int vfs_create(struct inode *dir, struct
585 error = -EACCES; /* shouldn't it be ENOSYS? */
586 - if (!dir->i_op || !dir->i_op->create)
587 + if (!dir->i_op || (!dir->i_op->create && !dir->i_op->create_it))
592 - error = dir->i_op->create(dir, dentry, mode);
593 + if (dir->i_op->create_it)
594 + error = dir->i_op->create_it(dir, dentry, mode, it);
596 + error = dir->i_op->create(dir, dentry, mode);
600 @@ -984,6 +1098,11 @@ exit_lock:
604 +int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
606 + return vfs_create_it(dir, dentry, mode, NULL);
612 @@ -998,7 +1117,8 @@ exit_lock:
613 * for symlinks (where the permissions are checked later).
616 -int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
617 +int open_namei_it(const char *pathname, int flag, int mode,
618 + struct nameidata *nd, struct lookup_intent *it)
620 int acc_mode, error = 0;
622 @@ -1008,11 +1128,14 @@ int open_namei(const char * pathname, in
624 acc_mode = ACC_MODE(flag);
627 + it->it_flags = flag;
630 * The simplest case - just a plain lookup.
632 if (!(flag & O_CREAT)) {
633 - error = path_lookup(pathname, lookup_flags(flag), nd);
634 + error = path_lookup_it(pathname, lookup_flags(flag), nd, it);
638 @@ -1022,6 +1145,10 @@ int open_namei(const char * pathname, in
640 * Create - we need to know the parent.
643 + it->it_create_mode = mode;
644 + it->it_op |= IT_CREAT;
646 error = path_lookup(pathname, LOOKUP_PARENT, nd);
649 @@ -1037,7 +1164,7 @@ int open_namei(const char * pathname, in
652 down(&dir->d_inode->i_sem);
653 - dentry = lookup_hash(&nd->last, nd->dentry);
654 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
657 error = PTR_ERR(dentry);
658 @@ -1046,10 +1173,11 @@ do_last:
662 + it->it_create_mode = mode;
663 /* Negative dentry, just create the file */
664 if (!dentry->d_inode) {
665 - error = vfs_create(dir->d_inode, dentry,
666 - mode & ~current->fs->umask);
667 + error = vfs_create_it(dir->d_inode, dentry,
668 + mode & ~current->fs->umask, it);
669 up(&dir->d_inode->i_sem);
672 @@ -1153,7 +1281,7 @@ ok:
676 - error = do_truncate(dentry, 0);
677 + error = do_truncate(dentry, 0, 1);
679 put_write_access(inode);
681 @@ -1165,8 +1293,10 @@ ok:
685 + intent_release(it);
688 + intent_release(it);
692 @@ -1185,7 +1315,10 @@ do_link:
693 * are done. Procfs-like symlinks just set LAST_BIND.
695 UPDATE_ATIME(dentry->d_inode);
697 error = dentry->d_inode->i_op->follow_link(dentry, nd);
699 + intent_release(it);
703 @@ -1207,13 +1340,20 @@ do_link:
706 down(&dir->d_inode->i_sem);
707 - dentry = lookup_hash(&nd->last, nd->dentry);
708 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
709 putname(nd->last.name);
713 +int open_namei(const char *pathname, int flag, int mode, struct nameidata *nd)
715 + return open_namei_it(pathname, flag, mode, nd, NULL);
720 -static struct dentry *lookup_create(struct nameidata *nd, int is_dir)
721 +static struct dentry *lookup_create(struct nameidata *nd, int is_dir,
722 + struct lookup_intent *it)
724 struct dentry *dentry;
726 @@ -1221,7 +1361,7 @@ static struct dentry *lookup_create(stru
727 dentry = ERR_PTR(-EEXIST);
728 if (nd->last_type != LAST_NORM)
730 - dentry = lookup_hash(&nd->last, nd->dentry);
731 + dentry = lookup_hash_it(&nd->last, nd->dentry, it);
734 if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
735 @@ -1277,7 +1417,20 @@ asmlinkage long sys_mknod(const char * f
736 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
739 - dentry = lookup_create(&nd, 0);
741 + if (nd.last_type != LAST_NORM) {
745 + if (nd.dentry->d_inode->i_op->mknod_raw) {
746 + struct inode_operations *op = nd.dentry->d_inode->i_op;
747 + error = op->mknod_raw(&nd, mode, dev);
748 + /* the file system wants to use normal vfs path now */
749 + if (error != -EOPNOTSUPP)
753 + dentry = lookup_create(&nd, 0, NULL);
754 error = PTR_ERR(dentry);
756 mode &= ~current->fs->umask;
757 @@ -1298,6 +1451,7 @@ asmlinkage long sys_mknod(const char * f
760 up(&nd.dentry->d_inode->i_sem);
765 @@ -1345,7 +1499,18 @@ asmlinkage long sys_mkdir(const char * p
766 error = path_lookup(tmp, LOOKUP_PARENT, &nd);
769 - dentry = lookup_create(&nd, 1);
770 + if (nd.last_type != LAST_NORM) {
774 + if (nd.dentry->d_inode->i_op->mkdir_raw) {
775 + struct inode_operations *op = nd.dentry->d_inode->i_op;
776 + error = op->mkdir_raw(&nd, mode);
777 + /* the file system wants to use normal vfs path now */
778 + if (error != -EOPNOTSUPP)
781 + dentry = lookup_create(&nd, 1, NULL);
782 error = PTR_ERR(dentry);
783 if (!IS_ERR(dentry)) {
784 error = vfs_mkdir(nd.dentry->d_inode, dentry,
785 @@ -1353,6 +1518,7 @@ asmlinkage long sys_mkdir(const char * p
788 up(&nd.dentry->d_inode->i_sem);
793 @@ -1453,8 +1619,16 @@ asmlinkage long sys_rmdir(const char * p
797 + if (nd.dentry->d_inode->i_op->rmdir_raw) {
798 + struct inode_operations *op = nd.dentry->d_inode->i_op;
800 + error = op->rmdir_raw(&nd);
801 + /* the file system wants to use normal vfs path now */
802 + if (error != -EOPNOTSUPP)
805 down(&nd.dentry->d_inode->i_sem);
806 - dentry = lookup_hash(&nd.last, nd.dentry);
807 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
808 error = PTR_ERR(dentry);
809 if (!IS_ERR(dentry)) {
810 error = vfs_rmdir(nd.dentry->d_inode, dentry);
811 @@ -1512,8 +1686,15 @@ asmlinkage long sys_unlink(const char *
813 if (nd.last_type != LAST_NORM)
815 + if (nd.dentry->d_inode->i_op->unlink_raw) {
816 + struct inode_operations *op = nd.dentry->d_inode->i_op;
817 + error = op->unlink_raw(&nd);
818 + /* the file system wants to use normal vfs path now */
819 + if (error != -EOPNOTSUPP)
822 down(&nd.dentry->d_inode->i_sem);
823 - dentry = lookup_hash(&nd.last, nd.dentry);
824 + dentry = lookup_hash_it(&nd.last, nd.dentry, NULL);
825 error = PTR_ERR(dentry);
826 if (!IS_ERR(dentry)) {
827 /* Why not before? Because we want correct error value */
828 @@ -1580,15 +1761,27 @@ asmlinkage long sys_symlink(const char *
829 error = path_lookup(to, LOOKUP_PARENT, &nd);
832 - dentry = lookup_create(&nd, 0);
833 + if (nd.last_type != LAST_NORM) {
837 + if (nd.dentry->d_inode->i_op->symlink_raw) {
838 + struct inode_operations *op = nd.dentry->d_inode->i_op;
839 + error = op->symlink_raw(&nd, from);
840 + /* the file system wants to use normal vfs path now */
841 + if (error != -EOPNOTSUPP)
844 + dentry = lookup_create(&nd, 0, NULL);
845 error = PTR_ERR(dentry);
846 if (!IS_ERR(dentry)) {
847 error = vfs_symlink(nd.dentry->d_inode, dentry, from);
850 up(&nd.dentry->d_inode->i_sem);
858 @@ -1664,7 +1857,18 @@ asmlinkage long sys_link(const char * ol
860 if (old_nd.mnt != nd.mnt)
862 - new_dentry = lookup_create(&nd, 0);
863 + if (nd.last_type != LAST_NORM) {
867 + if (nd.dentry->d_inode->i_op->link_raw) {
868 + struct inode_operations *op = nd.dentry->d_inode->i_op;
869 + error = op->link_raw(&old_nd, &nd);
870 + /* the file system wants to use normal vfs path now */
871 + if (error != -EOPNOTSUPP)
874 + new_dentry = lookup_create(&nd, 0, NULL);
875 error = PTR_ERR(new_dentry);
876 if (!IS_ERR(new_dentry)) {
877 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
878 @@ -1708,7 +1912,7 @@ exit:
881 int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
882 - struct inode *new_dir, struct dentry *new_dentry)
883 + struct inode *new_dir, struct dentry *new_dentry)
886 struct inode *target;
887 @@ -1787,7 +1991,7 @@ out_unlock:
890 int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
891 - struct inode *new_dir, struct dentry *new_dentry)
892 + struct inode *new_dir, struct dentry *new_dentry)
896 @@ -1875,9 +2079,18 @@ static inline int do_rename(const char *
897 if (newnd.last_type != LAST_NORM)
900 + if (old_dir->d_inode->i_op->rename_raw) {
902 + error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
904 + /* the file system wants to use normal vfs path now */
905 + if (error != -EOPNOTSUPP)
909 double_lock(new_dir, old_dir);
911 - old_dentry = lookup_hash(&oldnd.last, old_dir);
912 + old_dentry = lookup_hash_it(&oldnd.last, old_dir, NULL);
913 error = PTR_ERR(old_dentry);
914 if (IS_ERR(old_dentry))
916 @@ -1893,16 +2106,16 @@ static inline int do_rename(const char *
917 if (newnd.last.name[newnd.last.len])
920 - new_dentry = lookup_hash(&newnd.last, new_dir);
921 + new_dentry = lookup_hash_it(&newnd.last, new_dir, NULL);
922 error = PTR_ERR(new_dentry);
923 if (IS_ERR(new_dentry))
928 error = vfs_rename(old_dir->d_inode, old_dentry,
929 new_dir->d_inode, new_dentry);
935 @@ -1953,20 +2166,26 @@ out:
939 -__vfs_follow_link(struct nameidata *nd, const char *link)
940 +__vfs_follow_link(struct nameidata *nd, const char *link,
941 + struct lookup_intent *it)
950 + else if (it != nd->intent)
951 + printk("it != nd->intent: tell phil@clusterfs.com\n");
955 if (!walk_init_root(link, nd))
956 /* weird __emul_prefix() stuff did it */
959 - res = link_path_walk(link, nd);
960 + res = link_path_walk_it(link, nd, it);
962 if (current->link_count || res || nd->last_type!=LAST_NORM)
964 @@ -1990,7 +2209,13 @@ fail:
966 int vfs_follow_link(struct nameidata *nd, const char *link)
968 - return __vfs_follow_link(nd, link);
969 + return __vfs_follow_link(nd, link, NULL);
972 +int vfs_follow_link_it(struct nameidata *nd, const char *link,
973 + struct lookup_intent *it)
975 + return __vfs_follow_link(nd, link, it);
978 /* get the link contents into pagecache */
979 @@ -2032,7 +2257,7 @@ int page_follow_link(struct dentry *dent
981 struct page *page = NULL;
982 char *s = page_getlink(dentry, &page);
983 - int res = __vfs_follow_link(nd, s);
984 + int res = __vfs_follow_link(nd, s, NULL);
987 page_cache_release(page);
988 Index: linux-2.4.24/fs/open.c
989 ===================================================================
990 --- linux-2.4.24.orig/fs/open.c Mon Aug 25 04:44:43 2003
991 +++ linux-2.4.24/fs/open.c Wed Mar 17 17:36:14 2004
993 #include <asm/uaccess.h>
995 #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
996 +extern int path_walk_it(const char *name, struct nameidata *nd,
997 + struct lookup_intent *it);
999 int vfs_statfs(struct super_block *sb, struct statfs *buf)
1001 @@ -95,9 +97,10 @@ void fd_install(unsigned int fd, struct
1002 write_unlock(&files->file_lock);
1005 -int do_truncate(struct dentry *dentry, loff_t length)
1006 +int do_truncate(struct dentry *dentry, loff_t length, int called_from_open)
1008 struct inode *inode = dentry->d_inode;
1009 + struct inode_operations *op = dentry->d_inode->i_op;
1011 struct iattr newattrs;
1013 @@ -109,7 +112,13 @@ int do_truncate(struct dentry *dentry, l
1014 down(&inode->i_sem);
1015 newattrs.ia_size = length;
1016 newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
1017 - error = notify_change(dentry, &newattrs);
1018 + if (called_from_open)
1019 + newattrs.ia_valid |= ATTR_FROM_OPEN;
1020 + if (op->setattr_raw) {
1021 + newattrs.ia_valid |= ATTR_RAW;
1022 + error = op->setattr_raw(inode, &newattrs);
1024 + error = notify_change(dentry, &newattrs);
1026 up_write(&inode->i_alloc_sem);
1028 @@ -120,12 +129,13 @@ static inline long do_sys_truncate(const
1029 struct nameidata nd;
1030 struct inode * inode;
1032 + struct lookup_intent it = { .it_op = IT_GETATTR };
1035 if (length < 0) /* sorry, but loff_t says... */
1038 - error = user_path_walk(path, &nd);
1039 + error = user_path_walk_it(path, &nd, &it);
1042 inode = nd.dentry->d_inode;
1043 @@ -165,11 +175,13 @@ static inline long do_sys_truncate(const
1044 error = locks_verify_truncate(inode, NULL, length);
1047 - error = do_truncate(nd.dentry, length);
1048 + intent_release(&it);
1049 + error = do_truncate(nd.dentry, length, 0);
1051 put_write_access(inode);
1054 + intent_release(&it);
1058 @@ -217,7 +229,7 @@ static inline long do_sys_ftruncate(unsi
1060 error = locks_verify_truncate(inode, file, length);
1062 - error = do_truncate(dentry, length);
1063 + error = do_truncate(dentry, length, 0);
1067 @@ -262,11 +274,13 @@ asmlinkage long sys_utime(char * filenam
1068 struct inode * inode;
1069 struct iattr newattrs;
1071 - error = user_path_walk(filename, &nd);
1072 + error = user_path_walk_it(filename, &nd, NULL);
1075 inode = nd.dentry->d_inode;
1077 + /* this is safe without a Lustre lock because it only depends
1078 + on the super block */
1080 if (IS_RDONLY(inode))
1082 @@ -281,11 +295,25 @@ asmlinkage long sys_utime(char * filenam
1085 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1089 + if (inode->i_op->setattr_raw) {
1090 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1092 + newattrs.ia_valid |= ATTR_RAW;
1093 + error = op->setattr_raw(inode, &newattrs);
1094 + /* the file system wants to use normal vfs path now */
1095 + if (error != -EOPNOTSUPP)
1096 + goto dput_and_out;
1101 if (current->fsuid != inode->i_uid &&
1102 (error = permission(inode,MAY_WRITE)) != 0)
1106 error = notify_change(nd.dentry, &newattrs);
1109 @@ -306,12 +334,14 @@ asmlinkage long sys_utimes(char * filena
1110 struct inode * inode;
1111 struct iattr newattrs;
1113 - error = user_path_walk(filename, &nd);
1114 + error = user_path_walk_it(filename, &nd, NULL);
1118 inode = nd.dentry->d_inode;
1120 + /* this is safe without a Lustre lock because it only depends
1121 + on the super block */
1123 if (IS_RDONLY(inode))
1125 @@ -326,7 +356,20 @@ asmlinkage long sys_utimes(char * filena
1126 newattrs.ia_atime = times[0].tv_sec;
1127 newattrs.ia_mtime = times[1].tv_sec;
1128 newattrs.ia_valid |= ATTR_ATIME_SET | ATTR_MTIME_SET;
1132 + if (inode->i_op->setattr_raw) {
1133 + struct inode_operations *op = nd.dentry->d_inode->i_op;
1135 + newattrs.ia_valid |= ATTR_RAW;
1136 + error = op->setattr_raw(inode, &newattrs);
1137 + /* the file system wants to use normal vfs path now */
1138 + if (error != -EOPNOTSUPP)
1139 + goto dput_and_out;
1144 if (current->fsuid != inode->i_uid &&
1145 (error = permission(inode,MAY_WRITE)) != 0)
1147 @@ -349,6 +392,7 @@ asmlinkage long sys_access(const char *
1148 int old_fsuid, old_fsgid;
1149 kernel_cap_t old_cap;
1151 + struct lookup_intent it = { .it_op = IT_GETATTR };
1153 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
1155 @@ -366,13 +410,14 @@ asmlinkage long sys_access(const char *
1157 current->cap_effective = current->cap_permitted;
1159 - res = user_path_walk(filename, &nd);
1160 + res = user_path_walk_it(filename, &nd, &it);
1162 res = permission(nd.dentry->d_inode, mode);
1163 /* SuS v2 requires we report a read only fs too */
1164 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
1165 && !special_file(nd.dentry->d_inode->i_mode))
1167 + intent_release(&it);
1171 @@ -387,8 +432,9 @@ asmlinkage long sys_chdir(const char * f
1174 struct nameidata nd;
1175 + struct lookup_intent it = { .it_op = IT_GETATTR };
1177 - error = __user_walk(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd);
1178 + error = __user_walk_it(filename,LOOKUP_POSITIVE|LOOKUP_FOLLOW|LOOKUP_DIRECTORY,&nd, &it);
1182 @@ -399,6 +445,7 @@ asmlinkage long sys_chdir(const char * f
1183 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
1186 + intent_release(&it);
1190 @@ -438,9 +485,10 @@ asmlinkage long sys_chroot(const char *
1193 struct nameidata nd;
1194 + struct lookup_intent it = { .it_op = IT_GETATTR };
1196 - error = __user_walk(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1197 - LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
1198 + error = __user_walk_it(filename, LOOKUP_POSITIVE | LOOKUP_FOLLOW |
1199 + LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd, &it);
1203 @@ -456,39 +504,56 @@ asmlinkage long sys_chroot(const char *
1207 + intent_release(&it);
1213 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1214 +int chmod_common(struct dentry *dentry, mode_t mode)
1216 - struct inode * inode;
1217 - struct dentry * dentry;
1218 - struct file * file;
1220 + struct inode *inode = dentry->d_inode;
1221 struct iattr newattrs;
1226 + if (IS_RDONLY(inode))
1229 - dentry = file->f_dentry;
1230 - inode = dentry->d_inode;
1231 + if (inode->i_op->setattr_raw) {
1232 + newattrs.ia_mode = mode;
1233 + newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1234 + newattrs.ia_valid |= ATTR_RAW;
1235 + err = inode->i_op->setattr_raw(inode, &newattrs);
1236 + /* the file system wants to use normal vfs path now */
1237 + if (err != -EOPNOTSUPP)
1242 - if (IS_RDONLY(inode))
1245 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1249 if (mode == (mode_t) -1)
1250 mode = inode->i_mode;
1251 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1252 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1253 err = notify_change(dentry, &newattrs);
1260 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
1262 + struct file * file;
1269 + err = chmod_common(file->f_dentry, mode);
1274 @@ -497,30 +562,14 @@ out:
1275 asmlinkage long sys_chmod(const char * filename, mode_t mode)
1277 struct nameidata nd;
1278 - struct inode * inode;
1280 - struct iattr newattrs;
1282 error = user_path_walk(filename, &nd);
1285 - inode = nd.dentry->d_inode;
1288 - if (IS_RDONLY(inode))
1289 - goto dput_and_out;
1292 - if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1293 - goto dput_and_out;
1294 + error = chmod_common(nd.dentry, mode);
1296 - if (mode == (mode_t) -1)
1297 - mode = inode->i_mode;
1298 - newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
1299 - newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
1300 - error = notify_change(nd.dentry, &newattrs);
1306 @@ -540,6 +589,20 @@ static int chown_common(struct dentry *
1308 if (IS_RDONLY(inode))
1311 + if (inode->i_op->setattr_raw) {
1312 + struct inode_operations *op = dentry->d_inode->i_op;
1314 + newattrs.ia_uid = user;
1315 + newattrs.ia_gid = group;
1316 + newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
1317 + newattrs.ia_valid |= ATTR_RAW;
1318 + error = op->setattr_raw(inode, &newattrs);
1319 + /* the file system wants to use normal vfs path now */
1320 + if (error != -EOPNOTSUPP)
1325 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1327 @@ -644,6 +707,7 @@ struct file *filp_open(const char * file
1329 int namei_flags, error;
1330 struct nameidata nd;
1331 + struct lookup_intent it = { .it_op = IT_OPEN };
1333 namei_flags = flags;
1334 if ((namei_flags+1) & O_ACCMODE)
1335 @@ -651,14 +715,15 @@ struct file *filp_open(const char * file
1336 if (namei_flags & O_TRUNC)
1339 - error = open_namei(filename, namei_flags, mode, &nd);
1341 - return dentry_open(nd.dentry, nd.mnt, flags);
1342 + error = open_namei_it(filename, namei_flags, mode, &nd, &it);
1344 + return ERR_PTR(error);
1346 - return ERR_PTR(error);
1347 + return dentry_open_it(nd.dentry, nd.mnt, flags, &it);
1350 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1351 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1352 + int flags, struct lookup_intent *it)
1355 struct inode *inode;
1356 @@ -695,12 +760,15 @@ struct file *dentry_open(struct dentry *
1359 if (f->f_op && f->f_op->open) {
1361 error = f->f_op->open(inode,f);
1366 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
1368 + intent_release(it);
1372 @@ -715,11 +783,17 @@ cleanup_all:
1376 + intent_release(it);
1379 return ERR_PTR(error);
1382 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
1384 + return dentry_open_it(dentry, mnt, flags, NULL);
1388 * Find an empty file descriptor entry, and mark it busy.
1390 Index: linux-2.4.24/fs/stat.c
1391 ===================================================================
1392 --- linux-2.4.24.orig/fs/stat.c Mon Aug 25 04:44:43 2003
1393 +++ linux-2.4.24/fs/stat.c Wed Mar 17 17:36:52 2004
1395 * Revalidate the inode. This is required for proper NFS attribute caching.
1397 static __inline__ int
1398 -do_revalidate(struct dentry *dentry)
1399 +do_revalidate(struct dentry *dentry, struct lookup_intent *it)
1401 struct inode * inode = dentry->d_inode;
1402 - if (inode->i_op && inode->i_op->revalidate)
1403 + if (inode->i_op && inode->i_op->revalidate_it)
1404 + return inode->i_op->revalidate_it(dentry, it);
1405 + else if (inode->i_op && inode->i_op->revalidate)
1406 return inode->i_op->revalidate(dentry);
1409 @@ -137,13 +139,15 @@ static int cp_new_stat(struct inode * in
1410 asmlinkage long sys_stat(char * filename, struct __old_kernel_stat * statbuf)
1412 struct nameidata nd;
1413 + struct lookup_intent it = { .it_op = IT_GETATTR };
1416 - error = user_path_walk(filename, &nd);
1417 + error = user_path_walk_it(filename, &nd, &it);
1419 - error = do_revalidate(nd.dentry);
1420 + error = do_revalidate(nd.dentry, &it);
1422 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1423 + intent_release(&it);
1427 @@ -153,13 +157,15 @@ asmlinkage long sys_stat(char * filename
1428 asmlinkage long sys_newstat(char * filename, struct stat * statbuf)
1430 struct nameidata nd;
1431 + struct lookup_intent it = { .it_op = IT_GETATTR };
1434 - error = user_path_walk(filename, &nd);
1435 + error = user_path_walk_it(filename, &nd, &it);
1437 - error = do_revalidate(nd.dentry);
1438 + error = do_revalidate(nd.dentry, &it);
1440 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1441 + intent_release(&it);
1445 @@ -174,13 +180,15 @@ asmlinkage long sys_newstat(char * filen
1446 asmlinkage long sys_lstat(char * filename, struct __old_kernel_stat * statbuf)
1448 struct nameidata nd;
1449 + struct lookup_intent it = { .it_op = IT_GETATTR };
1452 - error = user_path_walk_link(filename, &nd);
1453 + error = user_path_walk_link_it(filename, &nd, &it);
1455 - error = do_revalidate(nd.dentry);
1456 + error = do_revalidate(nd.dentry, &it);
1458 error = cp_old_stat(nd.dentry->d_inode, statbuf);
1459 + intent_release(&it);
1463 @@ -191,13 +199,15 @@ asmlinkage long sys_lstat(char * filenam
1464 asmlinkage long sys_newlstat(char * filename, struct stat * statbuf)
1466 struct nameidata nd;
1467 + struct lookup_intent it = { .it_op = IT_GETATTR };
1470 - error = user_path_walk_link(filename, &nd);
1471 + error = user_path_walk_link_it(filename, &nd, &it);
1473 - error = do_revalidate(nd.dentry);
1474 + error = do_revalidate(nd.dentry, &it);
1476 error = cp_new_stat(nd.dentry->d_inode, statbuf);
1477 + intent_release(&it);
1481 @@ -218,7 +228,7 @@ asmlinkage long sys_fstat(unsigned int f
1483 struct dentry * dentry = f->f_dentry;
1485 - err = do_revalidate(dentry);
1486 + err = do_revalidate(dentry, NULL);
1488 err = cp_old_stat(dentry->d_inode, statbuf);
1490 @@ -237,7 +247,7 @@ asmlinkage long sys_newfstat(unsigned in
1492 struct dentry * dentry = f->f_dentry;
1494 - err = do_revalidate(dentry);
1495 + err = do_revalidate(dentry, NULL);
1497 err = cp_new_stat(dentry->d_inode, statbuf);
1499 @@ -259,7 +269,7 @@ asmlinkage long sys_readlink(const char
1502 if (inode->i_op && inode->i_op->readlink &&
1503 - !(error = do_revalidate(nd.dentry))) {
1504 + !(error = do_revalidate(nd.dentry, NULL))) {
1505 UPDATE_ATIME(inode);
1506 error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
1508 @@ -335,12 +345,14 @@ asmlinkage long sys_stat64(char * filena
1510 struct nameidata nd;
1512 + struct lookup_intent it = { .it_op = IT_GETATTR };
1514 - error = user_path_walk(filename, &nd);
1515 + error = user_path_walk_it(filename, &nd, &it);
1517 - error = do_revalidate(nd.dentry);
1518 + error = do_revalidate(nd.dentry, &it);
1520 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1521 + intent_release(&it);
1525 @@ -350,12 +362,14 @@ asmlinkage long sys_lstat64(char * filen
1527 struct nameidata nd;
1529 + struct lookup_intent it = { .it_op = IT_GETATTR };
1531 - error = user_path_walk_link(filename, &nd);
1532 + error = user_path_walk_link_it(filename, &nd, &it);
1534 - error = do_revalidate(nd.dentry);
1535 + error = do_revalidate(nd.dentry, &it);
1537 error = cp_new_stat64(nd.dentry->d_inode, statbuf);
1538 + intent_release(&it);
1542 @@ -370,7 +384,7 @@ asmlinkage long sys_fstat64(unsigned lon
1544 struct dentry * dentry = f->f_dentry;
1546 - err = do_revalidate(dentry);
1547 + err = do_revalidate(dentry, NULL);
1549 err = cp_new_stat64(dentry->d_inode, statbuf);
1551 Index: linux-2.4.24/include/linux/dcache.h
1552 ===================================================================
1553 --- linux-2.4.24.orig/include/linux/dcache.h Thu Nov 28 15:53:15 2002
1554 +++ linux-2.4.24/include/linux/dcache.h Wed Mar 17 17:36:14 2004
1556 #include <asm/atomic.h>
1557 #include <linux/mount.h>
1558 #include <linux/kernel.h>
1559 +#include <linux/string.h>
1561 +#define IT_OPEN 0x0001
1562 +#define IT_CREAT 0x0002
1563 +#define IT_READDIR 0x0004
1564 +#define IT_GETATTR 0x0008
1565 +#define IT_LOOKUP 0x0010
1566 +#define IT_UNLINK 0x0020
1567 +#define IT_GETXATTR 0x0040
1568 +#define IT_EXEC 0x0080
1569 +#define IT_PIN 0x0100
1571 +#define IT_FL_LOCKED 0x0001
1572 +#define IT_FL_FOLLOWED 0x0002 /* set by vfs_follow_link */
1574 +#define INTENT_MAGIC 0x19620323
1577 +struct lustre_intent_data {
1578 + int it_disposition;
1580 + __u64 it_lock_handle;
1585 +struct lookup_intent {
1587 + void (*it_op_release)(struct lookup_intent *);
1590 + int it_create_mode;
1592 + struct lustre_intent_data lustre;
1596 +static inline void intent_init(struct lookup_intent *it, int op, int flags)
1598 + memset(it, 0, sizeof(*it));
1599 + it->it_magic = INTENT_MAGIC;
1601 + it->it_flags = flags;
1606 * linux/include/linux/dcache.h
1607 @@ -91,8 +136,22 @@ struct dentry_operations {
1608 int (*d_delete)(struct dentry *);
1609 void (*d_release)(struct dentry *);
1610 void (*d_iput)(struct dentry *, struct inode *);
1611 + int (*d_revalidate_it)(struct dentry *, int, struct lookup_intent *);
1612 + void (*d_pin)(struct dentry *, struct vfsmount * , int);
1613 + void (*d_unpin)(struct dentry *, struct vfsmount *, int);
1616 +#define PIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_pin) \
1617 + de->d_op->d_pin(de, mnt, flag);
1618 +#define UNPIN(de,mnt,flag) if (de && de->d_op && de->d_op->d_unpin) \
1619 + de->d_op->d_unpin(de, mnt, flag);
1622 +/* defined in fs/namei.c */
1623 +extern void intent_release(struct lookup_intent *it);
1624 +/* defined in fs/dcache.c */
1625 +extern void __d_rehash(struct dentry * entry, int lock);
1627 /* the dentry parameter passed to d_hash and d_compare is the parent
1628 * directory of the entries to be compared. It is used in case these
1629 * functions need any directory specific information for determining
1630 @@ -124,6 +183,7 @@ d_iput: no no yes
1631 * s_nfsd_free_path semaphore will be down
1633 #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
1634 +#define DCACHE_LUSTRE_INVALID 0x0010 /* Lustre invalidated */
1636 extern spinlock_t dcache_lock;
1638 Index: linux-2.4.24/include/linux/fs.h
1639 ===================================================================
1640 --- linux-2.4.24.orig/include/linux/fs.h Wed Mar 17 17:36:14 2004
1641 +++ linux-2.4.24/include/linux/fs.h Wed Mar 17 17:36:14 2004
1642 @@ -73,6 +73,7 @@ extern int leases_enable, dir_notify_ena
1644 #define FMODE_READ 1
1645 #define FMODE_WRITE 2
1646 +#define FMODE_EXEC 4
1650 @@ -340,6 +341,9 @@ extern void set_bh_page(struct buffer_he
1651 #define ATTR_MTIME_SET 256
1652 #define ATTR_FORCE 512 /* Not a change, but a change it */
1653 #define ATTR_ATTR_FLAG 1024
1654 +#define ATTR_RAW 0x0800 /* file system, not vfs will massage attrs */
1655 +#define ATTR_FROM_OPEN 0x1000 /* called from open path, ie O_TRUNC */
1656 +#define ATTR_CTIME_SET 0x2000
1659 * This is the Inode Attributes structure, used for notify_change(). It
1660 @@ -478,6 +482,7 @@ struct inode {
1661 struct pipe_inode_info *i_pipe;
1662 struct block_device *i_bdev;
1663 struct char_device *i_cdev;
1664 + void *i_filterdata;
1666 unsigned long i_dnotify_mask; /* Directory notify events */
1667 struct dnotify_struct *i_dnotify; /* for directory notifications */
1668 @@ -582,6 +587,7 @@ struct file {
1670 /* needed for tty driver, and maybe others */
1672 + struct lookup_intent *f_it;
1674 /* preallocated helper kiobuf to speedup O_DIRECT */
1675 struct kiobuf *f_iobuf;
1676 @@ -702,6 +708,7 @@ struct nameidata {
1680 + struct lookup_intent *intent;
1684 @@ -822,7 +829,8 @@ extern int vfs_symlink(struct inode *, s
1685 extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
1686 extern int vfs_rmdir(struct inode *, struct dentry *);
1687 extern int vfs_unlink(struct inode *, struct dentry *);
1688 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
1689 +int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1690 + struct inode *new_dir, struct dentry *new_dentry);
1694 @@ -884,21 +892,32 @@ struct file_operations {
1696 struct inode_operations {
1697 int (*create) (struct inode *,struct dentry *,int);
1698 + int (*create_it) (struct inode *,struct dentry *,int, struct lookup_intent *);
1699 struct dentry * (*lookup) (struct inode *,struct dentry *);
1700 + struct dentry * (*lookup_it) (struct inode *,struct dentry *, struct lookup_intent *, int flags);
1701 int (*link) (struct dentry *,struct inode *,struct dentry *);
1702 + int (*link_raw) (struct nameidata *,struct nameidata *);
1703 int (*unlink) (struct inode *,struct dentry *);
1704 + int (*unlink_raw) (struct nameidata *);
1705 int (*symlink) (struct inode *,struct dentry *,const char *);
1706 + int (*symlink_raw) (struct nameidata *,const char *);
1707 int (*mkdir) (struct inode *,struct dentry *,int);
1708 + int (*mkdir_raw) (struct nameidata *,int);
1709 int (*rmdir) (struct inode *,struct dentry *);
1710 + int (*rmdir_raw) (struct nameidata *);
1711 int (*mknod) (struct inode *,struct dentry *,int,int);
1712 + int (*mknod_raw) (struct nameidata *,int,dev_t);
1713 int (*rename) (struct inode *, struct dentry *,
1714 struct inode *, struct dentry *);
1715 + int (*rename_raw) (struct nameidata *, struct nameidata *);
1716 int (*readlink) (struct dentry *, char *,int);
1717 int (*follow_link) (struct dentry *, struct nameidata *);
1718 void (*truncate) (struct inode *);
1719 int (*permission) (struct inode *, int);
1720 int (*revalidate) (struct dentry *);
1721 + int (*revalidate_it) (struct dentry *, struct lookup_intent *);
1722 int (*setattr) (struct dentry *, struct iattr *);
1723 + int (*setattr_raw) (struct inode *, struct iattr *);
1724 int (*getattr) (struct dentry *, struct iattr *);
1725 int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
1726 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1727 @@ -1094,10 +1113,14 @@ static inline int get_lease(struct inode
1729 asmlinkage long sys_open(const char *, int, int);
1730 asmlinkage long sys_close(unsigned int); /* yes, it's really unsigned */
1731 -extern int do_truncate(struct dentry *, loff_t start);
1732 +extern int do_truncate(struct dentry *, loff_t start, int called_from_open);
1734 extern struct file *filp_open(const char *, int, int);
1735 extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
1736 +extern int open_namei_it(const char *filename, int namei_flags, int mode,
1737 + struct nameidata *nd, struct lookup_intent *it);
1738 +extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
1739 + int flags, struct lookup_intent *it);
1740 extern int filp_close(struct file *, fl_owner_t id);
1741 extern char * getname(const char *);
1743 @@ -1386,6 +1409,7 @@ typedef int (*read_actor_t)(read_descrip
1744 extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
1746 extern int FASTCALL(__user_walk(const char *, unsigned, struct nameidata *));
1747 +extern int FASTCALL(__user_walk_it(const char *, unsigned, struct nameidata *, struct lookup_intent *it));
1748 extern int FASTCALL(path_init(const char *, unsigned, struct nameidata *));
1749 extern int FASTCALL(path_walk(const char *, struct nameidata *));
1750 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
1751 @@ -1397,6 +1421,8 @@ extern struct dentry * lookup_one_len(co
1752 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
1753 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
1754 #define user_path_walk_link(name,nd) __user_walk(name, LOOKUP_POSITIVE, nd)
1755 +#define user_path_walk_it(name,nd,it) __user_walk_it(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd, it)
1756 +#define user_path_walk_link_it(name,nd,it) __user_walk_it(name, LOOKUP_POSITIVE, nd, it)
1758 extern void inode_init_once(struct inode *);
1759 extern void iput(struct inode *);
1760 @@ -1500,6 +1526,8 @@ extern struct file_operations generic_ro
1762 extern int vfs_readlink(struct dentry *, char *, int, const char *);
1763 extern int vfs_follow_link(struct nameidata *, const char *);
1764 +extern int vfs_follow_link_it(struct nameidata *, const char *,
1765 + struct lookup_intent *it);
1766 extern int page_readlink(struct dentry *, char *, int);
1767 extern int page_follow_link(struct dentry *, struct nameidata *);
1768 extern struct inode_operations page_symlink_inode_operations;
1769 Index: linux-2.4.24/include/linux/fs_struct.h
1770 ===================================================================
1771 --- linux-2.4.24.orig/include/linux/fs_struct.h Fri Jul 13 15:10:44 2001
1772 +++ linux-2.4.24/include/linux/fs_struct.h Wed Mar 17 17:36:14 2004
1773 @@ -34,10 +34,12 @@ static inline void set_fs_root(struct fs
1774 write_lock(&fs->lock);
1775 old_root = fs->root;
1776 old_rootmnt = fs->rootmnt;
1777 + PIN(dentry, mnt, 1);
1778 fs->rootmnt = mntget(mnt);
1779 fs->root = dget(dentry);
1780 write_unlock(&fs->lock);
1782 + UNPIN(old_root, old_rootmnt, 1);
1784 mntput(old_rootmnt);
1786 @@ -57,10 +59,12 @@ static inline void set_fs_pwd(struct fs_
1787 write_lock(&fs->lock);
1789 old_pwdmnt = fs->pwdmnt;
1790 + PIN(dentry, mnt, 0);
1791 fs->pwdmnt = mntget(mnt);
1792 fs->pwd = dget(dentry);
1793 write_unlock(&fs->lock);
1795 + UNPIN(old_pwd, old_pwdmnt, 0);
1799 Index: linux-2.4.24/kernel/ksyms.c
1800 ===================================================================
1801 --- linux-2.4.24.orig/kernel/ksyms.c Wed Mar 17 17:36:14 2004
1802 +++ linux-2.4.24/kernel/ksyms.c Wed Mar 17 17:36:14 2004
1803 @@ -275,6 +275,7 @@ EXPORT_SYMBOL(set_page_dirty);
1804 EXPORT_SYMBOL(mark_page_accessed);
1805 EXPORT_SYMBOL(vfs_readlink);
1806 EXPORT_SYMBOL(vfs_follow_link);
1807 +EXPORT_SYMBOL(vfs_follow_link_it);
1808 EXPORT_SYMBOL(page_readlink);
1809 EXPORT_SYMBOL(page_follow_link);
1810 EXPORT_SYMBOL(page_symlink_inode_operations);
1811 Index: linux-2.4.24/kernel/fork.c
1812 ===================================================================
1813 --- linux-2.4.24.orig/kernel/fork.c Fri Nov 28 10:26:21 2003
1814 +++ linux-2.4.24/kernel/fork.c Wed Mar 17 17:36:14 2004
1815 @@ -386,10 +386,13 @@ static inline struct fs_struct *__copy_f
1816 fs->umask = old->umask;
1817 read_lock(&old->lock);
1818 fs->rootmnt = mntget(old->rootmnt);
1819 + PIN(old->pwd, old->pwdmnt, 0);
1820 + PIN(old->root, old->rootmnt, 1);
1821 fs->root = dget(old->root);
1822 fs->pwdmnt = mntget(old->pwdmnt);
1823 fs->pwd = dget(old->pwd);
1825 + PIN(old->altroot, old->altrootmnt, 1);
1826 fs->altrootmnt = mntget(old->altrootmnt);
1827 fs->altroot = dget(old->altroot);
1829 Index: linux-2.4.24/kernel/exit.c
1830 ===================================================================
1831 --- linux-2.4.24.orig/kernel/exit.c Thu Nov 28 15:53:15 2002
1832 +++ linux-2.4.24/kernel/exit.c Wed Mar 17 17:36:14 2004
1833 @@ -238,11 +238,14 @@ static inline void __put_fs_struct(struc
1835 /* No need to hold fs->lock if we are killing it */
1836 if (atomic_dec_and_test(&fs->count)) {
1837 + UNPIN(fs->pwd, fs->pwdmnt, 0);
1838 + UNPIN(fs->root, fs->rootmnt, 1);
1840 mntput(fs->rootmnt);
1844 + UNPIN(fs->altroot, fs->altrootmnt, 1);
1846 mntput(fs->altrootmnt);