From 632127e335095b6053fa93b7b695d688918f36bb Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 20 Mar 2007 10:13:00 +1100 Subject: [PATCH] Allow rpc.statd to *not* run sm-notify. With -L (for Listen-only) or --no-notify, statd will not run sm-notify. --- utils/statd/statd.c | 46 +++++++++++++++++++++++++------------------ utils/statd/statd.h | 2 +- utils/statd/statd.man | 21 ++++++++++++++++++-- 3 files changed, 47 insertions(+), 22 deletions(-) diff --git a/utils/statd/statd.c b/utils/statd/statd.c index 6200911..17e2947 100644 --- a/utils/statd/statd.c +++ b/utils/statd/statd.c @@ -70,6 +70,7 @@ static struct option longopts[] = { "state-directory-path", 1, 0, 'P' }, { "notify-mode", 0, 0, 'N' }, { "ha-callout", 1, 0, 'H' }, + { "no-notify", 0, 0, 'L' }, { NULL, 0, 0, 0 } }; @@ -158,6 +159,7 @@ usage() fprintf(stderr," -n, --name Specify a local hostname.\n"); fprintf(stderr," -P State directory path.\n"); fprintf(stderr," -N Run in notify only mode.\n"); + fprintf(stderr," -L, --no-notify Do not perform any notification.\n"); fprintf(stderr," -H Specify a high-availability callout program.\n"); } @@ -274,7 +276,7 @@ int main (int argc, char **argv) MY_NAME = NULL; /* Process command line switches */ - while ((arg = getopt_long(argc, argv, "h?vVFNH:dn:p:o:P:", longopts, NULL)) != EOF) { + while ((arg = getopt_long(argc, argv, "h?vVFNH:dn:p:o:P:L", longopts, NULL)) != EOF) { switch (arg) { case 'V': /* Version */ case 'v': @@ -286,6 +288,9 @@ int main (int argc, char **argv) case 'N': run_mode |= MODE_NOTIFY_ONLY; break; + case 'L': /* Listen only */ + run_mode |= MODE_NO_NOTIFY; + break; case 'd': /* No daemon only - log to stderr */ run_mode |= MODE_LOG_STDERR; break; @@ -458,15 +463,16 @@ int main (int argc, char **argv) create_pidfile(); atexit(truncate_pidfile); - switch (pid = fork()) { - case 0: - run_sm_notify(out_port); - break; - case -1: - break; - default: - waitpid(pid, NULL, 0); - } + if (! (run_mode & MODE_NO_NOTIFY)) + switch (pid = fork()) { + case 0: + run_sm_notify(out_port); + break; + case -1: + break; + default: + waitpid(pid, NULL, 0); + } drop_privs(); @@ -496,15 +502,17 @@ int main (int argc, char **argv) * responding to SM_SIMU_CRASH is an important use cases to * get perfect. */ - switch (pid = fork()) { - case 0: - run_sm_notify(out_port); - break; - case -1: - break; - default: - waitpid(pid, NULL, 0); - } + if (! (run_mode & MODE_NO_NOTIFY)) + switch (pid = fork()) { + case 0: + run_sm_notify(out_port); + break; + case -1: + break; + default: + waitpid(pid, NULL, 0); + } + } return 0; } diff --git a/utils/statd/statd.h b/utils/statd/statd.h index 13c80da..441eaaa 100644 --- a/utils/statd/statd.h +++ b/utils/statd/statd.h @@ -82,7 +82,7 @@ extern int run_mode; * that just came back up, for ex, when failing over a HA service to * another host.... */ #define STATIC_HOSTNAME 8 /* Always use the hostname set by -n */ - +#define MODE_NO_NOTIFY 16 /* Don't notify peers of a reboot */ /* * Program name and version pointers -- See statd.c for the reasoning * as to why they're global. diff --git a/utils/statd/statd.man b/utils/statd/statd.man index ce29dfd..e8be9f3 100644 --- a/utils/statd/statd.man +++ b/utils/statd/statd.man @@ -9,7 +9,7 @@ .SH NAME rpc.statd \- NSM status monitor .SH SYNOPSIS -.B "rpc.statd [-F] [-d] [-?] [-n " name "] [-o " port "] [-p " port "] [-H " prog "] [-V]" +.B "rpc.statd [-FNL] [-d] [-?] [-n " name "] [-o " port "] [-p " port "] [-H " prog "] [-V]" .SH DESCRIPTION The .B rpc.statd @@ -25,7 +25,9 @@ For each NFS client or server machine to be monitored, .B rpc.statd creates a file in .BR /var/lib/nfs/sm . -When starting, it iterates through these files and notifies the +When starting, it normally runs +.B sm-notify +to iterate through these files and notify the peer .B rpc.statd on those machines. @@ -101,6 +103,21 @@ Causes statd to run in the notify-only mode. When started in this mode, the statd program will check its state directory, send notifications to any monitored nodes, and exit once the notifications have been sent. This mode is used to enable Highly Available NFS implementations (i.e. HA-NFS). +This mode is deprecated \- +.B sm-notify +should be used directly instead. +.TP +.BR -L , " --no-notify +Inhibits the running of +.BR sm-notify . +If +.B sm-notify +is run by some other script at boot time, there is no need for +.B statd +to start sm-notify itself. This can be appropriate if starting of +statd needs to be delayed until it is actually need. In such cases +.B sm-notify +should still be run at boot time. .TP .BI "\-H, " "" " \-\-ha-callout " prog Specify a high availability callout program, which will receive callouts -- 2.39.5