Skip to content

Commit 3ebdbe5

Browse files
neilbrownchucklever
authored andcommitted
SUNRPC: discard svo_setup and rename svc_set_num_threads_sync()
The ->svo_setup callback serves no purpose. It is always called from within the same module that chooses which callback is needed. So discard it and call the relevant function directly. Now that svc_set_num_threads() is no longer used remove it and rename svc_set_num_threads_sync() to remove the "_sync" suffix. Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 3409e4f commit 3ebdbe5

File tree

4 files changed

+10
-62
lines changed

4 files changed

+10
-62
lines changed

fs/nfs/callback.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
172172
if (serv->sv_nrthreads == nrservs)
173173
return 0;
174174

175-
ret = serv->sv_ops->svo_setup(serv, NULL, nrservs);
175+
ret = svc_set_num_threads(serv, NULL, nrservs);
176176
if (ret) {
177-
serv->sv_ops->svo_setup(serv, NULL, 0);
177+
svc_set_num_threads(serv, NULL, 0);
178178
return ret;
179179
}
180180
dprintk("nfs_callback_up: service started\n");
@@ -235,14 +235,12 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
235235
static const struct svc_serv_ops nfs40_cb_sv_ops = {
236236
.svo_function = nfs4_callback_svc,
237237
.svo_enqueue_xprt = svc_xprt_do_enqueue,
238-
.svo_setup = svc_set_num_threads_sync,
239238
.svo_module = THIS_MODULE,
240239
};
241240
#if defined(CONFIG_NFS_V4_1)
242241
static const struct svc_serv_ops nfs41_cb_sv_ops = {
243242
.svo_function = nfs41_callback_svc,
244243
.svo_enqueue_xprt = svc_xprt_do_enqueue,
245-
.svo_setup = svc_set_num_threads_sync,
246244
.svo_module = THIS_MODULE,
247245
};
248246

@@ -357,7 +355,7 @@ void nfs_callback_down(int minorversion, struct net *net)
357355
cb_info->users--;
358356
if (cb_info->users == 0) {
359357
svc_get(serv);
360-
serv->sv_ops->svo_setup(serv, NULL, 0);
358+
svc_set_num_threads(serv, NULL, 0);
361359
svc_put(serv);
362360
dprintk("nfs_callback_down: service destroyed\n");
363361
cb_info->serv = NULL;

fs/nfsd/nfssvc.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ static const struct svc_serv_ops nfsd_thread_sv_ops = {
593593
.svo_shutdown = nfsd_last_thread,
594594
.svo_function = nfsd,
595595
.svo_enqueue_xprt = svc_xprt_do_enqueue,
596-
.svo_setup = svc_set_num_threads_sync,
597596
.svo_module = THIS_MODULE,
598597
};
599598

@@ -611,7 +610,7 @@ void nfsd_shutdown_threads(struct net *net)
611610

612611
svc_get(serv);
613612
/* Kill outstanding nfsd threads */
614-
serv->sv_ops->svo_setup(serv, NULL, 0);
613+
svc_set_num_threads(serv, NULL, 0);
615614
nfsd_put(net);
616615
mutex_unlock(&nfsd_mutex);
617616
}
@@ -750,8 +749,9 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net)
750749
/* apply the new numbers */
751750
svc_get(nn->nfsd_serv);
752751
for (i = 0; i < n; i++) {
753-
err = nn->nfsd_serv->sv_ops->svo_setup(nn->nfsd_serv,
754-
&nn->nfsd_serv->sv_pools[i], nthreads[i]);
752+
err = svc_set_num_threads(nn->nfsd_serv,
753+
&nn->nfsd_serv->sv_pools[i],
754+
nthreads[i]);
755755
if (err)
756756
break;
757757
}
@@ -793,8 +793,7 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred)
793793
error = nfsd_startup_net(net, cred);
794794
if (error)
795795
goto out_put;
796-
error = nn->nfsd_serv->sv_ops->svo_setup(nn->nfsd_serv,
797-
NULL, nrservs);
796+
error = svc_set_num_threads(nn->nfsd_serv, NULL, nrservs);
798797
if (error)
799798
goto out_shutdown;
800799
error = nn->nfsd_serv->sv_nrthreads;

