From: Dhaval Giani Date: Wed, 26 Jul 2017 17:16:50 +0000 (-0400) Subject: Revert "NFSv4: Fix callback server shutdown" X-Git-Tag: v4.1.12-107.0.20170801_2000~19 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=15de9d720a3fe5736a2454dae6b37cf18c301bbc;p=users%2Fjedix%2Flinux-maple.git Revert "NFSv4: Fix callback server shutdown" This reverts commit 13757272bec28f1b8be59f56292e8f17076923b3. Orabug: 26479081 Signed-off-by: Dhaval Giani Reviewed-by: Brian Maly --- diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 8481d457c36d..df57bdcb4d50 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -77,10 +77,7 @@ nfs4_callback_svc(void *vrqstp) set_freezable(); - while (!kthread_freezable_should_stop(NULL)) { - - if (signal_pending(current)) - flush_signals(current); + while (!kthread_should_stop()) { /* * Listen for a request on the socket */ @@ -89,8 +86,6 @@ nfs4_callback_svc(void *vrqstp) continue; svc_process(rqstp); } - svc_exit_thread(rqstp); - module_put_and_exit(0); return 0; } @@ -136,10 +131,9 @@ nfs41_callback_svc(void *vrqstp) set_freezable(); - while (!kthread_freezable_should_stop(NULL)) { - - if (signal_pending(current)) - flush_signals(current); + while (!kthread_should_stop()) { + if (try_to_freeze()) + continue; prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE); spin_lock_bh(&serv->sv_cb_lock); @@ -155,13 +149,11 @@ nfs41_callback_svc(void *vrqstp) error); } else { spin_unlock_bh(&serv->sv_cb_lock); - if (!kthread_should_stop()) - schedule(); + schedule(); finish_wait(&serv->sv_cb_waitq, &wq); } + flush_signals(current); } - svc_exit_thread(rqstp); - module_put_and_exit(0); return 0; } diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 1e1a55c71036..fae6fb947fc8 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -437,7 +437,6 @@ struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, void (*shutdown)(struct svc_serv *, struct net *net), svc_thread_fn, struct module *); 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_destroy(struct svc_serv *); void svc_shutdown_net(struct svc_serv *, struct net *); diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index b9a699ca3894..ec97d7985859 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -787,44 +787,6 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs) } EXPORT_SYMBOL_GPL(svc_set_num_threads); -/* destroy old threads */ -static int -svc_stop_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; - kthread_stop(task); - nrservs++; - } while (nrservs < 0); - return 0; -} - -int -svc_set_num_threads_sync(struct svc_serv *serv, struct svc_pool *pool, int nrservs) -{ - if (pool == NULL) { - /* The -1 assumes caller has done a svc_get() */ - nrservs -= (serv->sv_nrthreads-1); - } 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_stop_kthreads(serv, pool, nrservs); - return 0; -} -EXPORT_SYMBOL_GPL(svc_set_num_threads_sync); - /* * Called from a server thread as it's exiting. Caller must hold the "service * mutex" for the service.