Skip to content

Commit 37902c6

Browse files
committed
NFSD: Move svc_serv_ops::svo_function into struct svc_serv
Hoist svo_function back into svc_serv and remove struct svc_serv_ops, since the struct is now devoid of fields. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent f49169c commit 37902c6

5 files changed

Lines changed: 43 additions & 64 deletions

File tree

fs/lockd/svc.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,6 @@ static struct notifier_block lockd_inet6addr_notifier = {
349349
};
350350
#endif
351351

352-
static const struct svc_serv_ops lockd_sv_ops = {
353-
.svo_function = lockd,
354-
};
355-
356352
static int lockd_get(void)
357353
{
358354
struct svc_serv *serv;
@@ -376,7 +372,7 @@ static int lockd_get(void)
376372
nlm_timeout = LOCKD_DFLT_TIMEO;
377373
nlmsvc_timeout = nlm_timeout * HZ;
378374

379-
serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, &lockd_sv_ops);
375+
serv = svc_create(&nlmsvc_program, LOCKD_BUFSIZE, lockd);
380376
if (!serv) {
381377
printk(KERN_WARNING "lockd_up: create service failed\n");
382378
return -ENOMEM;

fs/nfs/callback.c

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -231,29 +231,10 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
231231
return ret;
232232
}
233233

