From 6754fec432e3a2a758af9308fd7447f6e20e4cea Mon Sep 17 00:00:00 2001 From: Goldwyn Rodrigues Date: Tue, 23 Jul 2013 09:06:23 -0500 Subject: [PATCH 1/5] Remove pacemaker/ais stuff --- configure.in | 58 +---------- ocfs2_controld/Makefile | 27 +++-- ocfs2_controld/cpg.c | 56 +++++----- ocfs2_controld/main.c | 270 ------------------------------------------------ 4 files changed, 42 insertions(+), 369 deletions(-) Index: ocfs2-tools-1.8.2+git.1361836695.ff84eb5/configure.in =================================================================== --- ocfs2-tools-1.8.2+git.1361836695.ff84eb5.orig/configure.in 2013-07-31 08:15:10.269877099 -0500 +++ ocfs2-tools-1.8.2+git.1361836695.ff84eb5/configure.in 2013-07-31 08:16:54.137970542 -0500 @@ -219,12 +219,6 @@ LIBS="$ocfs_tools_save_LIBS" AC_SUBST(BUILD_DEBUGOCFS2) -pcmk_found= -AC_CHECK_LIB(crmcluster, crm_get_peer, - [AC_CHECK_HEADER(pacemaker/crm_config.h, pcmk_found=yes, - [AC_MSG_WARN([Pacemaker headers not found, pacemaker support will not be built])])], - [AC_MSG_WARN([libcrmcluster not found, pacemaker support will not be built])]) - # We use cman_replyto_shutdown to insure a new enough libcman cman_found= AC_CHECK_LIB(cman, cman_replyto_shutdown, @@ -298,53 +292,6 @@ else fi AC_SUBST(CPG_LDFLAGS) -ckpt_found= -AC_CHECK_HEADER(openais/saCkpt.h, ckpt_found=yes, - [AC_MSG_WARN([openais/saCkpt.h not found, ocfs2_controld will not be built])], - [#include ]) - -AIS_LDFLAGS= -if test "x$ckpt_found" = "xyes"; then - ckpt_found= - TRY_PATH="$AIS_TRY_PATH" - AC_MSG_CHECKING([for saCkptInitialize in -lSaCkpt]) - while test "x$TRY_PATH" != "x"; do - TRY="`echo $TRY_PATH | cut -f1 -d:`" - NEW_TRY_PATH="`echo $TRY_PATH | cut -f2- -d:`" - if test "x$NEW_TRY_PATH" != "x$TRY_PATH"; then - TRY_PATH="$NEW_TRY_PATH" - else - TRY_PATH="" - fi - - if test "x$TRY" != "x"; then - TRY="-L${TRY}/openais" - fi - # TRY="$TRY" - - saved_LDFLAGS="$LDFLAGS" - saved_LIBS="$LIBS" - LDFLAGS="$LDFLAGS $TRY" - LIBS="-lSaCkpt" - AC_LINK_IFELSE([AC_LANG_CALL([], [saCkptInitialize])], - ckpt_found=yes) - LIBS="$saved_LIBS" - LDFLAGS="$saved_LDFLAGS" - - if test "x$ckpt_found" = "xyes"; then - AIS_LDFLAGS="$TRY" - break - fi - done -fi -if test "x$ckpt_found" = "xyes"; then - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) - AC_MSG_WARN([libSaCkpt not found, ocfs2_controld will not be built]) -fi -AC_SUBST(AIS_LDFLAGS) - libdlmcontrol_found= AC_CHECK_LIB(dlmcontrol, dlmc_fs_connect, [AC_CHECK_HEADER(libdlmcontrol.h, libdlmcontrol_found=yes, @@ -379,7 +326,7 @@ AC_SUBST(BUILD_FSDLM_SUPPORT) AC_SUBST(DL_LIBS) BUILD_OCFS2_CONTROLD= -if test "x$cpg_found" = "xyes" -a "x$ckpt_found" = "xyes" -a "x$libdlmcontrol_found" = "xyes"; then +if test "x$cpg_found" = "xyes" -a "x$libdlmcontrol_found" = "xyes"; then if test "x$fsdlm_found" = "xyes"; then BUILD_OCFS2_CONTROLD=yes else @@ -388,12 +335,6 @@ if test "x$cpg_found" = "xyes" -a "x$ckp fi AC_SUBST(BUILD_OCFS2_CONTROLD) -BUILD_PCMK_SUPPORT= -if test "x$pcmk_found" = "xyes" -a "x$BUILD_OCFS2_CONTROLD" = "xyes"; then - BUILD_PCMK_SUPPORT=yes -fi -AC_SUBST(BUILD_PCMK_SUPPORT) - BUILD_CMAN_SUPPORT= if test "x$cman_found" = "xyes" -a "x$BUILD_OCFS2_CONTROLD" = "xyes"; then BUILD_CMAN_SUPPORT=yes Index: ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/Makefile =================================================================== --- ocfs2-tools-1.8.2+git.1361836695.ff84eb5.orig/ocfs2_controld/Makefile 2013-07-31 08:15:39.324743014 -0500 +++ ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/Makefile 2013-07-31 08:15:50.516076420 -0500 @@ -14,18 +14,17 @@ endif ifneq ($(BUILD_PCMK_SUPPORT),) SBIN_PROGRAMS += ocfs2_controld.pcmk # Some pacemaker headers which pacemaker.c includes want this. -PCMK_INCLUDES = -I/usr/include/pacemaker -I/usr/include/heartbeat/ $(GLIB_CFLAGS) +#PCMK_INCLUDES = -I/usr/include/pacemaker -I/usr/include/heartbeat/ $(GLIB_CFLAGS) endif -INCLUDES = -I$(TOPDIR)/include -I. $(PCMK_INCLUDES) + +INCLUDES = -I$(TOPDIR)/include -I. LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2 LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a -COROSYNC_LIBS = $(CPG_LDFLAGS) -lcpg -OPENAIS_LIBS = $(AIS_LDFLAGS) -lSaCkpt +COROSYNC_LIBS = $(CPG_LDFLAGS) -lcpg -lcmap -lcfg -lquorum DLMCONTROL_LIBS = -ldlmcontrol -CRM_LIBS = -lcrmcluster -lstonithd -lcrmcommon ifdef OCFS2_DEBUG OPTS += -ggdb @@ -44,15 +43,16 @@ UNINST_HFILES = ocfs2_controld.h ifneq ($(HAVE_COROSYNC),) DEFINES += -DHAVE_COROSYNC=1 endif -DAEMON_CFILES = main.c cpg.c mount.c ckpt.c dlmcontrol.c +DAEMON_CFILES = main.c cpg.c mount.c dlmcontrol.c CMAN_CFILES = cman.c CMAN_DAEMON_CFILES = $(DAEMON_CFILES) $(CMAN_CFILES) CMAN_DAEMON_OBJS = $(subst .c,.o,$(CMAN_DAEMON_CFILES)) -PCMK_CFILES = pacemaker.c -PCMK_DAEMON_CFILES = $(DAEMON_CFILES) $(PCMK_CFILES) -PCMK_DAEMON_OBJS = $(subst .c,.o,$(PCMK_DAEMON_CFILES)) +COROSYNC_CFILES = +COROSYNC_DAEMON_CFILES = $(DAEMON_CFILES) $(COROSYNC_CFILES) +COROSYNC_DAEMON_OBJS = $(subst .c,.o,$(COROSYNC_DAEMON_CFILES)) + TEST_CFILES = test_client.c TEST_OBJS = $(subst .c,.o,$(TEST_CFILES) $(PROTO_CFILES)) @@ -60,18 +60,17 @@ MANS = DIST_FILES = \ $(DAEMON_CFILES) \ - $(PCMK_CFILES) \ $(CMAN_CFILES) \ $(TEST_CFILES) \ $(UNINST_HFILES) \ $(addsuffix .in,$(MANS)) -ocfs2_controld.pcmk: $(PCMK_DAEMON_OBJS) $(LIBO2CB_DEPS) +ocfs2_controld.pcmk: $(COROSYNC_DAEMON_OBJS) $(LIBO2CB_DEPS) $(LINK) $(GLIB_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS) \ - $(OPENAIS_LIBS) $(COROSYNC_LIBS) \ - $(DLMCONTROL_LIBS) $(CRM_LIBS) + $(COROSYNC_LIBS) \ + $(DLMCONTROL_LIBS) ocfs2_controld.cman: $(CMAN_DAEMON_OBJS) $(LIBO2CB_DEPS) - $(LINK) $(LIBO2CB_LIBS) $(COM_ERR_LIBS) $(OPENAIS_LIBS) \ + $(LINK) $(LIBO2CB_LIBS) $(COM_ERR_LIBS) \ $(COROSYNC_LIBS) $(DLMCONTROL_LIBS) -lcman test_client: $(TEST_OBJS) $(LIBO2CB_DEPS) $(LIBOCFS2_DEPS) Index: ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/cpg.c =================================================================== --- ocfs2-tools-1.8.2+git.1361836695.ff84eb5.orig/ocfs2_controld/cpg.c 2013-07-31 08:15:39.325743044 -0500 +++ ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/cpg.c 2013-07-31 08:15:50.516076420 -0500 @@ -474,20 +474,20 @@ static struct cgroup *handle_to_group(cp return NULL; } -static void deliver_cb(cpg_handle_t handle, struct cpg_name *group_name, +static void deliver_cb(cpg_handle_t handle, const struct cpg_name *group_name, uint32_t nodeid, uint32_t pid, - void *data, int data_len) + void *data, size_t data_len) { log_debug("deliver called"); } -static void confchg_cb(cpg_handle_t handle, struct cpg_name *group_name, - struct cpg_address *member_list, - int member_list_entries, - struct cpg_address *left_list, - int left_list_entries, - struct cpg_address *joined_list, - int joined_list_entries) +static void confchg_cb(cpg_handle_t handle, const struct cpg_name *group_name, + const struct cpg_address *member_list, + size_t member_list_entries, + const struct cpg_address *left_list, + size_t left_list_entries, + const struct cpg_address *joined_list, + size_t joined_list_entries) { int i; struct cgroup *cg; @@ -499,13 +499,13 @@ static void confchg_cb(cpg_handle_t hand return; if (left_list_entries > CPG_MEMBERS_MAX) { - log_debug("left_list_entries %d", left_list_entries); + log_debug("left_list_entries %d", (int) left_list_entries); left_list_entries = CPG_MEMBERS_MAX; } else if (joined_list_entries > CPG_MEMBERS_MAX) { - log_debug("joined_list_entries %d", joined_list_entries); + log_debug("joined_list_entries %d", (int) joined_list_entries); joined_list_entries = CPG_MEMBERS_MAX; } else if (member_list_entries > CPG_MEMBERS_MAX) { - log_debug("member_list_entries %d", member_list_entries); + log_debug("member_list_entries %d", (int) member_list_entries); member_list_entries = CPG_MEMBERS_MAX; } @@ -530,7 +530,7 @@ static cpg_callbacks_t callbacks = { static void process_cpg(int ci) { - cpg_error_t error; + cs_error_t error; cpg_flow_control_state_t flow_control_state; struct cgroup *cg; @@ -539,15 +539,15 @@ static void process_cpg(int ci) return; cg->cg_got_confchg = 0; - error = cpg_dispatch(cg->cg_handle, CPG_DISPATCH_ONE); - if (error != CPG_OK) { + error = cpg_dispatch(cg->cg_handle, CS_DISPATCH_ONE); + if (error != CS_OK) { log_error("cpg_dispatch error %d", error); return; } error = cpg_flow_control_state_get(cg->cg_handle, &flow_control_state); - if (error != CPG_OK) + if (error != CS_OK) log_error("cpg_flow_control_state_get %d", error); else if (flow_control_state == CPG_FLOW_CONTROL_ENABLED) { message_flow_control_on = 1; @@ -582,21 +582,21 @@ static void dead_cpg(int ci) static int start_join(struct cgroup *cg) { - cpg_error_t error; + cs_error_t error; log_debug("Starting join for group \"%.*s\"", cg->cg_name.length, cg->cg_name.value); do { error = cpg_join(cg->cg_handle, &cg->cg_name); - if (error == CPG_OK) { + if (error == CS_OK) { log_debug("cpg_join succeeded"); error = 0; - } else if (error == CPG_ERR_TRY_AGAIN) { + } else if (error == CS_ERR_TRY_AGAIN) { log_debug("cpg_join retry"); sleep(1); } else log_error("cpg_join error %d", error); - } while (error == CPG_ERR_TRY_AGAIN); + } while (error == CS_ERR_TRY_AGAIN); return error; } @@ -604,7 +604,7 @@ static int start_join(struct cgroup *cg) static int start_leave(struct cgroup *cg) { int i; - cpg_error_t error; + cs_error_t error; if (!cg->cg_handle) return -EINVAL; @@ -615,14 +615,14 @@ static int start_leave(struct cgroup *cg for (i = 0; i < 10; i++) { error = cpg_leave(cg->cg_handle, &cg->cg_name); - if (error == CPG_ERR_TRY_AGAIN) { + if (error == CS_ERR_TRY_AGAIN) { if (!i) log_debug("cpg_leave retry"); sleep(1); continue; } - if (error == CPG_OK) + if (error == CS_OK) log_debug("cpg_leave succeeded"); else log_error("cpg_leave error %d", error); @@ -630,9 +630,9 @@ static int start_leave(struct cgroup *cg break; } - if (error == CPG_OK) + if (error == CS_OK) return 0; - else if (error == CPG_ERR_TRY_AGAIN) + else if (error == CS_ERR_TRY_AGAIN) return -EAGAIN; else return -EIO; @@ -641,7 +641,7 @@ static int start_leave(struct cgroup *cg static int init_group(struct cgroup *cg, const char *name) { - cpg_error_t error; + cs_error_t error; cg->cg_name.length = snprintf(cg->cg_name.value, CPG_MAX_NAME_LENGTH, @@ -653,7 +653,7 @@ static int init_group(struct cgroup *cg, } error = cpg_initialize(&cg->cg_handle, &callbacks); - if (error != CPG_OK) { + if (error != CS_OK) { log_error("cpg_initialize error %d", error); goto out; } @@ -740,7 +740,7 @@ static void daemon_set_cgroup(struct cgr int setup_cpg(void (*daemon_joined)(int first)) { - cpg_error_t error; + cs_error_t error; INIT_LIST_HEAD(&group_list); daemon_group.cg_set_cgroup = daemon_set_cgroup; Index: ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/main.c =================================================================== --- ocfs2-tools-1.8.2+git.1361836695.ff84eb5.orig/ocfs2_controld/main.c 2013-07-31 08:15:10.359879781 -0500 +++ ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/main.c 2013-07-31 08:15:50.517076450 -0500 @@ -651,255 +651,6 @@ static int proto_version_to_checkpoint(s return 0; } -static int checkpoint_to_proto_version(char *data, size_t data_len, - struct ocfs2_protocol_version *proto) -{ - long major, minor; - char *ptr; - struct proto_version_str { - char major[2]; - char space; - char minor[2]; - char null; - } str; - - if (data_len != sizeof(struct proto_version_str)) { - log_error("Protocol version string \"%.*s\" has incorrect " - "length", - (int)data_len, data); - return -EINVAL; - } - memcpy((char *)&str, data, data_len); - - if ((str.space != ' ') || (str.null != '\0')) { - log_error("Protocol version string \"%.*s\" has invalid " - "separators", - (int)data_len, data); - return -EINVAL; - } - str.space = '\0'; - - major = strtol(str.major, &ptr, 16); - if (!ptr || *ptr) { - log_error("Protocol request has bad version 0x%s 0x%s", - str.major, str.minor); - return -EINVAL; - } - minor = strtol(str.minor, &ptr, 16); - if (!ptr || *ptr) { - log_error("Protocol version string has bad version 0x%s 0x%s", - str.major, str.minor); - return -EINVAL; - } - - /* The major and minor must be between 0 and 255, inclusive. */ - if ((major == LONG_MIN) || (major == LONG_MAX) || - (minor == LONG_MIN) || (minor == LONG_MAX) || - (major > (uint8_t)-1) || (major < 0) || - (minor > (uint8_t)-1) || (minor < 0)) { - log_error("Protocol version string has bad version 0x%s 0x%s", - str.major, str.minor); - return -ERANGE; - } - - proto->pv_major = major; - proto->pv_minor = minor; - - return 0; -} - -static int install_node_checkpoint(void) -{ - int rc; - char *buf; - errcode_t err; - - err = o2cb_get_max_locking_protocol(&fs_max_proto); - if (err) { - log_error("Error querying maximum filesystem locking " - "protocol: %s", - error_message(err)); - rc = -EIO; - goto out; - } - - rc = ckpt_open_this_node(&node_handle); - if (rc) - goto out; - - rc = proto_version_to_checkpoint(&daemon_max_proto, &buf); - if (rc) - goto out; - - rc = ckpt_section_store(node_handle, DAEMON_MAX_PROTOCOL_SECTION, - buf, strlen(buf) + 1); - free(buf); - if (rc) - goto out; - - rc = proto_version_to_checkpoint(&fs_max_proto, &buf); - if (rc) - goto out; - - rc = ckpt_section_store(node_handle, FS_MAX_PROTOCOL_SECTION, - buf, strlen(buf) + 1); - free(buf); - -out: - return rc; -} - -static void drop_node_checkpoint(void) -{ - if (node_handle) - ckpt_close(node_handle); -} - -/* - * If we're the only daemon running, install our maximum protocols - * as the running values. - */ -static int install_global_checkpoint(void) -{ - int rc; - char *buf; - - daemon_running_proto = daemon_max_proto; - fs_running_proto = fs_max_proto; - - rc = ckpt_open_global(1); - if (rc) - goto out; - - rc = proto_version_to_checkpoint(&daemon_running_proto, &buf); - if (rc) - goto out; - - rc = ckpt_global_store(DAEMON_PROTOCOL_SECTION, buf, - strlen(buf) + 1); - free(buf); - if (rc) - goto out; - - rc = proto_version_to_checkpoint(&fs_running_proto, &buf); - if (rc) - goto out; - - rc = ckpt_global_store(FS_PROTOCOL_SECTION, buf, strlen(buf) + 1); - free(buf); - -out: - return rc; -} - -/* - * Compare the cluster's locking protocol version against our maximum. - * - * If the major numbers are different, they are incompatible. - * If the cluster's minor is greater than our maximum minor, they are - * incompatible. - */ -static int protocol_compatible(struct ocfs2_protocol_version *cluster, - struct ocfs2_protocol_version *our_max) -{ - if (cluster->pv_major != our_max->pv_major) - return 0; - - if (cluster->pv_minor > our_max->pv_minor) - return 0; - - return 1; -} - -static int read_global_checkpoint(void) -{ - int rc, seen = 0, opened = 0, retrycount = 0; - char *buf; - size_t len; - -retry: - rc = ckpt_open_global(0); - if (rc) - goto out; - seen = 1; - opened = 1; - - rc = ckpt_global_get(DAEMON_PROTOCOL_SECTION, &buf, &len); - if (rc) - goto out; - - rc = checkpoint_to_proto_version(buf, len, &daemon_running_proto); - free(buf); - if (rc) - goto out; - if (!protocol_compatible(&daemon_running_proto, - &daemon_max_proto)) { - log_error("Our maximum daemon protocol (%d.%d) is not " - "compatible with the cluster's protocol (%d.%d)", - daemon_max_proto.pv_major, - daemon_max_proto.pv_minor, - daemon_running_proto.pv_major, - daemon_running_proto.pv_minor); - rc = -EPROTONOSUPPORT; - goto out; - } - - rc = ckpt_global_get(FS_PROTOCOL_SECTION, &buf, &len); - if (rc) - goto out; - - rc = checkpoint_to_proto_version(buf, len, &fs_running_proto); - free(buf); - if (rc) - goto out; - - if (!protocol_compatible(&fs_running_proto, - &fs_max_proto)) { - log_error("Our maximum fs protocol (%d.%d) is not " - "compatible with the cluster's protocol (%d.%d)", - fs_max_proto.pv_major, - fs_max_proto.pv_minor, - fs_running_proto.pv_major, - fs_running_proto.pv_minor); - rc = -EPROTONOSUPPORT; - } - -out: - if (rc == -ENOENT) { - /* - * -ENOENT means the first daemon hasn't gotten the - * global checkpoint fully installed yet. Either the - * checkpoint or one of its sections is missing. - * - * If we saw the checkpoint once, but now it's gone, it - * means the first daemon died. We don't recover from - * that. But if we haven't seen the checkpoint yet, or if - * it's just a missing section, we can keep trying. - */ - - if (opened) - ckpt_close_global(); - - if (seen && !opened) { - log_error("The global checkpoint disappeared out " - "from underneath us. This shouldn't " - "happen to a daemon that is not the " - "first in the cluster"); - } else { - opened = 0; - retry_warning(retrycount, - "Attempted to read the cluster's " - "protocol versions %d times, still " - "trying", - retrycount); - sleep_ms(10); - goto retry; - } - } - - return rc; -} - static void cpg_joined(int first) { int rv; @@ -908,16 +659,6 @@ static void cpg_joined(int first) log_debug("CPG is live, we are %s first daemon", first ? "the" : "not the"); - if (first) - rv = install_global_checkpoint(); - else - rv = read_global_checkpoint(); - - if (rv) { - shutdown_daemon(); - return; - } - log_debug("Daemon protocol is %d.%d", daemon_running_proto.pv_major, daemon_running_proto.pv_minor); @@ -1018,14 +759,6 @@ static int loop(void) if (rv < 0) goto out; - rv = setup_stack(); - if (rv < 0) - goto out; - - rv = setup_ckpt(); - if (rv < 0) - goto out; - rv = install_node_checkpoint(); if (rv < 0) goto out; @@ -1077,9 +810,6 @@ stop: o2cb_control_close(); exit_dlmcontrol(); exit_cpg(); - drop_node_checkpoint(); - exit_ckpt(); - exit_stack(); out: return rv;