Accepting request 185215 from home:goldwynr:branches:network:ha-clustering:Factory

update to be compatible with corosync 2.3.x

OBS-URL: https://build.opensuse.org/request/show/185215
OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/ocfs2-tools?expand=0&rev=60
This commit is contained in:
Goldwyn Rodrigues 2013-07-31 14:13:16 +00:00 committed by Git OBS Bridge
parent 086555113f
commit 4633b6be45
7 changed files with 1042 additions and 72 deletions

View File

@ -0,0 +1,648 @@
From 6754fec432e3a2a758af9308fd7447f6e20e4cea Mon Sep 17 00:00:00 2001
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
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 <openais/saAis.h>])
-
-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;

View File

@ -0,0 +1,315 @@
From 1a7b9a35228cd5ef9d6ad96ec35f6fc812ee821c Mon Sep 17 00:00:00 2001
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
Date: Tue, 23 Jul 2013 12:09:28 -0500
Subject: [PATCH 2/5] Add corosync cfg to get configuration information
---
ocfs2_controld/Makefile | 2 +-
ocfs2_controld/cpg.c | 1 -
ocfs2_controld/main.c | 58 ++-------------------
ocfs2_controld/member.c | 111 ++++++++++++++++++++++++++++++++++++++++
ocfs2_controld/ocfs2_controld.h | 20 ++------
5 files changed, 119 insertions(+), 73 deletions(-)
create mode 100644 ocfs2_controld/member.c
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:25:43.559675366 -0500
+++ ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/Makefile 2013-07-31 08:26:05.733331692 -0500
@@ -49,7 +49,7 @@ CMAN_CFILES = cman.c
CMAN_DAEMON_CFILES = $(DAEMON_CFILES) $(CMAN_CFILES)
CMAN_DAEMON_OBJS = $(subst .c,.o,$(CMAN_DAEMON_CFILES))
-COROSYNC_CFILES =
+COROSYNC_CFILES = member.c
COROSYNC_DAEMON_CFILES = $(DAEMON_CFILES) $(COROSYNC_CFILES)
COROSYNC_DAEMON_OBJS = $(subst .c,.o,$(COROSYNC_DAEMON_CFILES))
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:25:34.868418089 -0500
+++ ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/cpg.c 2013-07-31 08:25:43.559675366 -0500
@@ -339,7 +339,6 @@ static void handle_daemon_left(struct cp
if (1) {
log_error("kill node %d - ocfs2_controld PROCDOWN",
addr->nodeid);
- kill_stack_node(addr->nodeid);
}
/* FALL THROUGH */
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:25:34.837417171 -0500
+++ ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/main.c 2013-07-31 08:25:43.560675395 -0500
@@ -114,10 +114,8 @@ static struct ocfs2_protocol_version dae
.pv_major = CONTROLD_PROTOCOL_MAJOR,
.pv_minor = CONTROLD_PROTOCOL_MINOR,
};
-static struct ocfs2_protocol_version fs_max_proto;
struct ocfs2_protocol_version daemon_running_proto;
struct ocfs2_protocol_version fs_running_proto;
-struct ckpt_handle *node_handle;
void shutdown_daemon(void)
{
@@ -254,11 +252,6 @@ static int do_mount(int ci, int fd, cons
goto fail;
}
- if (!validate_cluster(cluster)) {
- error_msg = "Invalid cluster name";
- goto fail;
- }
-
return start_mount(ci, fd, uuid, device, service);
fail:
@@ -456,11 +449,6 @@ static int send_filesystems(int ci, int
goto fail;
}
- if (!validate_cluster(cluster)) {
- error_msg = "Invalid cluster name";
- goto fail;
- }
-
return send_mountgroups(ci, fd);
fail:
@@ -471,15 +459,6 @@ static int send_clustername(int ci, int
{
int rc = 0, rctmp;
char error_msg[100]; /* Arbitrary size smaller than a message */
- const char *cluster;
-
- rc = get_clustername(&cluster);
- if (rc) {
- snprintf(error_msg, sizeof(error_msg),
- "Unable to query cluster name: %s",
- strerror(-rc));
- goto out_status;
- }
/* Cman only supports one cluster */
rc = send_message(fd, CM_ITEMCOUNT, 1);
@@ -490,7 +469,7 @@ static int send_clustername(int ci, int
goto out_status;
}
- rc = send_message(fd, CM_ITEM, cluster);
+ rc = send_message(fd, CM_ITEM, cluster_name);
if (rc) {
snprintf(error_msg, sizeof(error_msg),
"Unable to send ITEM: %s",
@@ -630,27 +609,6 @@ static int setup_listener(void)
return 0;
}
-static int proto_version_to_checkpoint(struct ocfs2_protocol_version *proto,
- char **checkpoint_data)
-{
- size_t len;
- char *buf;
-
- len = snprintf(NULL, 0, "%02x %02x", proto->pv_major,
- proto->pv_minor);
- buf = malloc(sizeof(char) * (len + 1));
- if (!buf) {
- log_error("Unable to allocate memory for checkpoint data");
- return -ENOMEM;
- }
-
- snprintf(buf, len + 1, "%02x %02x", proto->pv_major,
- proto->pv_minor);
- *checkpoint_data = buf;
-
- return 0;
-}
-
static void cpg_joined(int first)
{
int rv;
@@ -759,7 +717,7 @@ static int loop(void)
if (rv < 0)
goto out;
- rv = install_node_checkpoint();
+ rv = setup_cluster_cfg();
if (rv < 0)
goto out;
@@ -1032,17 +990,6 @@ int main(int argc, char **argv)
return 1;
}
- err = o2cb_get_stack_name(&stack);
- if (err) {
- com_err(prog_name, err, "while determining the current cluster stack");
- return 1;
- }
- if (strcmp(stack, stackname)) {
- log_error("%s: This daemon supports the \"%s\" stack, but the \"%s\" stack is in use",
- prog_name, stackname, stack);
- return 1;
- }
-
if (!daemon_debug_opt)
daemonize();
Index: ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/member.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/member.c 2013-07-31 08:25:43.560675395 -0500
@@ -0,0 +1,111 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+
+#include "ocfs2_controld.h"
+#include <corosync/corotypes.h>
+#include <corosync/cfg.h>
+#include <corosync/cmap.h>
+
+
+char cluster_name[65];
+int our_nodeid;
+
+static corosync_cfg_handle_t ch;
+
+static int detect_cluster_name(void)
+{
+ cmap_handle_t handle;
+ char *str = NULL;
+ int rv, err = -1;
+
+ rv = cmap_initialize(&handle);
+ if (rv != CS_OK) {
+ log_error("cmap_initialize error %d", rv);
+ return -1;
+ }
+
+ rv = cmap_get_string(handle, "totem.cluster_name", &str);
+ if (rv != CS_OK) {
+ log_error("cmap_get_string totem.cluster_name error %d", rv);
+ goto out;
+ } else
+ err = 0;
+
+ log_debug("cmap totem.cluster_name = '%s'", str);
+
+ strncpy(cluster_name, str, 64);
+out:
+ if (str)
+ free(str);
+ cmap_finalize(handle);
+ return err;
+}
+
+static void shutdown_callback(corosync_cfg_handle_t h,
+ corosync_cfg_shutdown_flags_t flags)
+{
+ if (flags & COROSYNC_CFG_SHUTDOWN_FLAG_REQUEST) {
+ log_debug("shutdown request yes");
+ corosync_cfg_replyto_shutdown(ch, COROSYNC_CFG_SHUTDOWN_FLAG_YES);
+ }
+}
+
+static corosync_cfg_callbacks_t cfg_callbacks =
+{
+ .corosync_cfg_shutdown_callback = shutdown_callback,
+};
+
+int setup_cluster_cfg(void)
+{
+ cs_error_t err;
+ unsigned int nodeid;
+ int fd;
+ int retry = 1;
+
+try_again:
+ err = corosync_cfg_initialize(&ch, &cfg_callbacks);
+ if (err != CS_OK) {
+ if ((err == CS_ERR_TRY_AGAIN) && (retry <= 10)) {
+ log_error("corosync has not completed initialization.. retry %d", retry);
+ sleep(1);
+ retry++;
+ goto try_again;
+ }
+ log_error("corosync cfg init error %d", err);
+ return -1;
+ }
+
+ err = corosync_cfg_fd_get(ch, &fd);
+ if (err != CS_OK) {
+ log_error("corosync cfg fd_get error %d", err);
+ corosync_cfg_finalize(ch);
+ return -1;
+ }
+
+ err = corosync_cfg_local_get(ch, &nodeid);
+ if (err != CS_OK) {
+ log_error("corosync cfg local_get error %d", err);
+ corosync_cfg_finalize(ch);
+ return -1;
+ }
+
+ our_nodeid = nodeid;
+ log_debug("our_nodeid %d", our_nodeid);
+
+ if (our_nodeid < 0) {
+ log_error("negative nodeid, set corosync totem.clear_node_high_bit");
+ corosync_cfg_finalize(ch);
+ return -1;
+ }
+
+ return fd;
+}
+
+void close_cluster_cfg(void)
+{
+ corosync_cfg_finalize(ch);
+}
+
+
Index: ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/ocfs2_controld.h
===================================================================
--- ocfs2-tools-1.8.2+git.1361836695.ff84eb5.orig/ocfs2_controld/ocfs2_controld.h 2013-07-31 08:25:34.869418118 -0500
+++ ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/ocfs2_controld.h 2013-07-31 08:25:43.560675395 -0500
@@ -39,6 +39,7 @@ extern int dump_point;
extern int dump_wrap;
extern int our_nodeid;
extern const char *stackname;
+extern char cluster_name[65];
extern void daemon_dump_save(void);
@@ -70,25 +71,12 @@ int connection_add(int fd, void (*work)(
void connection_dead(int ci);
void shutdown_daemon(void);
-/* ckpt.c */
-int setup_ckpt(void);
-void exit_ckpt(void);
-int ckpt_open_global(int write);
-void ckpt_close_global(void);
-int ckpt_open_node(int nodeid, struct ckpt_handle **handle);
-int ckpt_open_this_node(struct ckpt_handle **handle);
-void ckpt_close(struct ckpt_handle *handle);
-int ckpt_global_store(const char *section, const char *data, size_t data_len);
-int ckpt_global_get(const char *section, char **data, size_t *data_len);
-int ckpt_section_store(struct ckpt_handle *handle, const char *section,
- const char *data, size_t data_len);
-int ckpt_section_get(struct ckpt_handle *handle, const char *section,
- char **data, size_t *data_len);
-
+/* member.c */
+int setup_cluster_cfg(void);
+void close_cluster_cfg(void);
/* stack-specific interfaces (cman.c) */
int setup_stack(void);
char *nodeid2name(int nodeid);
-int validate_cluster(const char *cluster);
int get_clustername(const char **cluster);
int kill_stack_node(int nodeid);
void exit_stack(void);

View File

@ -0,0 +1,30 @@
From 1b81ab8b660db633aff609bfae4609efe24b9b93 Mon Sep 17 00:00:00 2001
From: Goldwyn Rodrigues <goldwyn@localhost.localdomain>
Date: Sat, 27 Jul 2013 14:28:48 -0500
Subject: [PATCH 3/5] Hard-code protocol versions.
This is just a work around. Protocol detection needs some work.
---
ocfs2_controld/main.c | 6 ++++++
1 file changed, 6 insertions(+)
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:21:50.088759215 -0500
+++ ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/main.c 2013-07-31 08:22:27.023854129 -0500
@@ -617,9 +617,15 @@ static void cpg_joined(int first)
log_debug("CPG is live, we are %s first daemon",
first ? "the" : "not the");
+ daemon_running_proto.pv_major = 1;
+ daemon_running_proto.pv_minor = 0;
+
log_debug("Daemon protocol is %d.%d",
daemon_running_proto.pv_major,
daemon_running_proto.pv_minor);
+
+ fs_running_proto.pv_major = 1;
+ fs_running_proto.pv_minor = 0;
log_debug("fs protocol is %d.%d",
fs_running_proto.pv_major, fs_running_proto.pv_minor);

View File

@ -0,0 +1,31 @@
From af06444bea1bcc8006c295a5a2663e0372814df5 Mon Sep 17 00:00:00 2001
From: Goldwyn Rodrigues <rgoldwyn@suse.de>
Date: Sun, 28 Jul 2013 17:49:21 -0500
Subject: [PATCH 5/5] Add cluster_name and stack name
---
ocfs2_controld/member.c | 4 ++++
1 file changed, 4 insertions(+)
Index: ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/member.c
===================================================================
--- ocfs2-tools-1.8.2+git.1361836695.ff84eb5.orig/ocfs2_controld/member.c 2013-07-31 08:20:04.239619381 -0500
+++ ocfs2-tools-1.8.2+git.1361836695.ff84eb5/ocfs2_controld/member.c 2013-07-31 08:23:47.608241901 -0500
@@ -11,6 +11,8 @@
char cluster_name[65];
int our_nodeid;
+/* Using pcmk for legacy reasons */
+const char *stackname = "pcmk";
static corosync_cfg_handle_t ch;
@@ -93,6 +95,8 @@ try_again:
our_nodeid = nodeid;
log_debug("our_nodeid %d", our_nodeid);
+ detect_cluster_name();
+ log_debug("our cluster name %s", cluster_name);
if (our_nodeid < 0) {
log_error("negative nodeid, set corosync totem.clear_node_high_bit");

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Jul 31 08:01:02 CDT 2013 - rgoldwyn@suse.com
- Get ocfs2_controld up to speed with corosync 2.3.x
+ 0001-Remove-pacemaker-ais-stuff.patch
+ 0002-Add-corosync-cfg-to-get-configuration-information.patch
+ 0003-Hard-code-protocol-versions.patch
+ 0005-Add-cluster_name-and-stack-name.patch
- ocfs2_controld-pacemaker.diff
-------------------------------------------------------------------
Mon Jul 22 10:57:44 UTC 2013 - ygao@suse.com

View File

@ -29,7 +29,6 @@ Source2: reflink.tar.bz2
Patch101: force-debug.patch
Patch102: extra-debug.patch
Patch103: debug-ocfs2_hb_ctl.patch
Patch104: ocfs2_controld-pacemaker.diff
Patch105: bug-470741-debug_start_failures.patch
Patch106: ocfs2-devel.diff
Patch107: reflink-no-syscall.patch
@ -46,14 +45,17 @@ Patch212: bug-805764-ocfs2-controld.patch
Patch213: bnc804707-reduce-RR-priority.patch
Patch214: use-symlink-in-udev-rules.patch
Patch215: ocfs2console-libraries-include-aio.patch
Patch216: 0001-Remove-pacemaker-ais-stuff.patch
Patch217: 0002-Add-corosync-cfg-to-get-configuration-information.patch
Patch218: 0003-Hard-code-protocol-versions.patch
Patch219: 0005-Add-cluster_name-and-stack-name.patch
BuildRequires: autoconf
BuildRequires: e2fsprogs-devel
BuildRequires: libaio-devel
BuildRequires: libbz2-devel
BuildRequires: libcorosync-devel
BuildRequires: libdlm-devel
BuildRequires: libopenais-devel
BuildRequires: libpacemaker-devel
BuildRequires: libxslt-devel
BuildRequires: libz1
BuildRequires: python-devel
@ -69,7 +71,6 @@ Requires: e2fsprogs
Requires: glib2 >= 2.2.3
Requires: modutils
Requires: net-tools
Requires: openais
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} < 1120
# There's no separate kmp for openSUSE 11.2
@ -128,7 +129,6 @@ managing the file system.
%patch101 -p1
%patch102 -p1
%patch103 -p1
%patch104 -p1
%patch105 -p1
%patch106 -p1
%patch107 -p0
@ -145,6 +145,10 @@ managing the file system.
%patch213 -p1
%patch214 -p1
%patch215 -p1
%patch216 -p1
%patch217 -p1
%patch218 -p1
%patch219 -p1
%build
export PROJECT="ocfs2-tools"

View File

@ -1,67 +0,0 @@
Index: ocfs2-tools/ocfs2_controld/pacemaker.c
===================================================================
--- ocfs2-tools.orig/ocfs2_controld/pacemaker.c
+++ ocfs2-tools/ocfs2_controld/pacemaker.c
@@ -28,9 +28,8 @@
#define SUPPORT_HEARTBEAT 0
#include <pacemaker/crm/crm.h>
-#include <pacemaker/crm/ais.h>
-#include <pacemaker/crm/common/cluster.h>
-#include <pacemaker/crm/common/stack.h>
+#include <pacemaker/crm/cluster.h>
+#include <pacemaker/crm/cluster/plugin.h>
#include <pacemaker/crm/common/ipc.h>
#include <pacemaker/crm/msg_xml.h>
@@ -47,6 +46,7 @@ static char * clustername = "pacemaker"
extern struct list_head mounts;
const char *stackname = "pcmk";
+static crm_cluster_t crm_cluster;
extern int ais_fd_async;
char *local_node_uname = NULL;
@@ -138,33 +138,34 @@ static void dead_pcmk(int ci)
connection_dead(ci);
}
-extern void terminate_ais_connection(void);
-
void exit_stack(void)
{
log_debug("closing pacemaker connection");
- terminate_ais_connection();
+ crm_cluster_disconnect(&crm_cluster);
}
static void process_pcmk(int ci)
{
- ais_dispatch(ais_fd_async, NULL);
+ plugin_dispatch(&crm_cluster);
}
int setup_stack(void)
{
- crm_log_init("ocfs2_controld", LOG_INFO, FALSE, TRUE, 0, NULL);
+ crm_log_init("ocfs2_controld", LOG_INFO, FALSE, TRUE, 0, NULL, FALSE);
- if(init_ais_connection(NULL, NULL, NULL, &local_node_uname, &our_nodeid) == FALSE) {
+ if(crm_cluster_connect(&crm_cluster) == FALSE) {
log_error("Connection to our AIS plugin (CRM) failed");
return -1;
}
+ local_node_uname = crm_cluster.uname;
+ our_nodeid = crm_cluster.nodeid;
+
/* Sign up for membership updates */
- send_ais_text(crm_class_notify, "true", TRUE, NULL, crm_msg_ais);
+ send_cluster_text(crm_class_notify, "true", TRUE, NULL, crm_msg_ais);
/* Requesting the current list of known nodes */
- send_ais_text(crm_class_members, __FUNCTION__, TRUE, NULL, crm_msg_ais);
+ send_cluster_text(crm_class_members, __FUNCTION__, TRUE, NULL, crm_msg_ais);
log_debug("Cluster connection established. Local node id: %d", our_nodeid);