SUNRPC: discard svo_setup and rename svc_set_num_threads_sync()
authorNeilBrown <neilb@suse.de>
Mon, 29 Nov 2021 04:51:25 +0000 (15:51 +1100)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 13 Dec 2021 18:42:53 +0000 (13:42 -0500)
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 <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfs/callback.c
fs/nfsd/nfssvc.c
include/linux/sunrpc/svc.h
net/sunrpc/svc.c

index d9d78ffd1d653e067de5e3e1d66aa2d852cd1a54..6cdc9d18a7dd39396bb474751048df7fde81c172 100644 (file)
@@ -172,9 +172,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
        if (serv->sv_nrthreads == nrservs)
                return 0;
 
-       ret = serv->sv_ops->svo_setup(serv, NULL, nrservs);
+       ret = svc_set_num_threads(serv, NULL, nrservs);
        if (ret) {
-               serv->sv_ops->svo_setup(serv, NULL, 0);
+               svc_set_num_threads(serv, NULL, 0);
                return ret;
        }
        dprintk("nfs_callback_up: service started\n");
@@ -235,14 +235,12 @@ err_bind:
 static const struct svc_serv_ops nfs40_cb_sv_ops = {
        .svo_function           = nfs4_callback_svc,
        .svo_enqueue_xprt       = svc_xprt_do_enqueue,
-       .svo_setup              = svc_set_num_threads_sync,
        .svo_module             = THIS_MODULE,
 };
 #if defined(CONFIG_NFS_V4_1)
 static const struct svc_serv_ops nfs41_cb_sv_ops = {
        .svo_function           = nfs41_callback_svc,
        .svo_enqueue_xprt       = svc_xprt_do_enqueue,
-       .svo_setup              = svc_set_num_threads_sync,
        .svo_module             = THIS_MODULE,
 };
 
@@ -357,7 +355,7 @@ void nfs_callback_down(int minorversion, struct net *net)
        cb_info->users--;
        if (cb_info->users == 0) {
                svc_get(serv);
-               serv->sv_ops->svo_setup(serv, NULL, 0);
+               svc_set_num_threads(serv, NULL, 0);
                svc_put(serv);
                dprintk("nfs_callback_down: service destroyed\n");
                cb_info->serv = NULL;
index d0d9107a1b93dacd66fa3e38cf7b9eed976a5143..020156e96bdb507ab4ad591f900d906fdd6a36d8 100644 (file)
@@ -593,7 +593,6 @@ static const struct svc_serv_ops nfsd_thread_sv_ops = {
        .svo_shutdown           = nfsd_last_thread,
        .svo_function           = nfsd,
        .svo_enqueue_xprt       = svc_xprt_do_enqueue,
-       .svo_setup              = svc_set_num_threads_sync,
        .svo_module             = THIS_MODULE,
 };
 
@@ -611,7 +610,7 @@ void nfsd_shutdown_threads(struct net *net)
 
        svc_get(serv);
        /* Kill outstanding nfsd threads */
-       serv->sv_ops->svo_setup(serv, NULL, 0);
+       svc_set_num_threads(serv, NULL, 0);
        nfsd_put(net);
        mutex_unlock(&nfsd_mutex);
 }
@@ -750,8 +749,9 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net)
        /* apply the new numbers */
        svc_get(nn->nfsd_serv);
        for (i = 0; i < n; i++) {
-               err = nn->nfsd_serv->sv_ops->svo_setup(nn->nfsd_serv,
-                               &nn->nfsd_serv->sv_pools[i], nthreads[i]);
+               err = svc_set_num_threads(nn->nfsd_serv,
+                                         &nn->nfsd_serv->sv_pools[i],
+                                         nthreads[i]);
                if (err)
                        break;
        }
@@ -793,8 +793,7 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred)
        error = nfsd_startup_net(net, cred);
        if (error)
                goto out_put;
