2 fs/file_table.c | 11 ++
6 fs/nfsd/nfsfh.c | 65 +++++++++++++-
7 fs/nfsd/vfs.c | 235 ++++++++++++++++++++++++++++++++++++++++++++++++-----
8 include/linux/fs.h | 11 ++
10 9 files changed, 333 insertions(+), 34 deletions(-)
12 Index: linux-2.4.21-chaos/fs/file_table.c
13 ===================================================================
14 --- linux-2.4.21-chaos.orig/fs/file_table.c 2003-07-15 04:41:00.000000000 +0400
15 +++ linux-2.4.21-chaos/fs/file_table.c 2003-12-12 16:19:25.000000000 +0300
17 * and call the open function (if any). The caller must verify that
18 * inode->i_fop is not NULL.
20 -int init_private_file(struct file *filp, struct dentry *dentry, int mode)
21 +int init_private_file_it(struct file *filp, struct dentry *dentry, int mode,
22 + struct lookup_intent *it)
24 memset(filp, 0, sizeof(*filp));
27 filp->f_dentry = dentry;
28 filp->f_uid = current->fsuid;
29 filp->f_gid = current->fsgid;
32 filp->f_op = dentry->d_inode->i_fop;
34 return filp->f_op->open(dentry->d_inode, filp);
38 +EXPORT_SYMBOL(init_private_file_it);
40 +int init_private_file(struct file *filp, struct dentry *dentry, int mode)
42 + return init_private_file_it(filp, dentry, mode, NULL);
45 void fput(struct file * file)
47 Index: linux-2.4.21-chaos/fs/inode.c
48 ===================================================================
49 --- linux-2.4.21-chaos.orig/fs/inode.c 2003-12-12 16:18:15.000000000 +0300
50 +++ linux-2.4.21-chaos/fs/inode.c 2003-12-12 16:19:25.000000000 +0300
51 @@ -1054,9 +1054,10 @@
55 -struct inode *iget4_locked(struct super_block *sb, unsigned long ino, find_inode_t find_actor, void *opaque)
56 +struct inode *ifind(struct super_block *sb, unsigned long ino,
57 + struct list_head *head,
58 + find_inode_t find_actor, void *opaque)
60 - struct list_head * head = inode_hashtable + hash(sb,ino);
63 spin_lock(&inode_lock);
64 @@ -1069,6 +1070,24 @@
66 spin_unlock(&inode_lock);
71 +struct inode *ilookup4(struct super_block *sb, unsigned long ino,
72 + find_inode_t find_actor, void *opaque)
74 + struct list_head * head = inode_hashtable + hash(sb,ino);
75 + return ifind(sb, ino, head, find_actor, opaque);
78 +struct inode *iget4_locked(struct super_block *sb, unsigned long ino,
79 + find_inode_t find_actor, void *opaque)
81 + struct list_head * head = inode_hashtable + hash(sb,ino);
82 + struct inode *inode = ifind(sb, ino, head, find_actor, opaque);
87 * get_new_inode() will do the right thing, re-trying the search
88 * in case it had to block at any point.
89 Index: linux-2.4.21-chaos/fs/Makefile
90 ===================================================================
91 --- linux-2.4.21-chaos.orig/fs/Makefile 2003-12-12 16:18:36.000000000 +0300
92 +++ linux-2.4.21-chaos/fs/Makefile 2003-12-12 16:19:25.000000000 +0300
97 -export-objs := filesystems.o open.o dcache.o buffer.o dquot.o inode.o
98 +export-objs := filesystems.o open.o dcache.o buffer.o dquot.o inode.o \
99 + namei.o file_table.o
100 mod-subdirs := nls xfs
102 obj-y := open.o read_write.o devices.o file_table.o buffer.o \
103 Index: linux-2.4.21-chaos/fs/namei.c
104 ===================================================================
105 --- linux-2.4.21-chaos.orig/fs/namei.c 2003-12-12 16:18:06.000000000 +0300
106 +++ linux-2.4.21-chaos/fs/namei.c 2003-12-12 16:19:25.000000000 +0300
108 #include <linux/dnotify.h>
109 #include <linux/smp_lock.h>
110 #include <linux/personality.h>
111 +#include <linux/module.h>
113 #include <asm/namei.h>
114 #include <asm/uaccess.h>
116 it->it_op_release(it);
119 +EXPORT_SYMBOL(intent_release);
121 /* In order to reduce some races, while at the same time doing additional
122 * checking and hopefully speeding things up, we copy filenames to the
127 -struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
128 +struct dentry * lookup_one_len_it(const char * name, struct dentry * base,
129 + int len, struct lookup_intent *it)
133 @@ -930,11 +933,16 @@
135 this.hash = end_name_hash(hash);
137 - return lookup_hash_it(&this, base, NULL);
138 + return lookup_hash_it(&this, base, it);
140 return ERR_PTR(-EACCES);
143 +struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
145 + return lookup_one_len_it(name, base, len, NULL);
151 Index: linux-2.4.21-chaos/fs/nfsd/export.c
152 ===================================================================
153 --- linux-2.4.21-chaos.orig/fs/nfsd/export.c 2003-09-19 03:49:54.000000000 +0400
154 +++ linux-2.4.21-chaos/fs/nfsd/export.c 2003-12-12 16:19:25.000000000 +0300
156 inode = nd.dentry->d_inode;
159 + if ((inode->i_sb->s_type->fs_flags & FS_NFSEXP_FSID) &&
160 + !(nxp->ex_flags & NFSEXP_FSID)) {
161 + nxp->ex_dev = inode->i_sb->s_dev;
162 + nxp->ex_flags |= NFSEXP_FSID;
166 exp = exp_get(clp, dev, ino);
167 Index: linux-2.4.21-chaos/fs/nfsd/nfsfh.c
168 ===================================================================
169 --- linux-2.4.21-chaos.orig/fs/nfsd/nfsfh.c 2003-09-19 03:49:54.000000000 +0400
170 +++ linux-2.4.21-chaos/fs/nfsd/nfsfh.c 2003-12-12 16:19:25.000000000 +0300
172 int sequence; /* sequence counter */
175 +static struct dentry *lookup_it(struct inode *inode, struct dentry * dentry)
177 + if (inode->i_op->lookup_it)
178 + return inode->i_op->lookup_it(inode, dentry, NULL, NULL, 0);
180 + return inode->i_op->lookup(inode, dentry);
185 * A rather strange filldir function to capture
186 * the name matching the specified inode number.
190 struct nfsd_getdents_callback buffer;
191 + struct lookup_intent it;
192 + struct file *filp = NULL;
195 if (!dir || !S_ISDIR(dir->i_mode))
198 * Open the directory ...
200 - error = init_private_file(&file, dentry, FMODE_READ);
202 + if (dentry->d_op && dentry->d_op->d_revalidate_it) {
203 + if ((dentry->d_flags & DCACHE_NFSD_DISCONNECTED) &&
204 + (dentry->d_parent == dentry) ) {
205 + it.it_op_release = NULL;
207 + * XXX Temporary Hack: Simulating init_private_file without
208 + * f_op->open for disconnected dentry Since we don't have actual
209 + * dentry->d_name to revalidate in revalidate_it()
212 + memset(filp, 0, sizeof(*filp));
213 + filp->f_mode = FMODE_READ;
214 + atomic_set(&filp->f_count, 1);
215 + filp->f_dentry = dentry;
216 + filp->f_uid = current->fsuid;
217 + filp->f_gid = current->fsgid;
218 + filp->f_op = dentry->d_inode->i_fop;
221 + intent_init(&it, IT_OPEN, 0);
222 + error = revalidate_it(dentry, &it);
225 + error = init_private_file_it(&file, dentry, FMODE_READ, &it);
228 + error = init_private_file_it(&file, dentry, FMODE_READ, NULL);
234 if (!file.f_op->readdir)
240 - if (file.f_op->release)
241 + if (file.f_op->release && !filp)
242 file.f_op->release(dir, &file);
244 + if (dentry->d_op &&
245 + dentry->d_op->d_revalidate_it &&
246 + it.it_op_release && !filp)
247 + intent_release(&it);
252 * it is well connected. But nobody returns different dentrys do they?
254 down(&child->d_inode->i_sem);
255 - pdentry = child->d_inode->i_op->lookup(child->d_inode, tdentry);
256 + pdentry = lookup_it(child->d_inode, tdentry);
257 up(&child->d_inode->i_sem);
258 d_drop(tdentry); /* we never want ".." hashed */
259 if (!pdentry && tdentry->d_inode == NULL) {
261 pdentry->d_flags |= DCACHE_NFSD_DISCONNECTED;
262 pdentry->d_op = child->d_op;
264 + if (child->d_op && child->d_op->d_revalidate_it)
265 + pdentry->d_op = child->d_op;
268 pdentry = ERR_PTR(-ENOMEM);
270 struct dentry *pdentry;
271 struct inode *parent;
273 + if (result->d_op && result->d_op->d_revalidate_it)
274 + dentry->d_op = result->d_op;
275 pdentry = nfsd_findparent(dentry);
276 err = PTR_ERR(pdentry);
280 inode = dentry->d_inode;
282 + /* cache coherency for non-device filesystems */
283 + if (inode->i_op && inode->i_op->revalidate_it) {
284 + inode->i_op->revalidate_it(dentry, NULL);
287 /* Type check. The correct error return for type mismatches
288 * does not seem to be generally agreed upon. SunOS seems to
289 * use EISDIR if file isn't S_IFREG; a comment in the NFSv3
291 dentry->d_parent->d_name.name, dentry->d_name.name);
294 - printk(KERN_ERR "fh_update: %s/%s already up-to-date!\n",
295 - dentry->d_parent->d_name.name, dentry->d_name.name);
296 + if(!dentry->d_parent->d_inode->i_op->mkdir_raw)
297 + printk(KERN_ERR "fh_update: %s/%s already up-to-date!\n",
298 + dentry->d_parent->d_name.name, dentry->d_name.name);
302 Index: linux-2.4.21-chaos/fs/nfsd/vfs.c
303 ===================================================================
304 --- linux-2.4.21-chaos.orig/fs/nfsd/vfs.c 2003-09-19 03:49:54.000000000 +0400
305 +++ linux-2.4.21-chaos/fs/nfsd/vfs.c 2003-12-12 16:19:25.000000000 +0300
307 static struct raparms * raparml;
308 static struct raparms * raparm_cache;
310 +static int link_raw(struct dentry *dold, struct dentry *ddir,
311 + struct dentry *dnew)
315 + struct nameidata old_nd = { .dentry = dold };
316 + struct nameidata nd = { .dentry = ddir, .last = dnew->d_name };
317 + struct inode_operations *op = nd.dentry->d_inode->i_op;
318 + err = op->link_raw(&old_nd, &nd);
319 + d_instantiate(dnew, dold->d_inode);
320 + if(dold->d_inode->i_op && dold->d_inode->i_op->revalidate_it)
321 + dold->d_inode->i_op->revalidate_it(dnew, NULL);
326 +static int unlink_raw(struct dentry *dentry, char *fname, int flen,
327 + struct dentry *rdentry)
330 + struct qstr last = { .name = fname, .len = flen };
331 + struct nameidata nd = { .dentry = dentry, .last = last };
332 + struct inode_operations *op = nd.dentry->d_inode->i_op;
333 + err = op->unlink_raw(&nd);
340 +static int rmdir_raw(struct dentry *dentry, char *fname, int flen,
341 + struct dentry *rdentry)
344 + struct qstr last = { .name = fname, .len = flen };
345 + struct nameidata nd = { .dentry = dentry, .last = last };
346 + struct inode_operations *op = nd.dentry->d_inode->i_op;
347 + err = op->rmdir_raw(&nd);
349 + rdentry->d_inode->i_flags |= S_DEAD;
356 +static int symlink_raw(struct dentry *dentry, char *fname, int flen,
360 + struct qstr last = { .name = fname, .len = flen };
361 + struct nameidata nd = { .dentry = dentry, .last = last };
362 + struct inode_operations *op = nd.dentry->d_inode->i_op;
363 + err = op->symlink_raw(&nd, path);
368 +static int mkdir_raw(struct dentry *dentry, char *fname, int flen, int mode)
371 + struct qstr last = { .name = fname, .len = flen };
372 + struct nameidata nd = { .dentry = dentry, .last = last };
373 + struct inode_operations *op = nd.dentry->d_inode->i_op;
374 + err = op->mkdir_raw(&nd, mode);
379 +static int mknod_raw(struct dentry *dentry, char *fname, int flen, int mode,
383 + struct qstr last = { .name = fname, .len = flen };
384 + struct nameidata nd = { .dentry = dentry, .last = last };
385 + struct inode_operations *op = nd.dentry->d_inode->i_op;
386 + err = op->mknod_raw(&nd, mode, dev);
391 +static int rename_raw(struct dentry *fdentry, struct dentry *tdentry,
392 + struct dentry *odentry, struct dentry *ndentry)
396 + struct nameidata old_nd = { .dentry = fdentry, .last = odentry->d_name};
397 + struct nameidata new_nd = { .dentry = tdentry, .last = ndentry->d_name};
398 + struct inode_operations *op = old_nd.dentry->d_inode->i_op;
399 + err = op->rename_raw(&old_nd, &new_nd);
400 + d_move(odentry, ndentry);
405 +static int setattr_raw(struct inode *inode, struct iattr *iap)
409 + iap->ia_valid |= ATTR_RAW;
410 + err = inode->i_op->setattr_raw(inode, iap);
415 +int revalidate_it(struct dentry *dentry, struct lookup_intent *it)
419 + if (dentry && dentry->d_op && dentry->d_op->d_revalidate_it) {
420 + if (!dentry->d_op->d_revalidate_it(dentry, 0, NULL, it) &&
421 + !d_invalidate(dentry)) {
433 * Look up one component of a pathname.
434 * N.B. After this call _both_ fhp and resfh need an fh_put
437 err = nfserr_notsync;
438 if (!check_guard || guardtime == inode->i_ctime) {
439 - err = notify_change(dentry, iap);
440 + if ( dentry->d_inode->i_op && dentry->d_inode->i_op->setattr_raw)
441 + err = setattr_raw(dentry->d_inode, iap);
443 + err = notify_change(dentry, iap);
449 struct dentry *dentry;
451 + struct lookup_intent it;
454 /* If we get here, then the client has already done an "open", and (hopefully)
456 filp->f_mode = FMODE_READ;
459 + intent_init(&it, IT_OPEN, (filp->f_flags & ~O_ACCMODE) | filp->f_mode);
461 + err = revalidate_it(dentry, &it);
468 if (filp->f_op && filp->f_op->open) {
469 err = filp->f_op->open(inode, filp);
471 atomic_dec(&filp->f_count);
476 + if (it.it_op_release)
477 + intent_release(&it);
484 struct dentry *dentry, *dchild;
487 + int err, error = -EOPNOTSUPP;
491 @@ -837,20 +975,44 @@
492 dentry = fhp->fh_dentry;
493 dirp = dentry->d_inode;
497 + if (dirp->i_op->mkdir_raw)
498 + error = mkdir_raw(dentry, fname, flen, iap->ia_mode);
505 + if (dirp->i_op->mknod_raw) {
506 + if (type == S_IFREG)
508 + error = mknod_raw(dentry, fname, flen, iap->ia_mode, rdev);
512 + printk("nfsd: bad file type %o in nfsd_create\n", type);
516 - if(!dirp->i_op || !dirp->i_op->lookup)
517 + if(!dirp->i_op || !(dirp->i_op->lookup || dirp->i_op->lookup_it))
520 * Check whether the response file handle has been verified yet.
521 * If it has, the parent directory should already be locked.
523 - if (!resfhp->fh_dentry) {
524 - /* called from nfsd_proc_mkdir, or possibly nfsd3_proc_create */
526 + if (!resfhp->fh_dentry || dirp->i_op->lookup_it) {
527 + /* called from nfsd_proc_mkdir, or possibly nfsd3_proc_create
528 + and nfsd_proc_create in case of lustre
530 + if (!resfhp->fh_dentry)
532 dchild = lookup_one_len(fname, dentry, flen);
533 err = PTR_ERR(dchild);
536 + resfhp->fh_dentry = NULL;
537 err = fh_compose(resfhp, fhp->fh_export, dchild, fhp);
540 @@ -871,10 +1033,12 @@
541 * Make sure the child dentry is still negative ...
544 - if (dchild->d_inode) {
545 - dprintk("nfsd_create: dentry %s/%s not negative!\n",
546 - dentry->d_name.name, dchild->d_name.name);
548 + if ( error == -EOPNOTSUPP) {
549 + if (dchild->d_inode) {
550 + dprintk("nfsd_create: dentry %s/%s not negative!\n",
551 + dentry->d_name.name, dchild->d_name.name);
556 if (!(iap->ia_valid & ATTR_MODE))
557 @@ -887,16 +1051,19 @@
561 - err = vfs_create(dirp, dchild, iap->ia_mode);
562 + if (error == -EOPNOTSUPP)
563 + err = vfs_create(dirp, dchild, iap->ia_mode);
566 - err = vfs_mkdir(dirp, dchild, iap->ia_mode);
567 + if (error == -EOPNOTSUPP)
568 + err = vfs_mkdir(dirp, dchild, iap->ia_mode);
574 - err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
575 + if (error == -EOPNOTSUPP)
576 + err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
579 printk("nfsd: bad file type %o in nfsd_create\n", type);
580 @@ -965,7 +1132,13 @@
581 /* Get all the sanity checks out of the way before
582 * we lock the parent. */
584 - if(!dirp->i_op || !dirp->i_op->lookup)
585 + if (dirp->i_op->mknod_raw) {
586 + err = mknod_raw(dentry, fname, flen, iap->ia_mode, 0);
587 + if (err && err != -EOPNOTSUPP)
591 + if(!dirp->i_op || !(dirp->i_op->lookup || dirp->i_op->lookup_it))
595 @@ -1016,6 +1189,8 @@
596 case NFS3_CREATE_GUARDED:
599 + if(dirp->i_op->mknod_raw)
604 @@ -1122,7 +1297,7 @@
607 struct dentry *dentry, *dnew;
609 + int err, cerr, error = -EOPNOTSUPP;
613 @@ -1136,12 +1311,18 @@
616 dentry = fhp->fh_dentry;
618 + if (dentry->d_inode->i_op->symlink_raw)
619 + error = symlink_raw(dentry, fname, flen, path);
621 dnew = lookup_one_len(fname, dentry, flen);
626 - err = vfs_symlink(dentry->d_inode, dnew, path);
628 + if (err == -EOPNOTSUPP || !dentry->d_inode->i_op->symlink_raw)
629 + err = vfs_symlink(dentry->d_inode, dnew, path);
631 if (EX_ISSYNC(fhp->fh_export))
632 nfsd_sync_dir(dentry);
633 @@ -1211,7 +1392,10 @@
634 dold = tfhp->fh_dentry;
635 dest = dold->d_inode;
637 - err = vfs_link(dold, dirp, dnew);
638 + if (dirp->i_op->link_raw)
639 + err = link_raw(dold, ddir, dnew);
641 + err = vfs_link(dold, dirp, dnew);
643 if (EX_ISSYNC(ffhp->fh_export)) {
645 @@ -1296,7 +1480,10 @@
649 - err = vfs_rename(fdir, odentry, tdir, ndentry);
650 + if(fdir->i_op->rename_raw)
651 + err = rename_raw(fdentry, tdentry, odentry, ndentry);
653 + err = vfs_rename(fdir, odentry, tdir, ndentry);
654 if (!err && EX_ISSYNC(tfhp->fh_export)) {
655 nfsd_sync_dir(tdentry);
656 nfsd_sync_dir(fdentry);
657 @@ -1317,7 +1504,7 @@
659 double_up(&tdir->i_sem, &fdir->i_sem);
660 ffhp->fh_locked = tfhp->fh_locked = 0;
666 @@ -1363,9 +1550,15 @@
670 - err = vfs_unlink(dirp, rdentry);
671 + if (dirp->i_op->unlink_raw)
672 + err = unlink_raw(dentry, fname, flen, rdentry);
674 + err = vfs_unlink(dirp, rdentry);
675 } else { /* It's RMDIR */
676 - err = vfs_rmdir(dirp, rdentry);
677 + if (dirp->i_op->rmdir_raw)
678 + err = rmdir_raw(dentry, fname, flen, rdentry);
680 + err = vfs_rmdir(dirp, rdentry);
684 Index: linux-2.4.21-chaos/include/linux/fs.h
685 ===================================================================
686 --- linux-2.4.21-chaos.orig/include/linux/fs.h 2003-12-12 16:19:23.000000000 +0300
687 +++ linux-2.4.21-chaos/include/linux/fs.h 2003-12-12 16:19:25.000000000 +0300
689 #define FS_SINGLE 8 /* Filesystem that can have only one superblock */
690 #define FS_NOMOUNT 16 /* Never mount from userland */
691 #define FS_LITTER 32 /* Keeps the tree in dcache */
692 +#define FS_NFSEXP_FSID 64 /* Use file system specific fsid for
693 + * exporting non device filesystems.
695 #define FS_ODD_RENAME 32768 /* Temporary stuff; will go away as soon
696 * as nfs_rename() will be cleaned up
698 @@ -1159,6 +1162,9 @@
699 struct nameidata *nd, struct lookup_intent *it);
700 extern struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt,
701 int flags, struct lookup_intent *it);
702 +extern int revalidate_it(struct dentry *dentry, struct lookup_intent *it);
703 +extern int init_private_file_it(struct file *, struct dentry *dentry, int mode,
704 + struct lookup_intent *it);
705 extern int filp_close(struct file *, fl_owner_t id);
706 extern char * getname(const char *);
708 @@ -1458,6 +1464,8 @@
709 extern int follow_down(struct vfsmount **, struct dentry **);
710 extern int follow_up(struct vfsmount **, struct dentry **);
711 extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
712 +extern struct dentry * lookup_one_len_it(const char *, struct dentry *, int,
713 + struct lookup_intent *);
714 extern struct dentry * __lookup_hash(struct qstr *, struct dentry *);
715 extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
716 #define user_path_walk(name,nd) __user_walk(name, LOOKUP_FOLLOW|LOOKUP_POSITIVE, nd)
717 @@ -1477,7 +1485,8 @@
719 extern struct inode * iget4_locked(struct super_block *, unsigned long,
720 find_inode_t, void *);
722 +extern struct inode * ilookup4(struct super_block *, unsigned long,
723 + find_inode_t, void *);
724 static inline struct inode *iget4(struct super_block *sb, unsigned long ino,
725 find_inode_t find_actor, void *opaque)
727 Index: linux-2.4.21-chaos/kernel/ksyms.c
728 ===================================================================
729 --- linux-2.4.21-chaos.orig/kernel/ksyms.c 2003-12-12 16:18:36.000000000 +0300
730 +++ linux-2.4.21-chaos/kernel/ksyms.c 2003-12-12 16:19:25.000000000 +0300
732 EXPORT_SYMBOL(igrab);
733 EXPORT_SYMBOL(iunique);
734 EXPORT_SYMBOL(iget4_locked);
735 +EXPORT_SYMBOL(ilookup4);
736 EXPORT_SYMBOL(unlock_new_inode);
738 EXPORT_SYMBOL(inode_init_once);
740 EXPORT_SYMBOL(path_release);
741 EXPORT_SYMBOL(__user_walk);
742 EXPORT_SYMBOL(lookup_one_len);
743 +EXPORT_SYMBOL(lookup_one_len_it);
744 EXPORT_SYMBOL(lookup_hash);
746 EXPORT_SYMBOL(sys_close);