Skip to content

Commit 3903902

Browse files
neilbrownchucklever
authored andcommitted
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 3ebdbe5 ("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: NeilBrown <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 8db14ca commit 3903902

File tree

4 files changed

+9
-33
lines changed

4 files changed

+9
-33
lines changed

fs/nfs/callback.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ nfs4_callback_svc(void *vrqstp)
8080
set_freezable();
8181

8282
while (!kthread_freezable_should_stop(NULL)) {
83-
84-
if (signal_pending(current))
85-
flush_signals(current);
8683
/*
8784
* Listen for a request on the socket
8885
*/
@@ -112,11 +109,7 @@ nfs41_callback_svc(void *vrqstp)
112109
set_freezable();
113110

114111
while (!kthread_freezable_should_stop(NULL)) {
115-
116-
if (signal_pending(current))
117-
flush_signals(current);
118-
119-
prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE);
112+
prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_IDLE);
120113
spin_lock_bh(&serv->sv_cb_lock);
121114
if (!list_empty(&serv->sv_cb_list)) {
122115
req = list_first_entry(&serv->sv_cb_list,

fs/nfsd/nfs4proc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,12 +1347,11 @@ static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *nn, char *ipaddr,
13471347
/* found a match */
13481348
if (ni->nsui_busy) {
13491349
/* wait - and try again */
1350-
prepare_to_wait(&nn->nfsd_ssc_waitq, &wait,
1351-
TASK_INTERRUPTIBLE);
1350+
prepare_to_wait(&nn->nfsd_ssc_waitq, &wait, TASK_IDLE);
13521351
spin_unlock(&nn->nfsd_ssc_lock);
13531352

13541353
/* allow 20secs for mount/unmount for now - revisit */
1355-
if (signal_pending(current) ||
1354+
if (kthread_should_stop() ||
13561355
(schedule_timeout(20*HZ) == 0)) {
13571356
finish_wait(&nn->nfsd_ssc_waitq, &wait);
13581357
kfree(work);

fs/nfsd/nfssvc.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -965,15 +965,6 @@ nfsd(void *vrqstp)
965965

966966
current->fs->umask = 0;
967967

968-
/*
969-
* thread is spawned with all signals set to SIG_IGN, re-enable
970-
* the ones that will bring down the thread
971-
*/
972-
allow_signal(SIGKILL);
973-
allow_signal(SIGHUP);
974-
allow_signal(SIGINT);
975-
allow_signal(SIGQUIT);
976-
977968
atomic_inc(&nfsdstats.th_cnt);
978969

979970
set_freezable();
@@ -998,9 +989,6 @@ nfsd(void *vrqstp)
998989
validate_process_creds();
999990
}
1000991

1001-
/* Clear signals before calling svc_exit_thread() */
1002-
flush_signals(current);
1003-
1004992
atomic_dec(&nfsdstats.th_cnt);
1005993

1006994
out:

net/sunrpc/svc_xprt.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,8 @@ static int svc_alloc_arg(struct svc_rqst *rqstp)
701701
/* Made progress, don't sleep yet */
702702
continue;
703703

704-
set_current_state(TASK_INTERRUPTIBLE);
705-
if (signalled() || kthread_should_stop()) {
704+
set_current_state(TASK_IDLE);
705+
if (kthread_should_stop()) {
706706
set_current_state(TASK_RUNNING);
707707
return -EINTR;
708708
}
@@ -740,7 +740,7 @@ rqst_should_sleep(struct svc_rqst *rqstp)
740740
return false;
741741

742742
/* are we shutting down? */
743-
if (signalled() || kthread_should_stop())
743+
if (kthread_should_stop())
744744
return false;
745745

746746
/* are we freezing? */
@@ -762,11 +762,7 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout)
762762
if (rqstp->rq_xprt)
763763
goto out_found;
764764

765-
/*
766-
* We have to be able to interrupt this wait
767-
* to bring down the daemons ...
768-
*/
769-
set_current_state(TASK_INTERRUPTIBLE);
765+
set_current_state(TASK_IDLE);
770766
smp_mb__before_atomic();
771767
clear_bit(SP_CONGESTED, &pool->sp_flags);
772768
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)
788784
if (!time_left)
789785
percpu_counter_inc(&pool->sp_threads_timedout);
790786

791-
if (signalled() || kthread_should_stop())
787+
if (kthread_should_stop())
792788
return ERR_PTR(-EINTR);
793789
return ERR_PTR(-EAGAIN);
794790
out_found:
@@ -885,7 +881,7 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
885881
try_to_freeze();
886882
cond_resched();
887883
err = -EINTR;
888-
if (signalled() || kthread_should_stop())
884+
if (kthread_should_stop())
889885
goto out;
890886

891887
xprt = svc_get_next_xprt(rqstp, timeout);

0 commit comments

Comments
 (0)