From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15083 invoked by alias); 18 Mar 2008 13:26:37 -0000 Received: (qmail 15052 invoked by uid 9452); 18 Mar 2008 13:26:36 -0000 Date: Tue, 18 Mar 2008 13:26:00 -0000 Message-ID: <20080318132636.15037.qmail@sourceware.org> From: ccaulfield@sourceware.org To: cluster-cvs@sources.redhat.com, cluster-devel@redhat.com Subject: Cluster Project branch, master, updated. gfs-kernel_0_1_22-75-gbee9018 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: febfaf415cb873716ff5f105f873ec8401607a29 X-Git-Newrev: bee9018146ab3200d1691621dc4bd648670ece09 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2008-q1/txt/msg00324.txt.bz2 This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Cluster Project". http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=bee9018146ab3200d1691621dc4bd648670ece09 The branch, master has been updated via bee9018146ab3200d1691621dc4bd648670ece09 (commit) via 11aa8972e4fcf7524647f55237bd46a7b7489e6b (commit) from febfaf415cb873716ff5f105f873ec8401607a29 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit bee9018146ab3200d1691621dc4bd648670ece09 Author: Christine Caulfield Date: Tue Mar 18 13:11:47 2008 +0000 [CMAN] Make cman cope with the new objdb structure Now the /cluster bits are held on the objdb below "cluster" we need to look for everything (well, nearly everything) under there. Also add a 'cman_tool dump-db' command which is only built in DEBUG mode. Signed-off-by: Christine Caulfield commit 11aa8972e4fcf7524647f55237bd46a7b7489e6b Author: Christine Caulfield Date: Tue Mar 18 13:10:22 2008 +0000 [CCS] Fix the config loader for good We were removing the "/cluster" top level domain to allow /cluster/totem and other random ais bits to be at the top level of the objdb since aisexec expects to find them there. This is not clean in several way because it would break queries like: /cluster/child::* by returning a bunch of top levels objdb that are internal to aisexec and we don't want to expose to everybody. This is achieved by doing a few tricks here and there.. best would be to allow objdb symlinking. First we load the special bits for aisexec at the top level by using the right path within the xml config and then we load (again) the whole configuration. The final result will have some duplicates entries but for now we can live with that. The overhead is minimal. Signed-off-by: Fabio M. Di Nitto ----------------------------------------------------------------------- Summary of changes: ccs/ccsais/config.c | 46 ++++++--------------------- cman/cman_tool/cman_tool.h | 1 + cman/cman_tool/main.c | 32 ++++++++++++++++++- cman/daemon/cman-preconfig.c | 71 +++++++++++++++++++++++++----------------- cman/daemon/cmanconfig.c | 23 ++++++++----- cman/daemon/cnxman-socket.h | 1 + cman/daemon/commands.c | 16 +++++++++- cman/daemon/nodelist.h | 14 +++++--- cman/lib/libcman.c | 10 ++++++ cman/lib/libcman.h | 3 ++ 10 files changed, 136 insertions(+), 81 deletions(-) diff --git a/ccs/ccsais/config.c b/ccs/ccsais/config.c index 07db749..d8b815b 100644 --- a/ccs/ccsais/config.c +++ b/ccs/ccsais/config.c @@ -83,14 +83,14 @@ static int should_alloc(int ccs_fd, char *key) char path[256]; char *str = NULL; - sprintf(path, "/cluster/%s/@*", key); + sprintf(path, "%s/@*", key); keyerror = ccs_get_list(ccs_fd, path, &str); if(str) { free(str); str = NULL; } - sprintf(path, "/cluster/%s/child::*", key); + sprintf(path, "%s/child::*", key); childerr = ccs_get_list(ccs_fd, path, &str); if(str) free(str); @@ -116,7 +116,7 @@ static int read_config_for(int ccs_fd, struct objdb_iface_ver0 *objdb, unsigned if (should_alloc(ccs_fd, key) || always_create) objdb->object_create(parent, &object_handle, object, strlen(object)); - sprintf(path, "/cluster/%s/@*", key); + sprintf(path, "%s/@*", key); /* Get the keys */ for (;;) @@ -143,7 +143,7 @@ static int read_config_for(int ccs_fd, struct objdb_iface_ver0 *objdb, unsigned CCS can't cope with recursive queries so we have to store the result of the subkey search */ memset(subkeys, 0, sizeof(subkeys)); - sprintf(path, "/cluster/%s/child::*", key); + sprintf(path, "%s/child::*", key); for (;;) { char *equal; @@ -229,7 +229,6 @@ static int init_config(struct objdb_iface_ver0 *objdb, char *error_string) { int cd; char *cname = NULL; - char *str; /* Connect to ccsd */ if (getenv("CCS_CLUSTER_NAME")) { @@ -244,40 +243,15 @@ static int init_config(struct objdb_iface_ver0 *objdb, char *error_string) } /* These first few are just versions of openais.conf */ - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "totem", "totem", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "logging", "logging", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "event", "event", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "aisexec", "aisexec", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "amf", "amf", 1); + read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "totem", "/cluster/totem", 1); + read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "logging", "/cluster/logging", 1); + read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "event", "/cluster/event", 1); + read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "aisexec", "/cluster/aisexec", 1); + read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "amf", "/cluster/amf", 1); /* This is stuff specific to us, eg quorum device timeout */ - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "cman", "cman", 1); - - /* Nodes information */ - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "clusternodes", "clusternodes", 1); - - /* all the others */ - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "quorumd", "quorumd", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "fence_xvmd", "fence_xvmd", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "fencedevices", "fencedevices", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "dlm", "dlm", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "gfs_controld", "gfs_controld", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "rm", "rm", 1); - - /* Also get cluster name and config version number */ - if (!ccs_get(cd, CONFIG_VERSION_PATH, &str)) { - objdb->object_key_create(OBJECT_PARENT_HANDLE, - "config_version", strlen("config_version"), - str, strlen(str)+1); - free(str); - } + read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "cluster", "/cluster", 1); - if (!ccs_get(cd, CONFIG_NAME_PATH, &str)) { - objdb->object_key_create(OBJECT_PARENT_HANDLE, - "name", strlen("name"), - str, strlen(str)+1); - free(str); - } ccs_disconnect(cd); return 0; } diff --git a/cman/cman_tool/cman_tool.h b/cman/cman_tool/cman_tool.h index ea4e472..8a98c12 100644 --- a/cman/cman_tool/cman_tool.h +++ b/cman/cman_tool/cman_tool.h @@ -76,6 +76,7 @@ struct commandline char *interfaces[MAX_INTERFACES]; char *override_nodename; char *key_filename; + char *filename; char *format_opts; char *config_lcrso; int votes; diff --git a/cman/cman_tool/main.c b/cman/cman_tool/main.c index 98d0802..c916b7f 100644 --- a/cman/cman_tool/main.c +++ b/cman/cman_tool/main.c @@ -34,6 +34,7 @@ #define OP_NODES 9 #define OP_SERVICES 10 #define OP_DEBUG 11 +#define OP_DUMP_OBJDB 12 static void print_usage(int subcmd) @@ -708,6 +709,19 @@ static void set_debuglog(commandline_t *comline) cman_finish(h); } +#ifdef DEBUG +static void dump_objdb(commandline_t *comline) +{ + cman_handle_t h; + + h = open_cman_handle(1); + + if (cman_dump_objdb(h, comline->filename)) + perror("dump objdb failed"); + + cman_finish(h); +} +#endif static int get_int_arg(char argopt, char *arg) { @@ -913,6 +927,18 @@ static void decode_arguments(int argc, char *argv[], commandline_t *comline) if (comline->operation) die("can't specify two operations"); comline->operation = OP_DEBUG; +#ifdef DEBUG + } else if (strcmp(argv[optind], "dump-db") == 0) { + if (comline->operation) + die("can't specify two operations"); + comline->operation = OP_DUMP_OBJDB; + if (!argv[optind+1]) + die("no filename given"); + comline->filename = strdup(argv[optind+1]); + if (comline->filename[0] != '/') + die("dump filename must be an absolute path"); + optind++; +#endif } else if (strcmp(argv[optind], "remove") == 0) { comline->remove = TRUE; } else if (strcmp(argv[optind], "force") == 0) { @@ -1031,8 +1057,12 @@ int main(int argc, char *argv[]) case OP_DEBUG: set_debuglog(&comline); break; +#ifdef DEBUG + case OP_DUMP_OBJDB: + dump_objdb(&comline); + break; } - +#endif exit(EXIT_SUCCESS); } diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c index 5900256..c45cc0e 100644 --- a/cman/daemon/cman-preconfig.c +++ b/cman/daemon/cman-preconfig.c @@ -65,6 +65,7 @@ static char *key_filename; static char *mcast_name; static char *cluster_name; static char error_reason[1024]; +static unsigned int cluster_parent_handle; /* * Exports the interface for the service @@ -130,15 +131,15 @@ static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr, "totem", strlen("totem"), &totem_object_handle)) { objdb->object_create(OBJECT_PARENT_HANDLE, &totem_object_handle, - "totem", strlen("totem")); + "totem", strlen("totem")); } objdb->object_find_reset(OBJECT_PARENT_HANDLE); if (objdb->object_find(OBJECT_PARENT_HANDLE, - "totem", strlen("totem"), &totem_object_handle) == 0) { + "totem", strlen("totem"), &totem_object_handle) == 0) { if (objdb->object_create(totem_object_handle, &interface_object_handle, - "interface", strlen("interface")) == 0) { + "interface", strlen("interface")) == 0) { P_AIS("Setting if %d, name: %s, mcast: %s, port=%d, \n", num_interfaces, ifaddr, mcast, portnum); @@ -221,7 +222,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename) int error; /* nodename is either from commandline or from uname */ - if (nodelist_byname(objdb, nodename)) + if (nodelist_byname(objdb, cluster_parent_handle, nodename)) return 0; /* If nodename was from uname, try a domain-less version of it */ @@ -230,7 +231,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename) if (dot) { *dot = '\0'; - if (nodelist_byname(objdb, nodename2)) { + if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) { strcpy(nodename, nodename2); return 0; } @@ -238,7 +239,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename) /* If nodename (from uname) is domain-less, try to match against cluster.conf names which may have domainname specified */ - nodes_handle = nodeslist_init(objdb, &parent_handle); + nodes_handle = nodeslist_init(objdb, cluster_parent_handle, &parent_handle); do { int len; @@ -284,7 +285,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename) if (error) goto out; - if (nodelist_byname(objdb, nodename2)) { + if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) { strcpy(nodename, nodename2); goto out; } @@ -296,7 +297,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename) continue; *dot = '\0'; - if (nodelist_byname(objdb, nodename2)) { + if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) { strcpy(nodename, nodename2); goto out; } @@ -307,7 +308,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename) if (error) goto out; - if (nodelist_byname(objdb, nodename2)) { + if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) { strcpy(nodename, nodename2); goto out; } @@ -441,7 +442,7 @@ static int get_nodename(struct objdb_iface_ver0 *objdb) // Add - if ( (node_object_handle = nodelist_byname(objdb, nodename))) { + if ( (node_object_handle = nodelist_byname(objdb, cluster_parent_handle, nodename))) { if (objdb_get_string(objdb, node_object_handle, "nodeid", &nodeid_str)) { log_printf(LOG_ERR, "Cannot get node ID"); write_cman_pipe("This node has no nodeid in cluster.conf"); @@ -449,9 +450,9 @@ static int get_nodename(struct objdb_iface_ver0 *objdb) } } - objdb->object_find_reset(OBJECT_PARENT_HANDLE); + objdb->object_find_reset(cluster_parent_handle); - if (objdb->object_find(OBJECT_PARENT_HANDLE, + if (objdb->object_find(cluster_parent_handle, "cman", strlen("cman"), &object_handle) == 0) { @@ -615,15 +616,15 @@ static void add_cman_overrides(struct objdb_iface_ver0 *objdb) } /* Make sure mainconfig doesn't stomp on our logging options */ - if (objdb->object_find(OBJECT_PARENT_HANDLE, + if (objdb->object_find(cluster_parent_handle, "logging", strlen("logging"), &object_handle)) { - objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle, + objdb->object_create(cluster_parent_handle, &object_handle, "logging", strlen("logging")); } - objdb->object_find_reset(OBJECT_PARENT_HANDLE); - if (objdb->object_find(OBJECT_PARENT_HANDLE, + objdb->object_find_reset(cluster_parent_handle); + if (objdb->object_find(cluster_parent_handle, "logging", strlen("logging"), &object_handle) == 0) { unsigned int logger_object_handle; @@ -649,8 +650,8 @@ static void add_cman_overrides(struct objdb_iface_ver0 *objdb) } /* Don't run under user "ais" */ - objdb->object_find_reset(OBJECT_PARENT_HANDLE); - if (objdb->object_find(OBJECT_PARENT_HANDLE, "aisexec", strlen("aisexec"), &object_handle) == 0) + objdb->object_find_reset(cluster_parent_handle); + if (objdb->object_find(cluster_parent_handle, "aisexec", strlen("aisexec"), &object_handle) == 0) { objdb->object_key_create(object_handle, "user", strlen("user"), "root", strlen("root") + 1); @@ -658,8 +659,8 @@ static void add_cman_overrides(struct objdb_iface_ver0 *objdb) "root", strlen("root") + 1); } - objdb->object_find_reset(OBJECT_PARENT_HANDLE); - if (objdb->object_find(OBJECT_PARENT_HANDLE, "cman", strlen("cman"), &object_handle) == 0) + objdb->object_find_reset(cluster_parent_handle); + if (objdb->object_find(cluster_parent_handle, "cman", strlen("cman"), &object_handle) == 0) { char str[255]; @@ -757,7 +758,7 @@ static int set_noccs_defaults(struct objdb_iface_ver0 *objdb) } /* Write a local entry to keep the rest of the code happy */ - objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle, + objdb->object_create(cluster_parent_handle, &object_handle, "clusternodes", strlen("clusternodes")); objdb->object_create(object_handle, &object_handle, "clusternode", strlen("clusternode")); @@ -773,19 +774,19 @@ static int set_noccs_defaults(struct objdb_iface_ver0 *objdb) tmp, strlen(tmp)+1); /* Write the default cluster name & ID in here too */ - objdb->object_key_create(OBJECT_PARENT_HANDLE, "name", strlen("name"), + objdb->object_key_create(cluster_parent_handle, "name", strlen("name"), cluster_name, strlen(cluster_name)+1); - if (objdb->object_find(OBJECT_PARENT_HANDLE, + if (objdb->object_find(cluster_parent_handle, "cman", strlen("cman"), &object_handle)) { - objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle, + objdb->object_create(cluster_parent_handle, &object_handle, "cman", strlen("cman")); } - objdb->object_find_reset(OBJECT_PARENT_HANDLE); - if (objdb->object_find(OBJECT_PARENT_HANDLE, + objdb->object_find_reset(cluster_parent_handle); + if (objdb->object_find(cluster_parent_handle, "cman", strlen("cman"), &object_handle) == 0) { @@ -804,11 +805,11 @@ static int get_cman_globals(struct objdb_iface_ver0 *objdb) { unsigned int object_handle; - objdb_get_string(objdb, OBJECT_PARENT_HANDLE, "name", &cluster_name); + objdb_get_string(objdb, cluster_parent_handle, "name", &cluster_name); /* Get the bits that override bits */ - objdb->object_find_reset(OBJECT_PARENT_HANDLE); - if (objdb->object_find(OBJECT_PARENT_HANDLE, + objdb->object_find_reset(cluster_parent_handle); + if (objdb->object_find(cluster_parent_handle, "cman", strlen("cman"), &object_handle) == 0) { if (!portnum) @@ -829,6 +830,7 @@ static int get_cman_globals(struct objdb_iface_ver0 *objdb) static int cmanpre_readconfig(struct objdb_iface_ver0 *objdb, char **error_string) { int ret = 0; + unsigned int object_handle; if (getenv("CMAN_PIPE")) startup_pipe = atoi(getenv("CMAN_PIPE")); @@ -847,6 +849,17 @@ static int cmanpre_readconfig(struct objdb_iface_ver0 *objdb, char **error_strin logsys_config_subsys_set("CMAN", LOGSYS_TAG_LOG, LOG_DEBUG); } + objdb->object_find_reset(OBJECT_PARENT_HANDLE); + objdb->object_find(OBJECT_PARENT_HANDLE, + "cluster", strlen("cluster"), &cluster_parent_handle); + + if (objdb->object_find(cluster_parent_handle, + "cman", strlen("cman"), &object_handle)) { + + objdb->object_create(cluster_parent_handle, &object_handle, + "cman", strlen("cman")); + } + get_env_overrides(); if (getenv("CMAN_NOCCS")) ret = set_noccs_defaults(objdb); diff --git a/cman/daemon/cmanconfig.c b/cman/daemon/cmanconfig.c index b190b9c..8bd24dd 100644 --- a/cman/daemon/cmanconfig.c +++ b/cman/daemon/cmanconfig.c @@ -41,6 +41,7 @@ static char cluster_name[MAX_CLUSTER_NAME_LEN + 1]; static unsigned int expected_votes; static char *our_nodename; static int our_votes; +static unsigned int cluster_parent_handle; /* Get all the cluster node names from objdb and * add them to our node list. @@ -58,11 +59,11 @@ int read_cman_nodes(struct objdb_iface_ver0 *objdb, unsigned int *config_version char *nodename; /* New config version */ - objdb_get_int(objdb, OBJECT_PARENT_HANDLE, "config_version", config_version); + objdb_get_int(objdb, cluster_parent_handle, "config_version", config_version); - objdb->object_find_reset(OBJECT_PARENT_HANDLE); + objdb->object_find_reset(cluster_parent_handle); - if (objdb->object_find(OBJECT_PARENT_HANDLE, + if (objdb->object_find(cluster_parent_handle, "cman", strlen("cman"), &object_handle) == 0) { @@ -77,7 +78,7 @@ int read_cman_nodes(struct objdb_iface_ver0 *objdb, unsigned int *config_version clear_reread_flags(); /* Get the nodes list */ - nodes_handle = nodeslist_init(objdb, &parent_handle); + nodes_handle = nodeslist_init(objdb, cluster_parent_handle, &parent_handle); do { if (objdb_get_string(objdb, nodes_handle, "name", &nodename)) { log_printf(LOG_ERR, "Cannot get node name"); @@ -149,7 +150,7 @@ static int get_cman_join_info(struct objdb_iface_ver0 *objdb) unsigned int node_object; /* Cluster name */ - if (objdb_get_string(objdb, OBJECT_PARENT_HANDLE, "name", &cname)) { + if (objdb_get_string(objdb, cluster_parent_handle, "name", &cname)) { log_printf(LOG_ERR, "cannot find cluster name in config file"); write_cman_pipe("Can't find cluster name in CCS"); error = -ENOENT; @@ -175,7 +176,7 @@ static int get_cman_join_info(struct objdb_iface_ver0 *objdb) unsigned int nodes_handle; unsigned int parent_handle; - nodes_handle = nodeslist_init(objdb, &parent_handle); + nodes_handle = nodeslist_init(objdb, cluster_parent_handle, &parent_handle); do { int votes; @@ -195,8 +196,8 @@ static int get_cman_join_info(struct objdb_iface_ver0 *objdb) nodes_handle = nodeslist_next(objdb, parent_handle); } while (nodes_handle); - objdb->object_find_reset(OBJECT_PARENT_HANDLE); - if (objdb->object_find(OBJECT_PARENT_HANDLE, + objdb->object_find_reset(cluster_parent_handle); + if (objdb->object_find(cluster_parent_handle, "cman", strlen("cman"), &object_handle) == 0) { @@ -214,7 +215,7 @@ static int get_cman_join_info(struct objdb_iface_ver0 *objdb) log_printf(LOG_INFO, "Using override votes %d\n", votes); } - node_object = nodelist_byname(objdb, our_nodename); + node_object = nodelist_byname(objdb, cluster_parent_handle, our_nodename); if (!node_object) { log_printf(LOG_ERR, "unable to find votes for %s", our_nodename); write_cman_pipe("Unable to find votes for node in CCS"); @@ -291,6 +292,10 @@ int read_cman_config(struct objdb_iface_ver0 *objdb, unsigned int *config_versio { int error; + objdb->object_find_reset(OBJECT_PARENT_HANDLE); + objdb->object_find(OBJECT_PARENT_HANDLE, + "cluster", strlen("cluster"), &cluster_parent_handle); + read_cman_nodes(objdb, config_version, 1); error = get_cman_join_info(objdb); if (error) { diff --git a/cman/daemon/cnxman-socket.h b/cman/daemon/cnxman-socket.h index 90cb9ee..d00ca5b 100644 --- a/cman/daemon/cnxman-socket.h +++ b/cman/daemon/cnxman-socket.h @@ -54,6 +54,7 @@ #define CMAN_CMD_STOP_CONFCHG 0x000000c1 #define CMAN_CMD_SET_DIRTY 0x800000c2 #define CMAN_CMD_SET_DEBUGLOG 0x800000c3 +#define CMAN_CMD_DUMP_OBJDB 0x800000c4 #define CMAN_CMD_DATA 0x00000100 #define CMAN_CMD_BIND 0x00000101 diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c index 2549e06..eab29fe 100644 --- a/cman/daemon/commands.c +++ b/cman/daemon/commands.c @@ -1230,6 +1230,7 @@ int process_command(struct connection *con, int cmd, char *cmdbuf, struct cl_version cnxman_version; char *outbuf = *retbuf; int value; + FILE *dumpfile; P_MEMB("command to process is %x\n", cmd); @@ -1260,7 +1261,20 @@ int process_command(struct connection *con, int cmd, char *cmdbuf, set_debuglog(value); err = 0; break; - +#ifdef DEBUG + case CMAN_CMD_DUMP_OBJDB: + P_MEMB("CC: Dump_objdb: filename = %s\n", cmdbuf); + dumpfile = fopen(cmdbuf, "w+"); + if (dumpfile) { + global_objdb->object_dump(OBJECT_PARENT_HANDLE, dumpfile); + fclose(dumpfile); + err = 0; + } + else { + err = -errno; + } + break; +#endif case CMAN_CMD_START_CONFCHG: con->confchg = 1; err = 0; diff --git a/cman/daemon/nodelist.h b/cman/daemon/nodelist.h index a11b842..5363b67 100644 --- a/cman/daemon/nodelist.h +++ b/cman/daemon/nodelist.h @@ -12,12 +12,14 @@ /* Helper functions for navigating the nodes list */ -static unsigned int nodeslist_init(struct objdb_iface_ver0 *objdb, unsigned int *parent_handle) +static unsigned int nodeslist_init(struct objdb_iface_ver0 *objdb, + unsigned int cluster_parent_handle, + unsigned int *parent_handle) { unsigned int object_handle; - objdb->object_find_reset(OBJECT_PARENT_HANDLE); - if (objdb->object_find(OBJECT_PARENT_HANDLE, + objdb->object_find_reset(cluster_parent_handle); + if (objdb->object_find(cluster_parent_handle, "clusternodes", strlen("clusternodes"), &object_handle) == 0) { @@ -47,13 +49,15 @@ static unsigned int nodeslist_next(struct objdb_iface_ver0 *objdb, unsigned int return 0; } -static unsigned int nodelist_byname(struct objdb_iface_ver0 *objdb, char *name) +static unsigned int nodelist_byname(struct objdb_iface_ver0 *objdb, + unsigned int cluster_parent_handle, + char *name) { char *nodename; unsigned int nodes_handle; unsigned int parent_handle; - nodes_handle = nodeslist_init(objdb, &parent_handle); + nodes_handle = nodeslist_init(objdb, cluster_parent_handle, &parent_handle); while (nodes_handle) { if (objdb_get_string(objdb, nodes_handle, "name", &nodename)) { log_printf(LOG_ERR, "Cannot get node name"); diff --git a/cman/lib/libcman.c b/cman/lib/libcman.c index 190ad0b..7b28dc1 100644 --- a/cman/lib/libcman.c +++ b/cman/lib/libcman.c @@ -1112,3 +1112,13 @@ int cman_node_fenced(cman_handle_t handle, int nodeid, uint64_t time, char *agen strcpy(f.fence_agent, agent); return info_call(h, CMAN_CMD_UPDATE_FENCE_INFO, &f, sizeof(f), NULL, 0); } + +#ifdef DEBUG +int cman_dump_objdb(cman_handle_t handle, char *filename) +{ + struct cman_handle *h = (struct cman_handle *)handle; + VALIDATE_HANDLE(h); + + return info_call(h, CMAN_CMD_DUMP_OBJDB, filename, strlen(filename)+1, NULL, 0); +} +#endif diff --git a/cman/lib/libcman.h b/cman/lib/libcman.h index 21acba3..4afe126 100644 --- a/cman/lib/libcman.h +++ b/cman/lib/libcman.h @@ -337,6 +337,9 @@ int cman_get_fenceinfo(cman_handle_t handle, int nodeid, uint64_t *fence_time, i /* Get stuff for cman_tool. Nobody else should use this */ int cman_get_extra_info(cman_handle_t handle, cman_extra_info_t *info, int maxlen); +/* Dump the objdb contents (only works if compiled with DEBUG enabled) */ +int cman_dump_objdb(cman_handle_t handle, char *filename); + /* * ----------------------------------------------------------------------------- * Admin functions. You will need privileges and have a handle created by hooks/post-receive -- Cluster Project