From fd5c5a9703ba8543514234f7f4dffafd47d465c2 Mon Sep 17 00:00:00 2001 From: Christine Caulfield Date: Mon, 2 Feb 2009 14:34:24 +0000 Subject: [PATCH] Allow clvmd to be built with all cluster managers & select one on cmdline. --- WHATS_NEW | 3 +- daemons/clvmd/Makefile.in | 23 +++++------- daemons/clvmd/clvmd-corosync.c | 6 ++-- daemons/clvmd/clvmd-openais.c | 6 ++-- daemons/clvmd/clvmd.c | 64 +++++++++++++++++++++++++++------- 5 files changed, 68 insertions(+), 34 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 966b4327d..c9be5f08a 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,6 +1,7 @@ Version 2.02.45 - =================================== - Mention --with-clvmd=corosync in ./configure + Allow clvmd to be built with all cluster managers & select one on cmdline. + Mention --with-clvmd=corosync in ./configure. Replace internal vg_check_status() implementation. Rename vg_read() to vg_read_internal(). diff --git a/daemons/clvmd/Makefile.in b/daemons/clvmd/Makefile.in index 1edf02d72..268084d5c 100644 --- a/daemons/clvmd/Makefile.in +++ b/daemons/clvmd/Makefile.in @@ -21,31 +21,26 @@ SOURCES = \ lvm-functions.c \ refresh_clvmd.c -ifeq ("@CLVMD@", "gulm") +ifneq (,$(findstring gulm,, "@CLVMD@,")) GULM = yes endif -ifeq ("@CLVMD@", "cman") +ifneq (,$(findstring cman,, "@CLVMD@,")) CMAN = yes endif -ifeq ("@CLVMD@", "openais") +ifneq (,$(findstring openais,, "@CLVMD@,")) OPENAIS = yes - GULM = no - CMAN = no endif -ifeq ("@CLVMD@", "all") +ifneq (,$(findstring corosync,, "@CLVMD@,")) + COROSYNC = yes +endif + +ifneq (,$(findstring all,, "@CLVMD@,")) GULM = yes CMAN = yes - OPENAIS = no - COROSYNC = no -endif - -ifeq ("@CLVMD@", "corosync") - GULM = no - CMAN = no - OPENAIS = no + OPENAIS = yes COROSYNC = yes endif diff --git a/daemons/clvmd/clvmd-corosync.c b/daemons/clvmd/clvmd-corosync.c index 3c142e3f7..61dfe4d3e 100644 --- a/daemons/clvmd/clvmd-corosync.c +++ b/daemons/clvmd/clvmd-corosync.c @@ -194,7 +194,7 @@ static int cs_to_errno(cs_error_t err) return -1; } -static char *print_csid(const char *csid) +static char *print_corosync_csid(const char *csid) { static char buf[128]; int id; @@ -392,7 +392,7 @@ static int _name_from_csid(const char *csid, char *name) ninfo = dm_hash_lookup_binary(node_hash, csid, COROSYNC_CSID_LEN); if (!ninfo) { - sprintf(name, "UNKNOWN %s", print_csid(csid)); + sprintf(name, "UNKNOWN %s", print_corosync_csid(csid)); return -1; } @@ -414,7 +414,7 @@ static void _add_up_node(const char *csid) ninfo = dm_hash_lookup_binary(node_hash, csid, COROSYNC_CSID_LEN); if (!ninfo) { DEBUGLOG("corosync_add_up_node no node_hash entry for csid %s\n", - print_csid(csid)); + print_corosync_csid(csid)); return; } diff --git a/daemons/clvmd/clvmd-openais.c b/daemons/clvmd/clvmd-openais.c index 42f8187d2..58da43a06 100644 --- a/daemons/clvmd/clvmd-openais.c +++ b/daemons/clvmd/clvmd-openais.c @@ -195,7 +195,7 @@ static int ais_to_errno(SaAisErrorT err) return -1; } -static char *print_csid(const char *csid) +static char *print_openais_csid(const char *csid) { static char buf[128]; int id; @@ -415,7 +415,7 @@ static int _name_from_csid(const char *csid, char *name) ninfo = dm_hash_lookup_binary(node_hash, csid, OPENAIS_CSID_LEN); if (!ninfo) { - sprintf(name, "UNKNOWN %s", print_csid(csid)); + sprintf(name, "UNKNOWN %s", print_openais_csid(csid)); return -1; } @@ -437,7 +437,7 @@ static void _add_up_node(const char *csid) ninfo = dm_hash_lookup_binary(node_hash, csid, OPENAIS_CSID_LEN); if (!ninfo) { DEBUGLOG("openais_add_up_node no node_hash entry for csid %s\n", - print_csid(csid)); + print_openais_csid(csid)); return; } diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c index 83059a4be..faa1755eb 100644 --- a/daemons/clvmd/clvmd.c +++ b/daemons/clvmd/clvmd.c @@ -108,6 +108,8 @@ static int child_pipe[2]; #define DFAIL_TIMEOUT 5 #define SUCCESS 0 +typedef enum {IF_AUTO, IF_CMAN, IF_GULM, IF_OPENAIS, IF_COROSYNC} if_type_t; + /* Prototypes for code further down */ static void sigusr2_handler(int sig); static void sighup_handler(int sig); @@ -144,6 +146,7 @@ static void hton_clvm(struct clvm_header *hdr); static void ntoh_clvm(struct clvm_header *hdr); static void add_reply_to_list(struct local_client *client, int status, const char *csid, const char *buf, int len); +static if_type_t parse_cluster_interface(char *ifname); static void usage(char *prog, FILE *file) { @@ -158,6 +161,20 @@ static void usage(char *prog, FILE *file) fprintf(file, " -C Sets debug level (from -d) on all clvmd instances clusterwide\n"); fprintf(file, " -t Command timeout (default 60 seconds)\n"); fprintf(file, " -T Startup timeout (default none)\n"); + fprintf(file, " -I Cluster manager (default: auto)\n"); + fprintf(file, " Available cluster managers: "); +#ifdef USE_COROSYNC + fprintf(file, "corosync "); +#endif +#ifdef USE_CMAN + fprintf(file, "cman "); +#endif +#ifdef USE_OPENAIS + fprintf(file, "openais "); +#endif +#ifdef USE_GULM + fprintf(file, "gulm "); +#endif fprintf(file, "\n"); } @@ -258,6 +275,7 @@ int main(int argc, char *argv[]) signed char opt; int cmd_timeout = DEFAULT_CMD_TIMEOUT; int start_timeout = 0; + if_type_t cluster_iface = IF_AUTO; sigset_t ss; int using_gulm = 0; int debug_opt = 0; @@ -266,7 +284,7 @@ int main(int argc, char *argv[]) /* Deal with command-line arguments */ opterr = 0; optind = 0; - while ((opt = getopt(argc, argv, "?vVhd::t:RT:C")) != EOF) { + while ((opt = getopt(argc, argv, "?vVhd::t:RT:CI:")) != EOF) { switch (opt) { case 'h': usage(argv[0], stdout); @@ -299,6 +317,9 @@ int main(int argc, char *argv[]) exit(1); } break; + case 'I': + cluster_iface = parse_cluster_interface(optarg); + break; case 'T': start_timeout = atoi(optarg); if (start_timeout <= 0) { @@ -365,7 +386,7 @@ int main(int argc, char *argv[]) /* Start the cluster interface */ #ifdef USE_CMAN - if ((clops = init_cman_cluster())) { + if ((cluster_iface == IF_AUTO || cluster_iface == IF_CMAN) && (clops = init_cman_cluster())) { max_csid_len = CMAN_MAX_CSID_LEN; max_cluster_message = CMAN_MAX_CLUSTER_MESSAGE; max_cluster_member_name_len = CMAN_MAX_NODENAME_LEN; @@ -374,7 +395,7 @@ int main(int argc, char *argv[]) #endif #ifdef USE_GULM if (!clops) - if ((clops = init_gulm_cluster())) { + if ((cluster_iface == IF_AUTO || cluster_iface == IF_GULM) && (clops = init_gulm_cluster())) { max_csid_len = GULM_MAX_CSID_LEN; max_cluster_message = GULM_MAX_CLUSTER_MESSAGE; max_cluster_member_name_len = GULM_MAX_CLUSTER_MEMBER_NAME_LEN; @@ -382,24 +403,24 @@ int main(int argc, char *argv[]) syslog(LOG_NOTICE, "Cluster LVM daemon started - connected to GULM"); } #endif -#ifdef USE_OPENAIS - if (!clops) - if ((clops = init_openais_cluster())) { - max_csid_len = OPENAIS_CSID_LEN; - max_cluster_message = OPENAIS_MAX_CLUSTER_MESSAGE; - max_cluster_member_name_len = OPENAIS_MAX_CLUSTER_MEMBER_NAME_LEN; - syslog(LOG_NOTICE, "Cluster LVM daemon started - connected to OpenAIS"); - } -#endif #ifdef USE_COROSYNC if (!clops) - if ((clops = init_corosync_cluster())) { + if (((cluster_iface == IF_AUTO || cluster_iface == IF_COROSYNC) && (clops = init_corosync_cluster()))) { max_csid_len = COROSYNC_CSID_LEN; max_cluster_message = COROSYNC_MAX_CLUSTER_MESSAGE; max_cluster_member_name_len = COROSYNC_MAX_CLUSTER_MEMBER_NAME_LEN; syslog(LOG_NOTICE, "Cluster LVM daemon started - connected to Corosync"); } #endif +#ifdef USE_OPENAIS + if (!clops) + if ((cluster_iface == IF_AUTO || cluster_iface == IF_OPENAIS) && (clops = init_openais_cluster())) { + max_csid_len = OPENAIS_CSID_LEN; + max_cluster_message = OPENAIS_MAX_CLUSTER_MESSAGE; + max_cluster_member_name_len = OPENAIS_MAX_CLUSTER_MEMBER_NAME_LEN; + syslog(LOG_NOTICE, "Cluster LVM daemon started - connected to OpenAIS"); + } +#endif if (!clops) { DEBUGLOG("Can't initialise cluster interface\n"); @@ -2008,3 +2029,20 @@ int sync_unlock(const char *resource, int lockid) return clops->sync_unlock(resource, lockid); } +static if_type_t parse_cluster_interface(char *ifname) +{ + if_type_t iface = IF_AUTO; + + if (!strcmp(ifname, "auto")) + iface = IF_AUTO; + if (!strcmp(ifname, "cman")) + iface = IF_CMAN; + if (!strcmp(ifname, "gulm")) + iface = IF_GULM; + if (!strcmp(ifname, "openais")) + iface = IF_OPENAIS; + if (!strcmp(ifname, "corosync")) + iface = IF_COROSYNC; + + return iface; +}