-       error = nn->nfsd_serv->sv_ops->svo_setup(nn->nfsd_serv,
-                       NULL, nrservs);
+       error = svc_set_num_threads(nn->nfsd_serv, NULL, nrservs);
        if (error)
                goto out_shutdown;
        error = nn->nfsd_serv->sv_nrthreads;
index 36bfc0281988b127f10461c9551d940072093a1a..0b38c6eaf9852192240f9c32c99dcddbb96674c8 100644 (file)
@@ -64,9 +64,6 @@ struct svc_serv_ops {
        /* queue up a transport for servicing */
        void            (*svo_enqueue_xprt)(struct svc_xprt *);
 
-       /* set up thread (or whatever) execution context */
-       int             (*svo_setup)(struct svc_serv *, struct svc_pool *, int);
-
        /* optional module to count when adding threads (pooled svcs only) */
        struct module   *svo_module;
 };
@@ -541,7 +538,6 @@ void                   svc_pool_map_put(void);
 struct svc_serv *  svc_create_pooled(struct svc_program *, unsigned int,
                        const struct svc_serv_ops *);
 int               svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
-int               svc_set_num_threads_sync(struct svc_serv *, struct svc_pool *, int);
 int               svc_pool_stats_open(struct svc_serv *serv, struct file *file);
 void              svc_shutdown_net(struct svc_serv *, struct net *);
 int               svc_process(struct svc_rqst *);
index 2b2042234e4bb9913a056b10a47e40f796930705..5513f8c9a8d6315a4ee78dfaa9e9f5a8b2d67646 100644 (file)
@@ -743,58 +743,13 @@ svc_start_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
        return 0;
 }
 
-
-/* destroy old threads */
-static int
-svc_signal_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
-{
-       struct task_struct *task;
-       unsigned int state = serv->sv_nrthreads-1;
-
-       /* destroy old threads */
-       do {
-               task = choose_victim(serv, pool, &state);
-               if (task == NULL)
-                       break;
-               send_sig(SIGINT, task, 1);
-               nrservs++;
-       } while (nrservs < 0);
-
-       return 0;
-}
-
 /*
  * Create or destroy enough new threads to make the number
  * of threads the given number.  If `pool' is non-NULL, applies
  * only to threads in that pool, otherwise round-robins between
  * all pools.  Caller must ensure that mutual exclusion between this and
  * server startup or shutdown.
- *
- * Destroying threads relies on the service threads filling in
- * rqstp->rq_task, which only the nfs ones do.  Assumes the serv
- * has been created using svc_create_pooled().
- *
- * Based on code that used to be in nfsd_svc() but tweaked
- * to be pool-aware.
  */
-int
-svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
-{
-       if (pool == NULL) {
-               nrservs -= serv->sv_nrthreads;
-       } else {
-               spin_lock_bh(&pool->sp_lock);
-               nrservs -= pool->sp_nrthreads;
-               spin_unlock_bh(&pool->sp_lock);
-       }
-
-       if (nrservs > 0)
-               return svc_start_kthreads(serv, pool, nrservs);
-       if (nrservs < 0)
-               return svc_signal_kthreads(serv, pool, nrservs);
-       return 0;
-}
-EXPORT_SYMBOL_GPL(svc_set_num_threads);
 
 /* destroy old threads */
 static int
@@ -815,7 +770,7 @@ svc_stop_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
 }
 
 int
-svc_set_num_threads_sync(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
+svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
 {
        if (pool == NULL) {
                nrservs -= serv->sv_nrthreads;
@@ -831,7 +786,7 @@ svc_set_num_threads_sync(struct svc_serv *serv, struct svc_pool *pool, int nrser
                return svc_stop_kthreads(serv, pool, nrservs);
        return 0;
 }
-EXPORT_SYMBOL_GPL(svc_set_num_threads_sync);
+EXPORT_SYMBOL_GPL(svc_set_num_threads);
 
 /**
  * svc_rqst_replace_page - Replace one page in rq_pages[]