aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2007-07-17 07:04:30 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-17 13:23:06 -0400
commitd37065cd6d6bbe98fd4be14d6c9e64c0bfa124c5 (patch)
tree03a996d3d93a4d5ebd737519f7a6f959ecdbce0d
parent5ca29607331fe37980dc3b488793ef8b1409b722 (diff)
knfsd: exportfs: add procedural interface for NFSD
Currently NFSD calls directly into filesystems through the export_operations structure. I plan to change this interface in various ways in later patches, and want to avoid the export of the default operations to NFSD, so this patch adds two simple exportfs_encode_fh/exportfs_decode_fh helpers for NFSD to call instead of poking into exportfs guts. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/exportfs/expfs.c22
-rw-r--r--fs/nfsd/nfsfh.c18
-rw-r--r--include/linux/exportfs.h7
3 files changed, 33 insertions, 14 deletions
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index dd132bb7b8f8..db86006956b0 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -3,6 +3,7 @@
3#include <linux/fs.h> 3#include <linux/fs.h>
4#include <linux/file.h> 4#include <linux/file.h>
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/mount.h>
6#include <linux/namei.h> 7#include <linux/namei.h>
7 8
8struct export_operations export_op_default; 9struct export_operations export_op_default;
@@ -468,6 +469,26 @@ static struct dentry *export_decode_fh(struct super_block *sb, __u32 *fh, int fh
468 acceptable, context); 469 acceptable, context);
469} 470}
470 471
472int exportfs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len,
473 int connectable)
474{
475 struct export_operations *nop = dentry->d_sb->s_export_op;
476
477 return CALL(nop, encode_fh)(dentry, fh, max_len, connectable);
478}
479EXPORT_SYMBOL_GPL(exportfs_encode_fh);
480
481struct dentry *exportfs_decode_fh(struct vfsmount *mnt, __u32 *fh, int fh_len,
482 int fileid_type, int (*acceptable)(void *, struct dentry *),
483 void *context)
484{
485 struct export_operations *nop = mnt->mnt_sb->s_export_op;
486
487 return CALL(nop, decode_fh)(mnt->mnt_sb, fh, fh_len, fileid_type,
488 acceptable, context);
489}
490EXPORT_SYMBOL_GPL(exportfs_decode_fh);
491
471struct export_operations export_op_default = { 492struct export_operations export_op_default = {
472 .decode_fh = export_decode_fh, 493 .decode_fh = export_decode_fh,
473 .encode_fh = export_encode_fh, 494 .encode_fh = export_encode_fh,
@@ -477,7 +498,6 @@ struct export_operations export_op_default = {
477 .get_dentry = get_dentry, 498 .get_dentry = get_dentry,
478}; 499};
479 500
480EXPORT_SYMBOL(export_op_default);
481EXPORT_SYMBOL(find_exported_dentry); 501EXPORT_SYMBOL(find_exported_dentry);
482 502
483MODULE_LICENSE("GPL"); 503MODULE_LICENSE("GPL");
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index 0108d3ec1c27..ecf9c361b3f5 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -28,10 +28,6 @@
28static int nfsd_nr_verified; 28static int nfsd_nr_verified;
29static int nfsd_nr_put; 29static int nfsd_nr_put;
30 30
31extern struct export_operations export_op_default;
32
33#define CALL(ops,fun) ((ops->fun)?(ops->fun):export_op_default.fun)
34
35/* 31/*
36 * our acceptability function. 32 * our acceptability function.
37 * if NOSUBTREECHECK, accept anything 33 * if NOSUBTREECHECK, accept anything
@@ -212,11 +208,9 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
212 if (fileid_type == 0) 208 if (fileid_type == 0)
213 dentry = dget(exp->ex_dentry); 209 dentry = dget(exp->ex_dentry);
214 else { 210 else {
215 struct export_operations *nop = exp->ex_mnt->mnt_sb->s_export_op; 211 dentry = exportfs_decode_fh(exp->ex_mnt, datap,
216 dentry = CALL(nop,decode_fh)(exp->ex_mnt->mnt_sb, 212 data_left, fileid_type,
217 datap, data_left, 213 nfsd_acceptable, exp);
218 fileid_type,
219 nfsd_acceptable, exp);
220 } 214 }
221 if (dentry == NULL) 215 if (dentry == NULL)
222 goto out; 216 goto out;
@@ -287,15 +281,13 @@ out:
287static inline int _fh_update(struct dentry *dentry, struct svc_export *exp, 281static inline int _fh_update(struct dentry *dentry, struct svc_export *exp,
288 __u32 *datap, int *maxsize) 282 __u32 *datap, int *maxsize)
289{ 283{
290 struct export_operations *nop = exp->ex_mnt->mnt_sb->s_export_op;
291
292 if (dentry == exp->ex_dentry) { 284 if (dentry == exp->ex_dentry) {
293 *maxsize = 0; 285 *maxsize = 0;
294 return 0; 286 return 0;
295 } 287 }
296 288
297 return CALL(nop,encode_fh)(dentry, datap, maxsize, 289 return exportfs_encode_fh(dentry, datap, maxsize,
298 !(exp->ex_flags&NFSEXP_NOSUBTREECHECK)); 290 !(exp->ex_flags & NFSEXP_NOSUBTREECHECK));
299} 291}
300 292
301/* 293/*
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index fdc306fbba50..8872fe8392d6 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -5,6 +5,7 @@
5 5
6struct dentry; 6struct dentry;
7struct super_block; 7struct super_block;
8struct vfsmount;
8 9
9 10
10/** 11/**
@@ -116,4 +117,10 @@ extern struct dentry *find_exported_dentry(struct super_block *sb, void *obj,
116 void *parent, int (*acceptable)(void *context, struct dentry *de), 117 void *parent, int (*acceptable)(void *context, struct dentry *de),
117 void *context); 118 void *context);
118 119
120extern int exportfs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len,
121 int connectable);
122extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, __u32 *fh,
123 int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *),
124 void *context);
125
119#endif /* LINUX_EXPORTFS_H */ 126#endif /* LINUX_EXPORTFS_H */