NFSD: move accumulated callback ops to per-net namespace
Subsystems (2)
Dai Ngo
reviewerPATCH v4 1/1 NFSD: move accumulated callback ops to per-net namespace
Moves the callback RPC program, version, and stats structures from global statics into struct nfsd_net so that each network namespace gets its own callback counters and program definition.
Signed-off-by Dai Ngo <[email protected]>
--- fs/nfsd/nfs4callback.c | 75 ++++++++++++++++++++++-------------------- fs/nfsd/nfsctl.c | 5 +++ fs/nfsd/state.h | 2 ++ 3 files changed, 47 insertions(+), 35 deletions(-)
v2:
. free memory allocated for nn->nfsd_cb_version4.counts in
nfsd_net_cb_stats_init() on error in nfsd_net_init().
v3:
. reword commit message.
. fix initialization of nn->nfsd_cb_program.nrvers.
v4:
. fix merge conflict in nfsd_net_exit in nfsd-testing branch.
fs/nfsd/nfs4callback.c +40 -35
@@ -1016,7 +1016,7 @@ static int nfs4_xdr_dec_cb_offload(struct rpc_rqst *rqstp, .p_decode = nfs4_xdr_dec_##restype, \ .p_arglen = NFS4_enc_##argtype##_sz, \ .p_replen = NFS4_dec_##restype##_sz, \ - .p_statidx = NFSPROC4_CB_##call, \ + .p_statidx = NFSPROC4_CLNT_##proc, \ .p_name = #proc, \ }
@@ -1032,40 +1032,7 @@ static const struct rpc_procinfo nfs4_cb_procedures[] = { PROC(CB_GETATTR, COMPOUND, cb_getattr, cb_getattr), }; -static unsigned int nfs4_cb_counts[ARRAY_SIZE (nfs4_cb_procedures)]; -static const struct rpc_version nfs_cb_version4 = { -/* -* Note on the callback rpc program version number: despite language in rfc -* 5661 section 18.36.3 requiring servers to use 4 in this field, the -* official xdr descriptions for both 4.0 and 4.1 specify version 1, and -* in practice that appears to be what implementations use. The section -* 18.36.3 language is expected to be fixed in an erratum. -*/ - .number =1 , - .nrprocs =ARRAY_SIZE (nfs4_cb_procedures), - .procs = nfs4_cb_procedures, - .counts = nfs4_cb_counts, -}; - -static const struct rpc_version *nfs_cb_version[2 ] = { - [1 ] = &nfs_cb_version4, -}; - -static const struct rpc_program cb_program; - -static struct rpc_stat cb_stats = { - .program = &cb_program -}; -#define NFS4_CALLBACK 0x40000000 -static const struct rpc_program cb_program = { - .name ="nfs4_cb" , - .number =NFS4_CALLBACK , - .nrvers =ARRAY_SIZE (nfs_cb_version), - .version = nfs_cb_version, - .stats = &cb_stats, - .pipe_dir_name ="nfsd4_cb" , -};static int max_cb_time (struct net *net) {
@@ -1152,14 +1119,15 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c .addrsize = conn->cb_addrlen, .saddress = (struct sockaddr *) &conn->cb_saddr, .timeout = &timeparms, - .program = &cb_program, .version = 1, .flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET), .cred = current_cred(), };struct rpc_clnt *client;const struct cred *cred; +struct nfsd_net *nn =net_generic (clp->net, nfsd_net_id); + args.program = &nn->nfsd_cb_program;if (clp->cl_minorversion ==0 ) {if (!clp->cl_cred.cr_principal && (clp->cl_cred.cr_flavor >=RPC_AUTH_GSS_KRB5 )) {
@@ -1786,3 +1754,40 @@ bool nfsd4_run_cb(struct nfsd4_callback *cb)nfsd41_cb_inflight_end (clp);return queued; } + +void nfsd_net_cb_stats_shutdown (struct nfsd_net *nn) +{ +kfree (nn->nfsd_cb_version4.counts); +} + +int nfsd_net_cb_stats_init (struct nfsd_net *nn) +{ + nn->nfsd_cb_version4.counts = kzalloc_objs(unsigned int, +ARRAY_SIZE (nfs4_cb_procedures),GFP_KERNEL ); +if (!nn->nfsd_cb_version4.counts) +return -ENOMEM ; +/* +* Note on the callback rpc program version number: despite language +* in rfc 5661 section 18.36.3 requiring servers to use 4 in this +* field, the official xdr descriptions for both 4.0 and 4.1 specify +* version 1, and in practice that appears to be what implementations +* use. The section 18.36.3 language is expected to be fixed in an +* erratum. +*/ + nn->nfsd_cb_version4.number =1 ; + + nn->nfsd_cb_version4.nrprocs =ARRAY_SIZE (nfs4_cb_procedures); + nn->nfsd_cb_version4.procs = nfs4_cb_procedures; + nn->nfsd_cb_versions[1 ] = &nn->nfsd_cb_version4; + +memset (&nn->nfsd_cb_stat,0 ,sizeof (nn->nfsd_cb_stat)); + nn->nfsd_cb_program.name ="nfs4_cb" ; + nn->nfsd_cb_program.number =NFS4_CALLBACK ; + nn->nfsd_cb_program.nrvers =ARRAY_SIZE (nn->nfsd_cb_versions); + nn->nfsd_cb_program.version = &nn->nfsd_cb_versions[0 ]; + nn->nfsd_cb_program.pipe_dir_name ="nfsd4_cb" ; + nn->nfsd_cb_program.stats = &nn->nfsd_cb_stat; + nn->nfsd_cb_stat.program = &nn->nfsd_cb_program; + +return 0 ; +}
fs/nfsd/nfsctl.c +5 -0
@@ -2216,6 +2216,9 @@ static __net_init int nfsd_net_init(struct net *net)int retval;int i; + retval =nfsd_net_cb_stats_init (nn); +if (retval) +return retval; retval =nfsd_export_init (net);if (retval) goto out_export_error;
@@ -2256,6 +2259,7 @@ static __net_init int nfsd_net_init(struct net *net) out_idmap_error:nfsd_export_shutdown (net); out_export_error: +nfsd_net_cb_stats_shutdown (nn);return retval; }
@@ -2286,6 +2290,7 @@ static __net_exit void nfsd_net_exit(struct net *net)struct nfsd_net *nn =net_generic (net, nfsd_net_id);kfree_sensitive (nn->fh_key); +nfsd_net_cb_stats_shutdown (nn);nfsd_proc_stat_shutdown (net);percpu_counter_destroy_many (nn->counter,NFSD_STATS_COUNTERS_NUM );nfsd_idmap_shutdown (net);
fs/nfsd/state.h +2 -0
@@ -893,4 +893,6 @@ struct nfsd4_get_dir_delegation;struct nfs4_delegation *nfsd_get_dir_deleg (struct nfsd4_compound_state *cstate,struct nfsd4_get_dir_delegation *gdd,struct nfsd_file *nf); +int nfsd_net_cb_stats_init (struct nfsd_net *nn); +void nfsd_net_cb_stats_shutdown (struct nfsd_net *nn);#endif /* NFSD4_STATE_H */
Signature · 1 line
2.47.3