Commit 39039024 authored by NeilBrown's avatar NeilBrown Committed by Chuck Lever

nfsd: don't allow nfsd threads to be signalled.

The original implementation of nfsd used signals to stop threads during
shutdown.
In Linux 2.3.46pre5 nfsd gained the ability to shutdown threads
internally it if was asked to run "0" threads.  After this user-space
transitioned to using "rpc.nfsd 0" to stop nfsd and sending signals to
threads was no longer an important part of the API.

In commit 3ebdbe52 ("SUNRPC: discard svo_setup and rename
svc_set_num_threads_sync()") (v5.17-rc1~75^2~41) we finally removed the
use of signals for stopping threads, using kthread_stop() instead.

This patch makes the "obvious" next step and removes the ability to
signal nfsd threads - or any svc threads.  nfsd stops allowing signals
and we don't check for their delivery any more.

This will allow for some simplification in later patches.

A change worth noting is in nfsd4_ssc_setup_dul().  There was previously
a signal_pending() check which would only succeed when the thread was
being shut down.  It should really have tested kthread_should_stop() as
well.  Now it just does the latter, not the former.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 8db14cad
...@@ -80,9 +80,6 @@ nfs4_callback_svc(void *vrqstp) ...@@ -80,9 +80,6 @@ nfs4_callback_svc(void *vrqstp)
set_freezable(); set_freezable();
while (!kthread_freezable_should_stop(NULL)) { while (!kthread_freezable_should_stop(NULL)) {
if (signal_pending(current))
flush_signals(current);
/* /*
* Listen for a request on the socket * Listen for a request on the socket
*/ */
...@@ -112,11 +109,7 @@ nfs41_callback_svc(void *vrqstp) ...@@ -112,11 +109,7 @@ nfs41_callback_svc(void *vrqstp)
set_freezable(); set_freezable();
while (!kthread_freezable_should_stop(NULL)) { while (!kthread_freezable_should_stop(NULL)) {
prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_IDLE);
if (signal_pending(current))
flush_signals(current);
prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE);
spin_lock_bh(&serv->sv_cb_lock); spin_lock_bh(&serv->sv_cb_lock);
if (!list_empty(&serv->sv_cb_list)) { if (!list_empty(&serv->sv_cb_list)) {
req = list_first_entry(&serv->sv_cb_list, req = list_first_entry(&serv->sv_cb_list,
......
...@@ -1347,12 +1347,11 @@ static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *nn, char *ipaddr, ...@@ -1347,12 +1347,11 @@ static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *nn, char *ipaddr,
/* found a match */ /* found a match */
if (ni->nsui_busy) { if (ni->nsui_busy) {
/* wait - and try again */ /* wait - and try again */
prepare_to_wait(&nn->nfsd_ssc_waitq, &wait, prepare_to_wait(&nn->nfsd_ssc_waitq, &wait, TASK_IDLE);
TASK_INTERRUPTIBLE);
spin_unlock(&nn->nfsd_ssc_lock); spin_unlock(&nn->nfsd_ssc_lock);
/* allow 20secs for mount/unmount for now - revisit */ /* allow 20secs for mount/unmount for now - revisit */
if (signal_pending(current) || if (kthread_should_stop() ||
(schedule_timeout(20*HZ) == 0)) { (schedule_timeout(20*HZ) == 0)) {
finish_wait(&nn->nfsd_ssc_waitq, &wait); finish_wait(&nn->nfsd_ssc_waitq, &wait);
kfree(work); kfree(work);
......
...@@ -965,15 +965,6 @@ nfsd(void *vrqstp) ...@@ -965,15 +965,6 @@ nfsd(void *vrqstp)
current->fs->umask = 0; current->fs->umask = 0;
/*
* thread is spawned with all signals set to SIG_IGN, re-enable
* the ones that will bring down the thread
*/
allow_signal(SIGKILL);
allow_signal(SIGHUP);
allow_signal(SIGINT);
allow_signal(SIGQUIT);
atomic_inc(&nfsdstats.th_cnt); atomic_inc(&nfsdstats.th_cnt);
set_freezable(); set_freezable();
...@@ -998,9 +989,6 @@ nfsd(void *vrqstp) ...@@ -998,9 +989,6 @@ nfsd(void *vrqstp)
validate_process_creds(); validate_process_creds();
} }
/* Clear signals before calling svc_exit_thread() */
flush_signals(current);
atomic_dec(&nfsdstats.th_cnt); atomic_dec(&nfsdstats.th_cnt);
out: out:
......
...@@ -701,8 +701,8 @@ static int svc_alloc_arg(struct svc_rqst *rqstp) ...@@ -701,8 +701,8 @@ static int svc_alloc_arg(struct svc_rqst *rqstp)
/* Made progress, don't sleep yet */ /* Made progress, don't sleep yet */
continue; continue;
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_IDLE);
if (signalled() || kthread_should_stop()) { if (kthread_should_stop()) {
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
return -EINTR; return -EINTR;
} }
...@@ -740,7 +740,7 @@ rqst_should_sleep(struct svc_rqst *rqstp) ...@@ -740,7 +740,7 @@ rqst_should_sleep(struct svc_rqst *rqstp)
return false; return false;
/* are we shutting down? */ /* are we shutting down? */
if (signalled() || kthread_should_stop()) if (kthread_should_stop())
return false; return false;
/* are we freezing? */ /* are we freezing? */
...@@ -762,11 +762,7 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) ...@@ -762,11 +762,7 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
if (rqstp->rq_xprt) if (rqstp->rq_xprt)
goto out_found; goto out_found;
/* set_current_state(TASK_IDLE);
* We have to be able to interrupt this wait
* to bring down the daemons ...
*/
set_current_state(TASK_INTERRUPTIBLE);
smp_mb__before_atomic(); smp_mb__before_atomic();
clear_bit(SP_CONGESTED, &pool->sp_flags); clear_bit(SP_CONGESTED, &pool->sp_flags);
clear_bit(RQ_BUSY, &rqstp->rq_flags); clear_bit(RQ_BUSY, &rqstp->rq_flags);
...@@ -788,7 +784,7 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) ...@@ -788,7 +784,7 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
if (!time_left) if (!time_left)
percpu_counter_inc(&pool->sp_threads_timedout); percpu_counter_inc(&pool->sp_threads_timedout);
if (signalled() || kthread_should_stop()) if (kthread_should_stop())
return ERR_PTR(-EINTR); return ERR_PTR(-EINTR);
return ERR_PTR(-EAGAIN); return ERR_PTR(-EAGAIN);
out_found: out_found:
...@@ -885,7 +881,7 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) ...@@ -885,7 +881,7 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
try_to_freeze(); try_to_freeze();
cond_resched(); cond_resched();
err = -EINTR; err = -EINTR;
if (signalled() || kthread_should_stop()) if (kthread_should_stop())
goto out; goto out;
xprt = svc_get_next_xprt(rqstp, timeout); xprt = svc_get_next_xprt(rqstp, timeout);
......
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