include/linux/sunrpc/svc.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ struct svc_serv_ops {
6464
/* queue up a transport for servicing */
6565
void (*svo_enqueue_xprt)(struct svc_xprt *);
6666

67-
/* set up thread (or whatever) execution context */
68-
int (*svo_setup)(struct svc_serv *, struct svc_pool *, int);
69-
7067
/* optional module to count when adding threads (pooled svcs only) */
7168
struct module *svo_module;
7269
};
@@ -541,7 +538,6 @@ void svc_pool_map_put(void);
541538
struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,
542539
const struct svc_serv_ops *);
543540
int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
544-
int svc_set_num_threads_sync(struct svc_serv *, struct svc_pool *, int);
545541
int svc_pool_stats_open(struct svc_serv *serv, struct file *file);
546542
void svc_shutdown_net(struct svc_serv *, struct net *);
547543
int svc_process(struct svc_rqst *);

net/sunrpc/svc.c

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -743,58 +743,13 @@ svc_start_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
743743
return 0;
744744
}
745745

746-
747-
/* destroy old threads */
748-
static int
749-
svc_signal_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
750-
{
751-
struct task_struct *task;
752-
unsigned int state = serv->sv_nrthreads-1;
753-
754-
/* destroy old threads */
755-
do {
756-
task = choose_victim(serv, pool, &state);
757-
if (task == NULL)
758-
break;
759-
send_sig(SIGINT, task, 1);
760-
nrservs++;
761-
} while (nrservs < 0);
762-
763-
return 0;
764-
}
765-
766746
/*
767747
* Create or destroy enough new threads to make the number
768748
* of threads the given number. If `pool' is non-NULL, applies
769749
* only to threads in that pool, otherwise round-robins between
770750
* all pools. Caller must ensure that mutual exclusion between this and
771751
* server startup or shutdown.
772-
*
773-
* Destroying threads relies on the service threads filling in
774-
* rqstp->rq_task, which only the nfs ones do. Assumes the serv
775-
* has been created using svc_create_pooled().
776-
*
777-
* Based on code that used to be in nfsd_svc() but tweaked
778-
* to be pool-aware.
779752
*/
780-
int
781-
svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
782-
{
783-
if (pool == NULL) {
784-
nrservs -= serv->sv_nrthreads;
785-
} else {
786-
spin_lock_bh(&pool->sp_lock);
787-
nrservs -= pool->sp_nrthreads;
788-
spin_unlock_bh(&pool->sp_lock);
789-
}
790-
791-
if (nrservs > 0)
792-
return svc_start_kthreads(serv, pool, nrservs);
793-
if (nrservs < 0)
794-
return svc_signal_kthreads(serv, pool, nrservs);
795-
return 0;
796-
}
797-
EXPORT_SYMBOL_GPL(svc_set_num_threads);
798753

799754
/* destroy old threads */
800755
static int
@@ -815,7 +770,7 @@ svc_stop_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
815770
}
816771

817772
int
818-
svc_set_num_threads_sync(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
773+
svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
819774
{
820775
if (pool == NULL) {
821776
nrservs -= serv->sv_nrthreads;
@@ -831,7 +786,7 @@ svc_set_num_threads_sync(struct svc_serv *serv, struct svc_pool *pool, int nrser
831786
return svc_stop_kthreads(serv, pool, nrservs);
832787
return 0;
833788
}
834-
EXPORT_SYMBOL_GPL(svc_set_num_threads_sync);
789+
EXPORT_SYMBOL_GPL(svc_set_num_threads);
835790

836791
/**
837792
* svc_rqst_replace_page - Replace one page in rq_pages[]

0 commit comments

Comments
 (0)