diff options
| author | neilbrown <neilbrown> | 2004-09-06 02:15:04 +0000 |
|---|---|---|
| committer | neilbrown <neilbrown> | 2004-09-06 02:15:04 +0000 |
| commit | af93e0306d87bba3f703386fd6390e9bf8e76816 (patch) | |
| tree | ec1caa91d3ccb07af6bd36ff583148390e56ea1d /utils/statd | |
| parent | 2c91715a9c8dbf18df1666f70e78d6e36e123ca0 (diff) | |
Support --ha-callout for high-availability callouts
Diffstat (limited to 'utils/statd')
| -rw-r--r-- | utils/statd/monitor.c | 9 | ||||
| -rw-r--r-- | utils/statd/rmtcall.c | 3 | ||||
| -rw-r--r-- | utils/statd/statd.c | 25 | ||||
| -rw-r--r-- | utils/statd/statd.h | 2 | ||||
| -rw-r--r-- | utils/statd/statd.man | 29 | ||||
| -rw-r--r-- | utils/statd/svc_run.c | 5 |
6 files changed, 70 insertions, 3 deletions
diff --git a/utils/statd/monitor.c b/utils/statd/monitor.c index 8c1bb50..3b81bdd 100644 --- a/utils/statd/monitor.c +++ b/utils/statd/monitor.c @@ -19,6 +19,7 @@ #include "misc.h" #include "statd.h" #include "notlist.h" +#include "ha-callout.h" notify_list * rtnl = NULL; /* Run-time notify list. */ @@ -177,6 +178,8 @@ sm_mon_1_svc(struct mon *argp, struct svc_req *rqstp) goto failure; } free(path); + /* PRC: do the HA callout: */ + ha_callout("add-client", mon_name, my_name, -1); nlist_insert(&rtnl, clnt); close(fd); @@ -232,6 +235,10 @@ sm_unmon_1_svc(struct mon_id *argp, struct svc_req *rqstp) /* Match! */ dprintf(N_DEBUG, "UNMONITORING %s for %s", mon_name, my_name); + + /* PRC: do the HA callout: */ + ha_callout("del-client", mon_name, my_name, -1); + nlist_free(&rtnl, clnt); xunlink(SM_DIR, mon_name, 1); @@ -276,6 +283,8 @@ sm_unmon_all_1_svc(struct my_id *argp, struct svc_req *rqstp) sizeof (mon_name) - 1); mon_name[sizeof (mon_name) - 1] = '\0'; temp = NL_NEXT(clnt); + /* PRC: do the HA callout: */ + ha_callout("del-client", mon_name, argp->my_name, -1); nlist_free(&rtnl, clnt); xunlink(SM_DIR, mon_name, 1); ++count; diff --git a/utils/statd/rmtcall.c b/utils/statd/rmtcall.c index 2997254..911a932 100644 --- a/utils/statd/rmtcall.c +++ b/utils/statd/rmtcall.c @@ -38,6 +38,7 @@ #include "statd.h" #include "notlist.h" #include "log.h" +#include "ha-callout.h" #define MAXMSGSIZE (2048 / sizeof(unsigned int)) @@ -414,6 +415,8 @@ process_notify_list(void) note(N_ERROR, "Can't notify %s, giving up.", NL_MON_NAME(entry)); + /* PRC: do the HA callout */ + ha_callout("del-client", NL_MON_NAME(entry), NL_MY_NAME(entry), -1); xunlink(SM_BAK_DIR, NL_MON_NAME(entry), 0); nlist_free(¬ify, entry); } diff --git a/utils/statd/statd.c b/utils/statd/statd.c index b57f71b..f666bcd 100644 --- a/utils/statd/statd.c +++ b/utils/statd/statd.c @@ -48,6 +48,11 @@ int run_mode = 0; /* foreground logging mode */ char *name_p = NULL; char *version_p = NULL; +/* PRC: a high-availability callout program can be specified with -H + * When this is done, the program will receive callouts whenever clients + * are added or deleted to the notify list */ +char *ha_callout_prog = NULL; + static struct option longopts[] = { { "foreground", 0, 0, 'F' }, @@ -59,6 +64,7 @@ static struct option longopts[] = { "name", 1, 0, 'n' }, { "state-directory-path", 1, 0, 'P' }, { "notify-mode", 0, 0, 'N' }, + { "ha-callout", 1, 0, 'H' }, { NULL, 0, 0, 0 } }; @@ -102,6 +108,13 @@ killer (int sig) exit (0); } +static void +sigusr (int sig) +{ + dprintf (N_DEBUG, "Caught signal %d, re-reading notify list.", sig); + re_notify = 1; +} + /* * Startup information. */ @@ -148,6 +161,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," -H Specify a high-availability callout program.\n"); } static const char *pidfile = "/var/run/rpc.statd.pid"; @@ -236,7 +250,7 @@ int main (int argc, char **argv) MY_NAME = NULL; /* Process command line switches */ - while ((arg = getopt_long(argc, argv, "h?vVFNdn:p:o:P:", longopts, NULL)) != EOF) { + while ((arg = getopt_long(argc, argv, "h?vVFNH:dn:p:o:P:", longopts, NULL)) != EOF) { switch (arg) { case 'V': /* Version */ case 'v': @@ -302,6 +316,13 @@ int main (int argc, char **argv) sprintf(SM_STAT_PATH, "%s/state", DIR_BASE ); } break; + case 'H': /* PRC: specify the ha-callout program */ + if ((ha_callout_prog = xstrdup(optarg)) == NULL) { + fprintf(stderr, "%s: xstrdup(%s) failed!\n", + argv[0], optarg); + exit(1); + } + break; case '?': /* heeeeeelllllllpppp? heh */ case 'h': usage(); @@ -397,6 +418,8 @@ int main (int argc, char **argv) signal (SIGHUP, killer); signal (SIGINT, killer); signal (SIGTERM, killer); + /* PRC: trap SIGUSR1 to re-read notify list from disk */ + signal(SIGUSR1, sigusr); /* WARNING: the following works on Linux and SysV, but not BSD! */ signal(SIGCHLD, SIG_IGN); diff --git a/utils/statd/statd.h b/utils/statd/statd.h index ef90bdd..e782972 100644 --- a/utils/statd/statd.h +++ b/utils/statd/statd.h @@ -85,3 +85,5 @@ extern int run_mode; */ extern char *name_p; /* program basename */ extern char *version_p; /* program version */ + +extern int re_notify; /* time to re-read notify list */ diff --git a/utils/statd/statd.man b/utils/statd/statd.man index f35b6c9..a225915 100644 --- a/utils/statd/statd.man +++ b/utils/statd/statd.man @@ -4,11 +4,12 @@ .\" Copyright (C) 1999 Olaf Kirch <okir@monad.swb.de> .\" Modified by Jeffrey A. Uphoff, 1999, 2002. .\" Modified by Lon Hohberger, 2000. -.TH rpc.statd 8 "16 Sep 2002" +.\" Modified by Paul Clements, 2004. +.TH rpc.statd 8 "31 Aug 2004" .SH NAME rpc.statd \- NSM status monitor .SH SYNOPSIS -.B "/sbin/rpc.statd [-F] [-d] [-?] [-n " name "] [-o " port "] [-p " port "] [-V]" +.B "/sbin/rpc.statd [-F] [-d] [-?] [-n " name "] [-o " port "] [-p " port "] [-H " prog "] [-V]" .SH DESCRIPTION The .B rpc.statd @@ -101,6 +102,19 @@ 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). .TP +.BI "\-H, " "" " \-\-ha-callout " prog +Specify a high availability callout program, which will receive callouts +for all client monitor and unmonitor requests. This allows +.B rpc.statd +to be used in a High Availability NFS (HA-NFS) environment. The +program will be run with 3 arguments: The first is either +.B add-client +or +.B del-client +depending on the reason for the callout. +The second will be the name of the client. +The third will be the name of the server as known to the client. +.TP .B -? Causes .B rpc.statd @@ -135,6 +149,15 @@ and .BR hosts_access (5) manual pages. +.SH SIGNALS +.BR SIGUSR1 +causes +.B rpc.statd +to re-read the notify list from disk +and send notifications to clients. This can be used in High Availability NFS +(HA-NFS) environments to notify clients to reacquire file locks upon takeover +of an NFS export from another server. + .SH FILES .BR /var/lib/nfs/state .br @@ -153,3 +176,5 @@ Olaf Kirch <okir@monad.swb.de> H.J. Lu <hjl@gnu.org> .br Lon Hohberger <hohberger@missioncriticallinux.com> +.br +Paul Clements <paul.clements@steeleye.com> diff --git a/utils/statd/svc_run.c b/utils/statd/svc_run.c index 393a2fd..e2d7c97 100644 --- a/utils/statd/svc_run.c +++ b/utils/statd/svc_run.c @@ -60,6 +60,7 @@ static int svc_stop = 0; * requests are put. */ notify_list * notify = NULL; +int re_notify = 0; /* * Jump-off function. @@ -86,6 +87,10 @@ my_svc_run(void) for (;;) { if (svc_stop) return; + if (re_notify) { + notify_hosts(); + re_notify = 0; + } /* Ah, there are some notifications to be processed */ while (notify && NL_WHEN(notify) <= time(&now)) { |
