Suggested improvements for localio support.
Subsystems (3)
These three patches are intend to be merged into the nfs localio patch series.
The first two should be squashed into existing patches as mentioned in the commit description. The first is a stand alone patch which cleans up some ugliness that the current rpcsvc infrastructure requires.
As mentioned in the first patch, a small rearranged of patches is required for each individual patch to compile.
I would like to suggest changes to the CONFIG options too - I haven't provided a patch for that.
There should be just one config option: CONFIG_NFS_LOCALIO. There is no point enabling for client without server or server without client as in either configuration nothing useful can be achieved. There is also no gain in enabling only for v3 or v4 and not both (unless I've missed something...)
Despite Jeff's generally sensible suggestion, I'd like the CONFIG option to be added earliy so that we can compile-test each individual commit. If that would mean some intermediate commit might be problematic then I would rather the localio_enabled module parameter were forced to 'false' until it was safe to turn it on.
I note that the server uses uuid_t while the client doesn't. I might have made that worse... We should probably be consisent.
I have only tested very lightly - treat as a base for further work more than as a fully polished solution.
Thanks,
NeilBrown
[PATCH 1/3] NFS: Simplify Client NFS_LOCALIO_PROGRAM support [PATCH 2/3] NFSD: Simplify server NFS_LOCALIO_PROGRAM support [PATCH 3/3] SUNRPC: replace program list with program array
PATCH 1/3 NFS: Simplify Client NFS_LOCALIO_PROGRAM support
From: NeilBrown <[email protected]>
This patch is intended to be squashed into
nfs: implement v3 and v4 client support for NFS_LOCALIO_PROGRAM
It moves all the knowledge of the LOCALIO RPC protocol in fs/nfs/localio.c and implements just a single version (1) which is used independently of what NFS version is used.
The #defines for PROGRAM and PROC numbers are moved out of uapi as these are not part of the UAPI - only Linux internals need to know then. Other servers might see them but the numbers are chosen so other servers will reject the any request they see.
For the resulting patch to compile,
nfs/nfsd: consolidate {encode,decode}_opaque_fixed in nfs_xdr.h
needs to be applied earlier in the series.
--- fs/nfs/internal.h | 5 -- fs/nfs/localio.c | 99 ++++++++++++++++++++++++++++------------ fs/nfs/nfs3_fs.h | 1 - fs/nfs/nfs3client.c | 23 ---------- fs/nfs/nfs3proc.c | 3 -- fs/nfs/nfs3xdr.c | 67 --------------------------- fs/nfs/nfs4_fs.h | 2 - fs/nfs/nfs4client.c | 23 ---------- fs/nfs/nfs4proc.c | 3 -- fs/nfs/nfs4xdr.c | 52 --------------------- include/linux/nfs.h | 7 +++ include/linux/nfs_xdr.h | 12 ----- include/uapi/linux/nfs.h | 4 -- 13 files changed, 76 insertions(+), 225 deletions(-)
fs/nfs/internal.h +0 -5
@@ -456,8 +456,6 @@ extern int nfs_wait_bit_killable(struct wait_bit_key *key, int mode);/* localio.c */ extern void nfs_local_disable (struct nfs_client *);extern void nfs_local_probe (struct nfs_client *); -extern void nfs_init_localioclient (struct nfs_client *clp, -const struct rpc_program *program,u32 vers);extern struct file *nfs_local_open_fh (struct nfs_client *,const struct cred *,struct nfs_fh *,const fmode_t ); extern struct file *nfs_local_file_open(struct nfs_client *clp,
@@ -474,9 +472,6 @@ extern bool nfs_server_is_local(const struct nfs_client *clp);#else static inline void nfs_local_disable (struct nfs_client *clp) {}static inline void nfs_local_probe (struct nfs_client *clp) {} -static inline void nfs_init_localioclient (struct nfs_client *clp, -const struct rpc_program *program, -u32 vers) {} static inline struct file *nfs_local_open_fh(struct nfs_client *clp, const struct cred *cred, struct nfs_fh *fh,
fs/nfs/localio.c +69 -30
148 lines not on this page · raw message
fs/nfs/nfs3_fs.h +0 -1
@@ -30,7 +30,6 @@ static inline int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,struct nfs_server *nfs3_create_server (struct fs_context *);struct nfs_server *nfs3_clone_server (struct nfs_server *,struct nfs_fh *,struct nfs_fattr *,rpc_authflavor_t ); -void nfs3_init_localioclient (struct nfs_client *);/* nfs3super.c */ extern struct nfs_subversion nfs_v3;
fs/nfs/nfs3client.c +0 -23
@@ -130,26 +130,3 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv,return clp; }EXPORT_SYMBOL_GPL (nfs3_set_ds_client); - -#if defined(CONFIG_NFS_V3_LOCALIO ) -static struct rpc_stat nfslocalio_rpcstat = { &nfslocalio_program3 }; -static const struct rpc_version *nfslocalio_version[] = { - [3 ] = &nfslocalio_version3, -}; - -const struct rpc_program nfslocalio_program3 = { - .name ="nfslocalio" , - .number =NFS_LOCALIO_PROGRAM , - .nrvers =ARRAY_SIZE (nfslocalio_version), - .version = nfslocalio_version, - .stats = &nfslocalio_rpcstat, -}; - -/* -* Initialise an NFSv3 localio client connection -*/ -void nfs3_init_localioclient (struct nfs_client *clp) -{ -nfs_init_localioclient (clp, &nfslocalio_program3,3 ); -} -#endif /* CONFIG_NFS_V3_LOCALIO */
fs/nfs/nfs3proc.c +0 -3
@@ -1067,7 +1067,4 @@ const struct nfs_rpc_ops nfs_v3_clientops = { .free_client = nfs_free_client, .create_server = nfs3_create_server, .clone_server = nfs3_clone_server, -#if defined(CONFIG_NFS_V3_LOCALIO ) - .init_localioclient = nfs3_init_localioclient, -#endif };
fs/nfs/nfs3xdr.c +0 -67
70 lines not on this page · raw message
fs/nfs/nfs4_fs.h +0 -2
@@ -538,8 +538,6 @@ extern int nfs4_proc_commit(struct file *dst, __u64 offset, __u32 count, structextern const nfs4_stateid zero_stateid;extern const nfs4_stateid invalid_stateid; -extern void nfs4_init_localioclient (struct nfs_client *); -/* nfs4super.c */ struct nfs_mount_info ;extern struct nfs_subversion nfs_v4;
fs/nfs/nfs4client.c +0 -23
@@ -1384,26 +1384,3 @@ int nfs4_update_server(struct nfs_server *server, const char *hostname,return nfs_probe_server (server,NFS_FH (d_inode (server->super->s_root))); } - -#if defined(CONFIG_NFS_V4_LOCALIO ) -static struct rpc_stat nfslocalio_rpcstat = { &nfslocalio_program4 }; -static const struct rpc_version *nfslocalio_version[] = { - [4 ] = &nfslocalio_version4, -}; - -const struct rpc_program nfslocalio_program4 = { - .name ="nfslocalio" , - .number =NFS_LOCALIO_PROGRAM , - .nrvers =ARRAY_SIZE (nfslocalio_version), - .version = nfslocalio_version, - .stats = &nfslocalio_rpcstat, -}; - -/* -* Initialise an NFSv4 localio client connection -*/ -void nfs4_init_localioclient (struct nfs_client *clp) -{ -nfs_init_localioclient (clp, &nfslocalio_program4,4 ); -} -#endif /* CONFIG_NFS_V4_LOCALIO */
fs/nfs/nfs4proc.c +0 -3
@@ -10745,9 +10745,6 @@ const struct nfs_rpc_ops nfs_v4_clientops = { .discover_trunking = nfs4_discover_trunking, .enable_swap = nfs4_enable_swap, .disable_swap = nfs4_disable_swap, -#if defined(CONFIG_NFS_V4_LOCALIO ) - .init_localioclient = nfs4_init_localioclient, -#endif };static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = {
fs/nfs/nfs4xdr.c +0 -52
55 lines not on this page · raw message
include/linux/nfs.h +7 -0
@@ -15,6 +15,13 @@#include <linux/crc32.h> #include <uapi/linux/nfs.h> +/* The localio program is entirely private to Linux and is +* NOT part of the uapi. +*/ +#define NFS_LOCALIO_PROGRAM 0x20000002 +#define LOCALIOPROC_NULL 0 +#define LOCALIOPROC_GETUUID 1 +/* * This is the kernel NFS client file handle representation */
include/linux/nfs_xdr.h +0 -12
@@ -1002,10 +1002,6 @@ struct nfs3_getaclres {struct posix_acl * acl_default; }; -struct nfs_getuuidres { -__u8 * uuid; -}; -#if IS_ENABLED (CONFIG_NFS_V4 )typedef u64 clientid4 ;
@@ -1823,9 +1819,6 @@ struct nfs_rpc_ops {int (*discover_trunking)(struct nfs_server *,struct nfs_fh *);void (*enable_swap)(struct inode *inode);void (*disable_swap)(struct inode *inode); -#if IS_ENABLED (CONFIG_NFS_LOCALIO ) -void (*init_localioclient)(struct nfs_client *); -#endif };/*
@@ -1841,9 +1834,4 @@ extern const struct rpc_version nfs_version4;extern const struct rpc_version nfsacl_version3;extern const struct rpc_program nfsacl_program; -extern const struct rpc_version nfslocalio_version3; -extern const struct rpc_program nfslocalio_program3; -extern const struct rpc_version nfslocalio_version4; -extern const struct rpc_program nfslocalio_program4; -#endif
include/uapi/linux/nfs.h +0 -4
@@ -33,10 +33,6 @@#define NFS_MNT_VERSION 1#define NFS_MNT3_VERSION 3 -#define NFS_LOCALIO_PROGRAM 0x20000002 -#define LOCALIOPROC_NULL 0 -#define LOCALIOPROC_GETUUID 1 -#define NFS_PIPE_DIRNAME "nfs"/*
Signature · 1 line
2.44.0
PATCH 2/3 NFSD: Simplify server NFS_LOCALIO_PROGRAM support
In reply to NeilBrownFrom: NeilBrown <[email protected]>
This patch is intended to be squashed into
nfsd: implement v3 and v4 server support for NFS_LOCALIO_PROGRAM
It moves all code for the LOCALIO RPC programs into localio.c with a little bit in nfssvc.c, and implements just a single version.
--- fs/nfsd/localio.c | 106 +++++++++------------------------------------- fs/nfsd/nfsd.h | 11 ----- fs/nfsd/nfssvc.c | 59 ++------------------------ fs/nfsd/xdr.h | 6 --- 4 files changed, 23 insertions(+), 159 deletions(-)
fs/nfsd/localio.c +19 -87
@@ -18,8 +18,6 @@#include "netns.h" #include "filecache.h" #include "cache.h" -#include "xdr3.h" -#include "xdr4.h" #define NFSDDBG_FACILITY NFSDDBG_FH
@@ -262,48 +260,39 @@ static __be32 nfsd_proc_null(struct svc_rqst *rqstp)return rpc_success; } +struct nfsd_getuuidres { +uuid_t uuid; +}; +static __be32 nfsd_proc_getuuid (struct svc_rqst *rqstp) {struct nfsd_net *nn =net_generic (SVC_NET (rqstp), nfsd_net_id);struct nfsd_getuuidres *resp = rqstp->rq_resp;uuid_copy (&resp->uuid, &nn->nfsd_uuid.uuid); - resp->status = nfs_ok;return rpc_success; } -#define NFS_getuuid_sz XDR_QUADLEN(UUID_SIZE) -static inline void encode_opaque_fixed (struct xdr_stream *xdr,const void *buf,size_t len) {WARN_ON_ONCE (xdr_stream_encode_opaque_fixed (xdr, buf, len) <0 ); } -static void encode_uuid (struct xdr_stream *xdr,uuid_t *src_uuid) +static bool nfslocalio_encode_getuuidres (struct svc_rqst *rqstp, +struct xdr_stream *xdr) { +struct nfsd_getuuidres *resp = rqstp->rq_resp;u8 uuid[UUID_SIZE ]; -export_uuid (uuid, src_uuid); +export_uuid (uuid, &resp->uuid);encode_opaque_fixed (xdr, uuid,UUID_SIZE );dprintk ("%s: uuid=%pU\n" , __func__, uuid); -} - -#if defined(CONFIG_NFSD_V3_LOCALIO) -static bool nfs3svc_encode_getuuidres(struct svc_rqst *rqstp, - struct xdr_stream *xdr) -{ - struct nfsd_getuuidres *resp = rqstp->rq_resp; - - if (!svcxdr_encode_nfsstat3(xdr, resp->status)) - return false; - if (resp->status == nfs_ok) - encode_uuid(xdr, &resp->uuid);return true; } -static const struct svc_procedure nfsd_localio_procedures3[2] = { +static const struct svc_procedure nfsd_localio_procedures[2 ] = { [LOCALIOPROC_NULL ] = { .pc_func = nfsd_proc_null, .pc_decode = nfssvc_decode_voidarg,
@@ -311,86 +300,29 @@ static const struct svc_procedure nfsd_localio_procedures3[2] = { .pc_argsize = sizeof(struct nfsd_voidargs), .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, - .pc_xdrressize = 1, + .pc_xdrressize = 0, .pc_name = "NULL", }, [LOCALIOPROC_GETUUID] = { .pc_func = nfsd_proc_getuuid, .pc_decode = nfssvc_decode_voidarg, - .pc_encode = nfs3svc_encode_getuuidres, + .pc_encode = nfslocalio_encode_getuuidres, .pc_argsize = sizeof(struct nfsd_voidargs), .pc_ressize = sizeof(struct nfsd_getuuidres), .pc_cachetype = RC_NOCACHE, - .pc_xdrressize = 1+NFS_getuuid_sz, + .pc_xdrressize = XDR_QUADLEN(UUID_SIZE), .pc_name = "GETUUID", }, }; static DEFINE_PER_CPU_ALIGNED(unsigned long, - nfsd_localio_count3[ARRAY_SIZE(nfsd_localio_procedures3)]); -const struct svc_version nfsd_localio_version3 = { - .vs_vers =3 , + nfsd_localio_count[ARRAY_SIZE(nfsd_localio_procedures)]); +const struct svc_version nfsd_localio_version1 = { + .vs_vers =1 , .vs_nproc =2 , - .vs_proc = nfsd_localio_procedures3, + .vs_proc = nfsd_localio_procedures, .vs_dispatch = nfsd_dispatch, - .vs_count = nfsd_localio_count3, - .vs_xdrsize =NFS3_SVC_XDRSIZE , -}; -#endif /* CONFIG_NFSD_V3_LOCALIO */ - -#if defined(CONFIG_NFSD_V4_LOCALIO ) -static bool nfs4svc_encode_getuuidres (struct svc_rqst *rqstp, -struct xdr_stream *xdr) -{ -struct nfsd_getuuidres *resp = rqstp->rq_resp; -__be32 *p; - - p =xdr_reserve_space (xdr,8 ); -if (!p) -return 0 ; - *p++ =cpu_to_be32 (LOCALIOPROC_GETUUID ); - *p++ = resp->status; - -if (resp->status == nfs_ok) -encode_uuid (xdr, &resp->uuid); - -return 1 ; -} - -static const struct svc_procedure nfsd_localio_procedures4[2 ] = { - [LOCALIOPROC_NULL ] = { - .pc_func = nfsd_proc_null, - .pc_decode = nfssvc_decode_voidarg, - .pc_encode = nfssvc_encode_voidres, - .pc_argsize =sizeof (struct nfsd_voidargs ), - .pc_ressize =sizeof (struct nfsd_voidres ), - .pc_cachetype =RC_NOCACHE , - .pc_xdrressize =1 , - .pc_name ="NULL" , - }, - [LOCALIOPROC_GETUUID ] = { - .pc_func = nfsd_proc_getuuid, - .pc_decode = nfssvc_decode_voidarg, - .pc_encode = nfs4svc_encode_getuuidres, - .pc_argsize =sizeof (struct nfsd_voidargs ), - .pc_ressize =sizeof (struct nfsd_getuuidres ), - .pc_cachetype =RC_NOCACHE , - .pc_xdrressize =2 +NFS_getuuid_sz, - .pc_name ="GETUUID" , - }, -}; - -static DEFINE_PER_CPU_ALIGNED(unsigned long, - nfsd_localio_count4[ARRAY_SIZE(nfsd_localio_procedures4)]); -const struct svc_version nfsd_localio_version4 = { - .vs_vers =4 , - .vs_nproc =2 , - .vs_proc = nfsd_localio_procedures4, - .vs_dispatch = nfsd_dispatch, - .vs_count = nfsd_localio_count4, - .vs_xdrsize =NFS4_SVC_XDRSIZE , - .vs_rpcb_optnl = true, - .vs_need_cong_ctrl = true, - + .vs_count = nfsd_localio_count, + .vs_xdrsize =XDR_QUADLEN (UUID_SIZE ), + .vs_hidden = true, }; -#endif /* CONFIG_NFSD_V4_LOCALIO */
fs/nfsd/nfsd.h +0 -11
@@ -143,17 +143,6 @@ extern const struct svc_version nfsd_acl_version3;#endif #endif -#if defined(CONFIG_NFSD_V3_LOCALIO ) -extern const struct svc_version nfsd_localio_version3; -#else -#define nfsd_localio_version3 NULL -#endif -#if defined(CONFIG_NFSD_V4_LOCALIO ) -extern const struct svc_version nfsd_localio_version4; -#else -#define nfsd_localio_version4 NULL -#endif -struct nfsd_net ;enum vers_op {NFSD_SET ,NFSD_CLEAR ,NFSD_TEST ,NFSD_AVAIL };
fs/nfsd/nfssvc.c +4 -55
86 lines not on this page · raw message
fs/nfsd/xdr.h +0 -6
@@ -5,7 +5,6 @@#define LINUX_NFSD_H #include <linux/vfs.h> -#include <linux/uuid.h> #include "nfsd.h" #include "nfsfh.h"
@@ -124,11 +123,6 @@ struct nfsd_statfsres {struct kstatfs stats; }; -struct nfsd_getuuidres { -__be32 status; -uuid_t uuid; -}; -/* * Storage requirements for XDR arguments and results. */
Signature · 1 line
2.44.0
PATCH 3/3 SUNRPC: replace program list with program array
In reply to NeilBrownFrom: NeilBrown <[email protected]>
A service created with svc_create_pooled() can be given a linked list of programs and all of these will be served.
Using a linked list makes is cumbersome when there a several programs that can be optionally selection with CONFIG settings.
So change to use an array with explicit size. svc_create() is always passed a single program. svc_create_pooled() now must be used for multiple programs.
--- fs/nfsd/nfsctl.c | 2 +- fs/nfsd/nfsd.h | 2 +- fs/nfsd/nfssvc.c | 69 ++++++++++++++++++-------------------- include/linux/sunrpc/svc.h | 7 ++-- net/sunrpc/svc.c | 68 +++++++++++++++++++++---------------- net/sunrpc/svc_xprt.c | 2 +- net/sunrpc/svcauth_unix.c | 3 +- 7 files changed, 80 insertions(+), 73 deletions(-)
fs/nfsd/nfsctl.c +1 -1
@@ -2265,7 +2265,7 @@ static __net_init int nfsd_net_init(struct net *net)if (retval) goto out_repcache_error;memset (&nn->nfsd_svcstats,0 ,sizeof (nn->nfsd_svcstats)); - nn->nfsd_svcstats.program = &nfsd_program; + nn->nfsd_svcstats.program = &nfsd_programs[0 ]; nn->nfsd_versions =NULL ; nn->nfsd4_minorversions =NULL ;nfsd4_init_leases_net (nn);
fs/nfsd/nfsd.h +1 -1
@@ -80,7 +80,7 @@ struct nfsd_genl_rqstp {u32 rq_opnum[NFSD_MAX_OPS_PER_COMPOUND ]; }; -extern struct svc_program nfsd_program; +extern struct svc_program nfsd_programs[];extern const struct svc_version nfsd_version2, nfsd_version3, nfsd_version4;extern struct mutex nfsd_mutex;extern spinlock_t nfsd_drc_lock;
fs/nfsd/nfssvc.c +32 -37
110 lines not on this page · raw message
include/linux/sunrpc/svc.h +4 -3
@@ -66,9 +66,10 @@ enum {* We currently do not support more than one RPC program per daemon. */ struct svc_serv { -struct svc_program * sv_program;/* RPC program */ +struct svc_program * sv_programs;/* RPC programs */ struct svc_stat * sv_stats;/* RPC statistics */ spinlock_t sv_lock; +unsigned int sv_nprogs;/* Number of sv_programs */ unsigned int sv_nrthreads;/* # of server threads */ unsigned int sv_maxconn;/* max connections allowed or * '0' causing max to be based
@@ -329,10 +330,9 @@ struct svc_process_info { };/* -* List of RPC programs on the same transport endpoint +* RPC program - an array of these can use the same transport endpoint */ struct svc_program { -struct svc_program * pg_next;/* other programs (same xprt) */ u32 pg_prog;/* program number */ unsigned int pg_lovers;/* lowest version */ unsigned int pg_hivers;/* highest version */
@@ -414,6 +414,7 @@ void svc_rqst_release_pages(struct svc_rqst *rqstp);void svc_rqst_free (struct svc_rqst *);void svc_exit_thread (struct svc_rqst *);struct svc_serv *svc_create_pooled (struct svc_program *prog, +unsigned int nprog,struct svc_stat *stats,unsigned int bufsize,int (*threadfn)(void *data));
net/sunrpc/svc.c +39 -29
166 lines not on this page · raw message
net/sunrpc/svc_xprt.c +1 -1
@@ -268,7 +268,7 @@ static int _svc_xprt_create(struct svc_serv *serv, const char *xprt_name,spin_unlock (&svc_xprt_class_lock); newxprt = xcl->xcl_ops->xpo_create (serv, net, sap, len, flags);if (IS_ERR (newxprt)) { -trace_svc_xprt_create_err (serv->sv_program->pg_name, +trace_svc_xprt_create_err (serv->sv_programs->pg_name, xcl->xcl_name, sap, len, newxprt);module_put (xcl->xcl_owner);
net/sunrpc/svcauth_unix.c +2 -1
@@ -697,7 +697,8 @@ svcauth_unix_set_client(struct svc_rqst *rqstp) rqstp->rq_auth_stat = rpc_autherr_badcred; ipm =ip_map_cached_get (xprt);if (ipm ==NULL ) - ipm =__ip_map_lookup (sn->ip_map_cache, rqstp->rq_server->sv_program->pg_class, + ipm =__ip_map_lookup (sn->ip_map_cache, + rqstp->rq_server->sv_programs->pg_class, &sin6->sin6_addr);if (ipm ==NULL )
Signature · 1 line
2.44.0