234-
static const struct svc_serv_ops nfs40_cb_sv_ops = {
235-
.svo_function = nfs4_callback_svc,
236-
};
237-
#if defined(CONFIG_NFS_V4_1)
238-
static const struct svc_serv_ops nfs41_cb_sv_ops = {
239-
.svo_function = nfs41_callback_svc,
240-
};
241-
242-
static const struct svc_serv_ops *nfs4_cb_sv_ops[] = {
243-
[0] = &nfs40_cb_sv_ops,
244-
[1] = &nfs41_cb_sv_ops,
245-
};
246-
#else
247-
static const struct svc_serv_ops *nfs4_cb_sv_ops[] = {
248-
[0] = &nfs40_cb_sv_ops,
249-
[1] = NULL,
250-
};
251-
#endif
252-
253234
static struct svc_serv *nfs_callback_create_svc(int minorversion)
254235
{
255236
struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
256-
const struct svc_serv_ops *sv_ops;
237+
int (*threadfn)(void *data);
257238
struct svc_serv *serv;
258239

259240
/*
@@ -262,17 +243,6 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion)
262243
if (cb_info->serv)
263244
return svc_get(cb_info->serv);
264245

265-
switch (minorversion) {
266-
case 0:
267-
sv_ops = nfs4_cb_sv_ops[0];
268-
break;
269-
default:
270-
sv_ops = nfs4_cb_sv_ops[1];
271-
}
272-
273-
if (sv_ops == NULL)
274-
return ERR_PTR(-ENOTSUPP);
275-
276246
/*
277247
* Sanity check: if there's no task,
278248
* we should be the first user ...
@@ -281,7 +251,16 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion)
281251
printk(KERN_WARNING "nfs_callback_create_svc: no kthread, %d users??\n",
282252
cb_info->users);
283253

284-
serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, sv_ops);
254+
threadfn = nfs4_callback_svc;
255+
#if defined(CONFIG_NFS_V4_1)
256+
if (minorversion)
257+
threadfn = nfs41_callback_svc;
258+
#else
259+
if (minorversion)
260+
return ERR_PTR(-ENOTSUPP);
261+
#endif
262+
serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE,
263+
threadfn);
285264
if (!serv) {
286265
printk(KERN_ERR "nfs_callback_create_svc: create service failed\n");
287266
return ERR_PTR(-ENOMEM);

fs/nfsd/nfssvc.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,6 @@ static int nfsd_get_default_max_blksize(void)
612612
return ret;
613613
}
614614

615-
static const struct svc_serv_ops nfsd_thread_sv_ops = {
616-
.svo_function = nfsd,
617-
};
618-
619615
void nfsd_shutdown_threads(struct net *net)
620616
{
621617
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
@@ -654,8 +650,7 @@ int nfsd_create_serv(struct net *net)
654650
if (nfsd_max_blksize == 0)
655651
nfsd_max_blksize = nfsd_get_default_max_blksize();
656652
nfsd_reset_versions(nn);
657-
serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize,
658-
&nfsd_thread_sv_ops);
653+
serv = svc_create_pooled(&nfsd_program, nfsd_max_blksize, nfsd);
659654
if (serv == NULL)
660655
return -ENOMEM;
661656

include/linux/sunrpc/svc.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ struct svc_pool {
5252
unsigned long sp_flags;
5353
} ____cacheline_aligned_in_smp;
5454

55-
struct svc_serv;
56-
57-
struct svc_serv_ops {
58-
/* function for service threads to run */
59-
int (*svo_function)(void *);
60-
};
61-
6255
/*
6356
* RPC service.
6457
*
@@ -91,7 +84,8 @@ struct svc_serv {
9184

9285
unsigned int sv_nrpools; /* number of thread pools */
9386
struct svc_pool * sv_pools; /* array of thread pools */
94-
const struct svc_serv_ops *sv_ops; /* server operations */
87+
int (*sv_threadfn)(void *data);
88+
9589
#if defined(CONFIG_SUNRPC_BACKCHANNEL)
9690
struct list_head sv_cb_list; /* queue for callback requests
9791
* that arrive over the same
@@ -492,15 +486,15 @@ int svc_rpcb_setup(struct svc_serv *serv, struct net *net);
492486
void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net);
493487
int svc_bind(struct svc_serv *serv, struct net *net);
494488
struct svc_serv *svc_create(struct svc_program *, unsigned int,
495-
const struct svc_serv_ops *);
489+
int (*threadfn)(void *data));
496490
struct svc_rqst *svc_rqst_alloc(struct svc_serv *serv,
497491
struct svc_pool *pool, int node);
498492
void svc_rqst_replace_page(struct svc_rqst *rqstp,
499493
struct page *page);
500494
void svc_rqst_free(struct svc_rqst *);
501495
void svc_exit_thread(struct svc_rqst *);
502496
struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,
503-
const struct svc_serv_ops *);
497+
int (*threadfn)(void *data));
504498
int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
505499
int svc_pool_stats_open(struct svc_serv *serv, struct file *file);
506500
int svc_process(struct svc_rqst *);

net/sunrpc/svc.c

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ __svc_init_bc(struct svc_serv *serv)
448448
*/
449449
static struct svc_serv *
450450
__svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
451-
const struct svc_serv_ops *ops)
451+
int (*threadfn)(void *data))
452452
{
453453
struct svc_serv *serv;
454454
unsigned int vers;
@@ -465,7 +465,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
465465
bufsize = RPCSVC_MAXPAYLOAD;
466466
serv->sv_max_payload = bufsize? bufsize : 4096;
467467
serv->sv_max_mesg = roundup(serv->sv_max_payload + PAGE_SIZE, PAGE_SIZE);
468-
serv->sv_ops = ops;
468+
serv->sv_threadfn = threadfn;
469469
xdrsize = 0;
470470
while (prog) {
471471
prog->pg_lovers = prog->pg_nvers-1;
@@ -511,22 +511,37 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools,
511511
return serv;
512512
}
513513

514-
struct svc_serv *
515-
svc_create(struct svc_program *prog, unsigned int bufsize,
516-
const struct svc_serv_ops *ops)
514+
/**
515+
* svc_create - Create an RPC service
516+
* @prog: the RPC program the new service will handle
517+
* @bufsize: maximum message size for @prog
518+
* @threadfn: a function to service RPC requests for @prog
519+
*
520+
* Returns an instantiated struct svc_serv object or NULL.
521+
*/
522+
struct svc_serv *svc_create(struct svc_program *prog, unsigned int bufsize,
523+
int (*threadfn)(void *data))
517524
{
518-
return __svc_create(prog, bufsize, /*npools*/1, ops);
525+
return __svc_create(prog, bufsize, 1, threadfn);
519526
}
520527
EXPORT_SYMBOL_GPL(svc_create);
521528

522-
struct svc_serv *
523-
svc_create_pooled(struct svc_program *prog, unsigned int bufsize,
524-
const struct svc_serv_ops *ops)
529+
/**
530+
* svc_create_pooled - Create an RPC service with pooled threads
531+
* @prog: the RPC program the new service will handle
532+
* @bufsize: maximum message size for @prog
533+
* @threadfn: a function to service RPC requests for @prog
534+
*
535+
* Returns an instantiated struct svc_serv object or NULL.
536+
*/
537+
struct svc_serv *svc_create_pooled(struct svc_program *prog,
538+
unsigned int bufsize,
539+
int (*threadfn)(void *data))
525540
{
526541
struct svc_serv *serv;
527542
unsigned int npools = svc_pool_map_get();
528543

529-
serv = __svc_create(prog, bufsize, npools, ops);
544+
serv = __svc_create(prog, bufsize, npools, threadfn);
530545
if (!serv)
531546
goto out_err;
532547
return serv;
@@ -736,7 +751,7 @@ svc_start_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
736751
if (IS_ERR(rqstp))
737752
return PTR_ERR(rqstp);
738753

739-
task = kthread_create_on_node(serv->sv_ops->svo_function, rqstp,
754+
task = kthread_create_on_node(serv->sv_threadfn, rqstp,
740755
node, "%s", serv->sv_name);
741756
if (IS_ERR(task)) {
742757
svc_exit_thread(rqstp);

0 commit comments

Comments
 (0)