aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfssvc.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2008-06-30 14:09:46 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-06-30 15:27:47 -0400
commit100766f8347c1aeb5a548c5c7aa9012f4a3276f1 (patch)
treefd9d011197bb466d49d102b5298f4293d18d311c /fs/nfsd/nfssvc.c
parent3cd2cfeae187fb754f9530e3f919256f350e89ca (diff)
nfsd: treat all shutdown signals as equivalent
knfsd currently uses 2 signal masks when processing requests. A "loose" mask (SHUTDOWN_SIGS) that it uses when receiving network requests, and then a more "strict" mask (ALLOWED_SIGS, which is just SIGKILL) that it allows when doing the actual operation on the local storage. This is apparently unnecessarily complicated. The underlying filesystem should be able to sanely handle a signal in the middle of an operation. This patch removes the signal mask handling from knfsd altogether. When knfsd is started as a kthread, all signals are ignored. It then allows all of the signals in SHUTDOWN_SIGS. There's no need to set the mask as well. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'fs/nfsd/nfssvc.c')
-rw-r--r--fs/nfsd/nfssvc.c30
1 files changed, 5 insertions, 25 deletions
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 96fdbcab8d95..80292ff5e924 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -37,15 +37,6 @@
37 37
38#define NFSDDBG_FACILITY NFSDDBG_SVC 38#define NFSDDBG_FACILITY NFSDDBG_SVC
39 39
40/* these signals will be delivered to an nfsd thread
41 * when handling a request
42 */
43#define ALLOWED_SIGS (sigmask(SIGKILL))
44/* these signals will be delivered to an nfsd thread
45 * when not handling a request. i.e. when waiting
46 */
47#define SHUTDOWN_SIGS (sigmask(SIGKILL) | sigmask(SIGHUP) | sigmask(SIGINT) | sigmask(SIGQUIT))
48
49extern struct svc_program nfsd_program; 40extern struct svc_program nfsd_program;
50static int nfsd(void *vrqstp); 41static int nfsd(void *vrqstp);
51struct timeval nfssvc_boot; 42struct timeval nfssvc_boot;
@@ -414,9 +405,7 @@ nfsd(void *vrqstp)
414{ 405{
415 struct svc_rqst *rqstp = (struct svc_rqst *) vrqstp; 406 struct svc_rqst *rqstp = (struct svc_rqst *) vrqstp;
416 struct fs_struct *fsp; 407 struct fs_struct *fsp;
417 sigset_t shutdown_mask, allowed_mask;
418 int err, preverr = 0; 408 int err, preverr = 0;
419 unsigned int signo;
420 409
421 /* Lock module and set up kernel thread */ 410 /* Lock module and set up kernel thread */
422 mutex_lock(&nfsd_mutex); 411 mutex_lock(&nfsd_mutex);
@@ -433,17 +422,14 @@ nfsd(void *vrqstp)
433 current->fs = fsp; 422 current->fs = fsp;
434 current->fs->umask = 0; 423 current->fs->umask = 0;
435 424
436 siginitsetinv(&shutdown_mask, SHUTDOWN_SIGS);
437 siginitsetinv(&allowed_mask, ALLOWED_SIGS);
438
439 /* 425 /*
440 * thread is spawned with all signals set to SIG_IGN, re-enable 426 * thread is spawned with all signals set to SIG_IGN, re-enable
441 * the ones that matter 427 * the ones that will bring down the thread
442 */ 428 */
443 for (signo = 1; signo <= _NSIG; signo++) { 429 allow_signal(SIGKILL);
444 if (!sigismember(&shutdown_mask, signo)) 430 allow_signal(SIGHUP);
445 allow_signal(signo); 431 allow_signal(SIGINT);
446 } 432 allow_signal(SIGQUIT);
447 433
448 nfsdstats.th_cnt++; 434 nfsdstats.th_cnt++;
449 mutex_unlock(&nfsd_mutex); 435 mutex_unlock(&nfsd_mutex);
@@ -460,9 +446,6 @@ nfsd(void *vrqstp)
460 * The main request loop 446 * The main request loop
461 */ 447 */
462 for (;;) { 448 for (;;) {
463 /* Block all but the shutdown signals */
464 sigprocmask(SIG_SETMASK, &shutdown_mask, NULL);
465
466 /* 449 /*
467 * Find a socket with data available and call its 450 * Find a socket with data available and call its
468 * recvfrom routine. 451 * recvfrom routine.
@@ -487,9 +470,6 @@ nfsd(void *vrqstp)
487 /* Lock the export hash tables for reading. */ 470 /* Lock the export hash tables for reading. */
488 exp_readlock(); 471 exp_readlock();
489 472
490 /* Process request with signals blocked. */
491 sigprocmask(SIG_SETMASK, &allowed_mask, NULL);
492
493 svc_process(rqstp); 473 svc_process(rqstp);
494 474
495 /* Unlock export hash tables */ 475 /* Unlock export hash tables */