Commit d37065cd authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5ca29607
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/file.h> #include <linux/file.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mount.h>
#include <linux/namei.h> #include <linux/namei.h>
struct export_operations export_op_default; struct export_operations export_op_default;
...@@ -468,6 +469,26 @@ static struct dentry *export_decode_fh(struct super_block *sb, __u32 *fh, int fh ...@@ -468,6 +469,26 @@ static struct dentry *export_decode_fh(struct super_block *sb, __u32 *fh, int fh
acceptable, context); acceptable, context);
} }
int exportfs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len,
int connectable)
{
struct export_operations *nop = dentry->d_sb->s_export_op;
return CALL(nop, encode_fh)(dentry, fh, max_len, connectable);
}
EXPORT_SYMBOL_GPL(exportfs_encode_fh);
struct dentry *exportfs_decode_fh(struct vfsmount *mnt, __u32 *fh, int fh_len,
int fileid_type, int (*acceptable)(void *, struct dentry *),
void *context)
{
struct export_operations *nop = mnt->mnt_sb->s_export_op;
return CALL(nop, decode_fh)(mnt->mnt_sb, fh, fh_len, fileid_type,
acceptable, context);
}
EXPORT_SYMBOL_GPL(exportfs_decode_fh);
struct export_operations export_op_default = { struct export_operations export_op_default = {
.decode_fh = export_decode_fh, .decode_fh = export_decode_fh,
.encode_fh = export_encode_fh, .encode_fh = export_encode_fh,
...@@ -477,7 +498,6 @@ struct export_operations export_op_default = { ...@@ -477,7 +498,6 @@ struct export_operations export_op_default = {
.get_dentry = get_dentry, .get_dentry = get_dentry,
}; };
EXPORT_SYMBOL(export_op_default);
EXPORT_SYMBOL(find_exported_dentry); EXPORT_SYMBOL(find_exported_dentry);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -28,10 +28,6 @@ ...@@ -28,10 +28,6 @@
static int nfsd_nr_verified; static int nfsd_nr_verified;
static int nfsd_nr_put; static int nfsd_nr_put;
extern struct export_operations export_op_default;
#define CALL(ops,fun) ((ops->fun)?(ops->fun):export_op_default.fun)
/* /*
* our acceptability function. * our acceptability function.
* if NOSUBTREECHECK, accept anything * if NOSUBTREECHECK, accept anything
...@@ -212,11 +208,9 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) ...@@ -212,11 +208,9 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
if (fileid_type == 0) if (fileid_type == 0)
dentry = dget(exp->ex_dentry); dentry = dget(exp->ex_dentry);
else { else {
struct export_operations *nop = exp->ex_mnt->mnt_sb->s_export_op; dentry = exportfs_decode_fh(exp->ex_mnt, datap,
dentry = CALL(nop,decode_fh)(exp->ex_mnt->mnt_sb, data_left, fileid_type,
datap, data_left, nfsd_acceptable, exp);
fileid_type,
nfsd_acceptable, exp);
} }
if (dentry == NULL) if (dentry == NULL)
goto out; goto out;
...@@ -287,15 +281,13 @@ out: ...@@ -287,15 +281,13 @@ out:
static inline int _fh_update(struct dentry *dentry, struct svc_export *exp, static inline int _fh_update(struct dentry *dentry, struct svc_export *exp,
__u32 *datap, int *maxsize) __u32 *datap, int *maxsize)
{ {
struct export_operations *nop = exp->ex_mnt->mnt_sb->s_export_op;
if (dentry == exp->ex_dentry) { if (dentry == exp->ex_dentry) {
*maxsize = 0; *maxsize = 0;
return 0; return 0;
} }
return CALL(nop,encode_fh)(dentry, datap, maxsize, return exportfs_encode_fh(dentry, datap, maxsize,
!(exp->ex_flags&NFSEXP_NOSUBTREECHECK)); !(exp->ex_flags & NFSEXP_NOSUBTREECHECK));
} }
/* /*
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
struct dentry; struct dentry;
struct super_block; struct super_block;
struct vfsmount;
/** /**
...@@ -116,4 +117,10 @@ extern struct dentry *find_exported_dentry(struct super_block *sb, void *obj, ...@@ -116,4 +117,10 @@ extern struct dentry *find_exported_dentry(struct super_block *sb, void *obj,
void *parent, int (*acceptable)(void *context, struct dentry *de), void *parent, int (*acceptable)(void *context, struct dentry *de),
void *context); void *context);
extern int exportfs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len,
int connectable);
extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, __u32 *fh,
int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *),
void *context);
#endif /* LINUX_EXPORTFS_H */ #endif /* LINUX_EXPORTFS_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment