Commit 758f62ff authored by Jeff Layton's avatar Jeff Layton Committed by J. Bruce Fields

nfsd/sunrpc: move sv_module parm into sv_ops

...not technically an operation, but it's more convenient and cleaner
to pass the module pointer in this struct.
Signed-off-by: default avatarShirley Ma <shirley.ma@oracle.com>
Acked-by: default avatarJeff Layton <jlayton@primarydata.com>
Tested-by: default avatarShirley Ma <shirley.ma@oracle.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent c369014f
...@@ -394,6 +394,7 @@ static int nfsd_get_default_max_blksize(void) ...@@ -394,6 +394,7 @@ static int nfsd_get_default_max_blksize(void)
static struct svc_serv_ops nfsd_sv_ops = { static struct svc_serv_ops nfsd_sv_ops = {
.svo_shutdown = nfsd_last_thread, .svo_shutdown = nfsd_last_thread,
.svo_function = nfsd, .svo_function = nfsd,
.svo_module = THIS_MODULE,
}; };
int nfsd_create_serv(struct net *net) int nfsd_create_serv(struct net *net)
...@@ -410,7 +411,7 @@ int nfsd_create_serv(struct net *net) ...@@ -410,7 +411,7 @@ int nfsd_create_serv(struct net *net)
nfsd_max_blksize = nfsd_get_default_max_blksize(); nfsd_max_blksize = nfsd_get_default_max_blksize();
nfsd_reset_versions(); nfsd_reset_versions();
nn->nfsd_serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize, nn->nfsd_serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize,
&nfsd_sv_ops, THIS_MODULE); &nfsd_sv_ops);
if (nn->nfsd_serv == NULL) if (nn->nfsd_serv == NULL)
return -ENOMEM; return -ENOMEM;
......
...@@ -54,7 +54,12 @@ struct svc_serv; ...@@ -54,7 +54,12 @@ struct svc_serv;
struct svc_serv_ops { struct svc_serv_ops {
/* Callback to use when last thread exits. */ /* Callback to use when last thread exits. */
void (*svo_shutdown)(struct svc_serv *, struct net *); void (*svo_shutdown)(struct svc_serv *, struct net *);
/* function for service threads to run */
int (*svo_function)(void *); int (*svo_function)(void *);
/* optional module to count when adding threads (pooled svcs only) */
struct module *svo_module;
}; };
/* /*
...@@ -89,8 +94,6 @@ struct svc_serv { ...@@ -89,8 +94,6 @@ struct svc_serv {
unsigned int sv_nrpools; /* number of thread pools */ unsigned int sv_nrpools; /* number of thread pools */
struct svc_pool * sv_pools; /* array of thread pools */ struct svc_pool * sv_pools; /* array of thread pools */
struct svc_serv_ops *sv_ops; /* server operations */ struct svc_serv_ops *sv_ops; /* server operations */
struct module * sv_module; /* optional module to count when
* adding threads */
#if defined(CONFIG_SUNRPC_BACKCHANNEL) #if defined(CONFIG_SUNRPC_BACKCHANNEL)
struct list_head sv_cb_list; /* queue for callback requests struct list_head sv_cb_list; /* queue for callback requests
* that arrive over the same * that arrive over the same
...@@ -430,7 +433,7 @@ struct svc_rqst *svc_prepare_thread(struct svc_serv *serv, ...@@ -430,7 +433,7 @@ struct svc_rqst *svc_prepare_thread(struct svc_serv *serv,
struct svc_pool *pool, int node); struct svc_pool *pool, int node);
void svc_exit_thread(struct svc_rqst *); void svc_exit_thread(struct svc_rqst *);
struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,
struct svc_serv_ops *, struct module *); struct svc_serv_ops *);
int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
int svc_pool_stats_open(struct svc_serv *serv, struct file *file); int svc_pool_stats_open(struct svc_serv *serv, struct file *file);
void svc_destroy(struct svc_serv *); void svc_destroy(struct svc_serv *);
......
...@@ -494,7 +494,7 @@ EXPORT_SYMBOL_GPL(svc_create); ...@@ -494,7 +494,7 @@ EXPORT_SYMBOL_GPL(svc_create);
struct svc_serv * struct svc_serv *
svc_create_pooled(struct svc_program *prog, unsigned int bufsize, svc_create_pooled(struct svc_program *prog, unsigned int bufsize,
struct svc_serv_ops *ops, struct module *mod) struct svc_serv_ops *ops)
{ {
struct svc_serv *serv; struct svc_serv *serv;
unsigned int npools = svc_pool_map_get(); unsigned int npools = svc_pool_map_get();
...@@ -502,8 +502,6 @@ svc_create_pooled(struct svc_program *prog, unsigned int bufsize, ...@@ -502,8 +502,6 @@ svc_create_pooled(struct svc_program *prog, unsigned int bufsize,
serv = __svc_create(prog, bufsize, npools, ops); serv = __svc_create(prog, bufsize, npools, ops);
if (!serv) if (!serv)
goto out_err; goto out_err;
serv->sv_module = mod;
return serv; return serv;
out_err: out_err:
svc_pool_map_put(); svc_pool_map_put();
...@@ -737,12 +735,12 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) ...@@ -737,12 +735,12 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
break; break;
} }
__module_get(serv->sv_module); __module_get(serv->sv_ops->svo_module);
task = kthread_create_on_node(serv->sv_ops->svo_function, rqstp, task = kthread_create_on_node(serv->sv_ops->svo_function, rqstp,
node, "%s", serv->sv_name); node, "%s", serv->sv_name);
if (IS_ERR(task)) { if (IS_ERR(task)) {
error = PTR_ERR(task); error = PTR_ERR(task);
module_put(serv->sv_module); module_put(serv->sv_ops->svo_module);
svc_exit_thread(rqstp); svc_exit_thread(rqstp);
break; break;
} }
......
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