public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: master - cman: Remove quorum service & use votequorum from corosync
@ 2009-01-26 13:14 Christine Caulfield
0 siblings, 0 replies; only message in thread
From: Christine Caulfield @ 2009-01-26 13:14 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=681f16bbd3c4f1e00fafe14ec7028354d1fd5296
Commit: 681f16bbd3c4f1e00fafe14ec7028354d1fd5296
Parent: 963587d79bd93cf75acc66191fa1291c9c19ca16
Author: Christine Caulfield <ccaulfie@redhat.com>
AuthorDate: Mon Jan 26 13:12:45 2009 +0000
Committer: Christine Caulfield <ccaulfie@redhat.com>
CommitterDate: Mon Jan 26 13:12:45 2009 +0000
cman: Remove quorum service & use votequorum from corosync
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
---
cman/cman_tool/Makefile | 2 +-
cman/cman_tool/main.c | 5 +-
cman/config/cman-preconfig.c | 2 +-
cman/services/Makefile | 2 +-
cman/services/cman/lib/Makefile | 2 +-
cman/services/cman/lib/libcman.c | 94 +-
cman/services/cman/lib/libcman.h | 2 +-
cman/services/quorum/Makefile | 4 -
cman/services/quorum/include/corosync/cmanquorum.h | 172 --
.../quorum/include/corosync/ipc_cmanquorum.h | 123 --
cman/services/quorum/lib/Makefile | 14 -
cman/services/quorum/lib/libcmanquorum.c | 830 ----------
cman/services/quorum/services/Makefile | 26 -
cman/services/quorum/services/cmanquorum.c | 1657 --------------------
cman/services/quorum/test/Makefile | 26 -
cman/services/quorum/test/testcmanquorum1.c | 126 --
cman/services/quorum/test/testcmanquorum2.c | 63 -
17 files changed, 55 insertions(+), 3095 deletions(-)
diff --git a/cman/cman_tool/Makefile b/cman/cman_tool/Makefile
index 3db7e49..057218a 100644
--- a/cman/cman_tool/Makefile
+++ b/cman/cman_tool/Makefile
@@ -19,13 +19,13 @@ CFLAGS += -I${incdir}
LDFLAGS += -L${cmanlibdir} -lcman
LDFLAGS += -L${ccslibdir} -lccs
+LDFLAGS += -L${corosynclibdir} -lvotequorum
LDFLAGS += -L${libdir}
${TARGET}: ${OBJS}
$(CC) -o $@ $^ $(LDFLAGS)
depends:
- $(MAKE) -C ../services/quorum/lib all
$(MAKE) -C ../services/cman/lib all
clean: generalclean
diff --git a/cman/cman_tool/main.c b/cman/cman_tool/main.c
index c8c45c9..9447291 100644
--- a/cman/cman_tool/main.c
+++ b/cman/cman_tool/main.c
@@ -233,10 +233,11 @@ static void show_status(void)
printf(" 2node");
if (einfo->ei_flags & CMAN_EXTRA_FLAG_DISALLOWED)
printf(" DisallowedNodes");
- if (einfo->ei_flags & CMAN_EXTRA_FLAG_DIRTY)
- printf(" Dirty");
+ if (einfo->ei_flags & CMAN_EXTRA_FLAG_HASSTATE)
+ printf(" HasState");
printf(" \n");
+ memset(&node, 0, sizeof(node));
if (cman_get_node(h, CMAN_NODEID_US, &node) == 0) {
printf("Node name: %s\n", node.cn_name);
printf("Node ID: %d\n", node.cn_nodeid);
diff --git a/cman/config/cman-preconfig.c b/cman/config/cman-preconfig.c
index 233bbad..c3d9cee 100644
--- a/cman/config/cman-preconfig.c
+++ b/cman/config/cman-preconfig.c
@@ -840,7 +840,7 @@ static void add_cman_overrides(struct objdb_iface_ver0 *objdb)
objdb->object_find_destroy(find_handle);
objdb->object_key_create(object_handle, "provider", strlen("provider"),
- "corosync_cmanquorum", strlen("corosync_cmanquorum") + 1);
+ "corosync_votequorum", strlen("corosync_votequorum") + 1);
if (!expected_votes)
expected_votes = sum_expected(objdb);
diff --git a/cman/services/Makefile b/cman/services/Makefile
index a74b599..2f30f36 100644
--- a/cman/services/Makefile
+++ b/cman/services/Makefile
@@ -1,4 +1,4 @@
include ../../make/defines.mk
include $(OBJDIR)/make/passthrough.mk
-SUBDIRS=quorum cman
+SUBDIRS=cman
diff --git a/cman/services/cman/lib/Makefile b/cman/services/cman/lib/Makefile
index 6ea115f..f35b104 100644
--- a/cman/services/cman/lib/Makefile
+++ b/cman/services/cman/lib/Makefile
@@ -17,4 +17,4 @@ CFLAGS += -I../include -I../../quorum/include
LDFLAGS += -L${corosynclibdir} -lcoroutil -lcfg
LDFLAGS += -L${ccslibdir} -lccs
-LDFLAGS += -L../../quorum/lib/ -Wl,-Bstatic -lcmanquorum -Wl,-Bdynamic
+LDFLAGS += -lvotequorum
diff --git a/cman/services/cman/lib/libcman.c b/cman/services/cman/lib/libcman.c
index cceda35..735a04c 100644
--- a/cman/services/cman/lib/libcman.c
+++ b/cman/services/cman/lib/libcman.c
@@ -18,7 +18,7 @@
#include <corosync/ais_util.h>
#include <corosync/cfg.h>
#include <corosync/confdb.h>
-#include <corosync/cmanquorum.h>
+#include <corosync/votequorum.h>
#include <corosync/ipc_cman.h>
#include "ccs.h"
@@ -41,27 +41,27 @@ struct cman_inst {
pthread_mutex_t dispatch_mutex;
int node_count;
- cmanquorum_node_t * node_list;
+ votequorum_node_t * node_list;
int node_list_size;
corosync_cfg_handle_t cfg_handle;
- cmanquorum_handle_t cmq_handle;
+ votequorum_handle_t cmq_handle;
};
static void cfg_shutdown_callback(
corosync_cfg_handle_t handle,
corosync_cfg_shutdown_flags_t flags);
-static void cmanquorum_notification_callback(
- cmanquorum_handle_t handle,
+static void votequorum_notification_callback(
+ votequorum_handle_t handle,
uint64_t context,
uint32_t quorate,
uint32_t node_list_entries,
- cmanquorum_node_t node_list[]);
+ votequorum_node_t node_list[]);
-static cmanquorum_callbacks_t cmq_callbacks =
+static votequorum_callbacks_t cmq_callbacks =
{
- .cmanquorum_notify_fn = cmanquorum_notification_callback,
+ .votequorum_notify_fn = votequorum_notification_callback,
};
static corosync_cfg_callbacks_t cfg_callbacks =
@@ -92,16 +92,16 @@ static void cfg_shutdown_callback(
}
-static void cmanquorum_notification_callback(
- cmanquorum_handle_t handle,
+static void votequorum_notification_callback(
+ votequorum_handle_t handle,
uint64_t context,
uint32_t quorate,
uint32_t node_list_entries,
- cmanquorum_node_t node_list[])
+ votequorum_node_t node_list[])
{
struct cman_inst *cman_inst;
- cmanquorum_context_get(handle, (void **)&cman_inst);
+ votequorum_context_get(handle, (void **)&cman_inst);
/* Save information for synchronous queries */
cman_inst->node_count = node_list_entries;
@@ -109,9 +109,9 @@ static void cmanquorum_notification_callback(
if (cman_inst->node_list)
free(cman_inst->node_list);
- cman_inst->node_list = malloc(sizeof(cmanquorum_node_t) * node_list_entries * 2);
+ cman_inst->node_list = malloc(sizeof(votequorum_node_t) * node_list_entries * 2);
if (cman_inst->node_list) {
- memcpy(cman_inst->node_list, node_list, sizeof(cmanquorum_node_t) * node_list_entries);
+ memcpy(cman_inst->node_list, node_list, sizeof(votequorum_node_t) * node_list_entries);
cman_inst->node_list_size = node_list_entries;
}
}
@@ -120,14 +120,14 @@ static void cmanquorum_notification_callback(
cman_inst->notify_callback((void*)cman_inst, cman_inst->privdata, CMAN_REASON_STATECHANGE, quorate);
}
-static int cmanquorum_check_and_start(struct cman_inst *cman_inst)
+static int votequorum_check_and_start(struct cman_inst *cman_inst)
{
if (!cman_inst->cmq_handle) {
- if (cmanquorum_initialize(&cman_inst->cmq_handle, &cmq_callbacks) != CS_OK) {
+ if (votequorum_initialize(&cman_inst->cmq_handle, &cmq_callbacks) != CS_OK) {
errno = ENOMEM;
return -1;
}
- cmanquorum_context_set(cman_inst->cmq_handle, (void*)cman_inst);
+ votequorum_context_set(cman_inst->cmq_handle, (void*)cman_inst);
}
return 0;
}
@@ -136,12 +136,12 @@ static int refresh_node_list(struct cman_inst *cman_inst)
{
int error;
- if (cmanquorum_check_and_start(cman_inst))
+ if (votequorum_check_and_start(cman_inst))
return -1;
- cmanquorum_trackstart(cman_inst->cmq_handle, 0, CS_TRACK_CURRENT);
+ votequorum_trackstart(cman_inst->cmq_handle, 0, CS_TRACK_CURRENT);
- error = cmanquorum_dispatch(cman_inst->cmq_handle, CS_DISPATCH_ONE);
+ error = votequorum_dispatch(cman_inst->cmq_handle, CS_DISPATCH_ONE);
return error;
}
@@ -198,7 +198,7 @@ int cman_finish (
VALIDATE_HANDLE(cman_inst);
if (cman_inst->cmq_handle) {
- cmanquorum_finalize(cman_inst->cmq_handle);
+ votequorum_finalize(cman_inst->cmq_handle);
cman_inst->cmq_handle = 0;
}
if (cman_inst->cfg_handle) {
@@ -420,18 +420,18 @@ int cman_is_quorate(cman_handle_t handle)
{
struct cman_inst *cman_inst;
int quorate = -1;
- struct cmanquorum_info info;
+ struct votequorum_info info;
cman_inst = (struct cman_inst *)handle;
VALIDATE_HANDLE(cman_inst);
- if (cmanquorum_check_and_start(cman_inst))
+ if (votequorum_check_and_start(cman_inst))
return -1;
- if (cmanquorum_getinfo(cman_inst->cmq_handle, 0, &info) != CS_OK)
+ if (votequorum_getinfo(cman_inst->cmq_handle, 0, &info) != CS_OK)
errno = EINVAL;
else
- quorate = ((info.flags & CMANQUORUM_INFO_FLAG_QUORATE) != 0);
+ quorate = ((info.flags & VOTEQUORUM_INFO_FLAG_QUORATE) != 0);
return quorate;
}
@@ -539,10 +539,10 @@ int cman_set_votes(cman_handle_t handle, int votes, int nodeid)
cman_inst = (struct cman_inst *)handle;
VALIDATE_HANDLE(cman_inst);
- if (cmanquorum_check_and_start(cman_inst))
+ if (votequorum_check_and_start(cman_inst))
return -1;
- error = cmanquorum_setvotes(cman_inst->cmq_handle, nodeid, votes);
+ error = votequorum_setvotes(cman_inst->cmq_handle, nodeid, votes);
return error;
}
@@ -555,10 +555,10 @@ int cman_set_expected_votes(cman_handle_t handle, int expected)
cman_inst = (struct cman_inst *)handle;
VALIDATE_HANDLE(cman_inst);
- if (cmanquorum_check_and_start(cman_inst))
+ if (votequorum_check_and_start(cman_inst))
return -1;
- error = cmanquorum_setexpected(cman_inst->cmq_handle, expected);
+ error = votequorum_setexpected(cman_inst->cmq_handle, expected);
return error;
}
@@ -614,10 +614,10 @@ int cman_register_quorum_device(cman_handle_t handle, char *name, int votes)
cman_inst = (struct cman_inst *)handle;
VALIDATE_HANDLE(cman_inst);
- if (cmanquorum_check_and_start(cman_inst))
+ if (votequorum_check_and_start(cman_inst))
return -1;
- error = cmanquorum_qdisk_register(cman_inst->cmq_handle, name, votes);
+ error = votequorum_qdisk_register(cman_inst->cmq_handle, name, votes);
return error;
}
@@ -630,10 +630,10 @@ int cman_unregister_quorum_device(cman_handle_t handle)
cman_inst = (struct cman_inst *)handle;
VALIDATE_HANDLE(cman_inst);
- if (cmanquorum_check_and_start(cman_inst))
+ if (votequorum_check_and_start(cman_inst))
return -1;
- error = cmanquorum_qdisk_unregister(cman_inst->cmq_handle);
+ error = votequorum_qdisk_unregister(cman_inst->cmq_handle);
return error;
}
@@ -645,10 +645,10 @@ int cman_poll_quorum_device(cman_handle_t handle, int isavailable)
cman_inst = (struct cman_inst *)handle;
VALIDATE_HANDLE(cman_inst);
- if (cmanquorum_check_and_start(cman_inst))
+ if (votequorum_check_and_start(cman_inst))
return -1;
- error = cmanquorum_qdisk_poll(cman_inst->cmq_handle, 1);
+ error = votequorum_qdisk_poll(cman_inst->cmq_handle, 1);
return error;
}
@@ -657,15 +657,15 @@ int cman_get_quorum_device(cman_handle_t handle, struct cman_qdev_info *info)
{
struct cman_inst *cman_inst;
int error;
- struct cmanquorum_qdisk_info qinfo;
+ struct votequorum_qdisk_info qinfo;
cman_inst = (struct cman_inst *)handle;
VALIDATE_HANDLE(cman_inst);
- if (cmanquorum_check_and_start(cman_inst))
+ if (votequorum_check_and_start(cman_inst))
return -1;
- error = cmanquorum_qdisk_getinfo(cman_inst->cmq_handle, &qinfo);
+ error = votequorum_qdisk_getinfo(cman_inst->cmq_handle, &qinfo);
if (!error) {
info->qi_state = qinfo.state;
@@ -684,10 +684,10 @@ int cman_set_dirty(cman_handle_t handle)
cman_inst = (struct cman_inst *)handle;
VALIDATE_HANDLE(cman_inst);
- if (cmanquorum_check_and_start(cman_inst))
+ if (votequorum_check_and_start(cman_inst))
return -1;
- error = cmanquorum_setdirty(cman_inst->cmq_handle);
+ error = votequorum_setstate(cman_inst->cmq_handle);
return error;
}
@@ -1058,7 +1058,7 @@ int cman_get_disallowed_nodes(cman_handle_t handle, int maxnodes, int *retnodes,
int cman_get_node(cman_handle_t handle, int nodeid, cman_node_t *node)
{
struct cman_inst *cman_inst;
- struct cmanquorum_info qinfo;
+ struct votequorum_info qinfo;
int i;
int ccs_handle;
int ret = 0;
@@ -1074,7 +1074,7 @@ int cman_get_node(cman_handle_t handle, int nodeid, cman_node_t *node)
if (node->cn_name[0] == '\0') {
/* Query by node ID */
if (nodeid == CMAN_NODEID_US) {
- if (cmanquorum_getinfo(cman_inst->cmq_handle, 0, &qinfo) != CS_OK) {
+ if (votequorum_getinfo(cman_inst->cmq_handle, 0, &qinfo) != CS_OK) {
return -1;
}
nodeid = node->cn_nodeid = qinfo.node_id;
@@ -1116,12 +1116,12 @@ int cman_start_notification(cman_handle_t handle, cman_callback_t callback)
cman_inst = (struct cman_inst *)handle;
VALIDATE_HANDLE(cman_inst);
- if (cmanquorum_check_and_start(cman_inst))
+ if (votequorum_check_and_start(cman_inst))
return -1;
cman_inst->notify_callback = callback;
- if (cmanquorum_trackstart(cman_inst->cmq_handle, (uint64_t)(long)handle, CS_TRACK_CURRENT) != CS_OK)
+ if (votequorum_trackstart(cman_inst->cmq_handle, (uint64_t)(long)handle, CS_TRACK_CURRENT) != CS_OK)
return -1;
return 0;
@@ -1134,7 +1134,7 @@ int cman_stop_notification(cman_handle_t handle)
cman_inst = (struct cman_inst *)handle;
VALIDATE_HANDLE(cman_inst);
- cmanquorum_trackstop(cman_inst->cmq_handle);
+ votequorum_trackstop(cman_inst->cmq_handle);
cman_inst->notify_callback = NULL;
return 0;
@@ -1147,14 +1147,14 @@ int cman_get_extra_info(cman_handle_t handle, cman_extra_info_t *info, int maxle
struct cman_inst *cman_inst;
unsigned int ccs_handle;
char *value;
- struct cmanquorum_info qinfo;
+ struct votequorum_info qinfo;
cman_inst = (struct cman_inst *)handle;
VALIDATE_HANDLE(cman_inst);
refresh_node_list(cman_inst);
- if (cmanquorum_getinfo(cman_inst->cmq_handle, 0, &qinfo) != CS_OK) {
+ if (votequorum_getinfo(cman_inst->cmq_handle, 0, &qinfo) != CS_OK) {
return -1;
}
diff --git a/cman/services/cman/lib/libcman.h b/cman/services/cman/lib/libcman.h
index f746629..5f50f2a 100644
--- a/cman/services/cman/lib/libcman.h
+++ b/cman/services/cman/lib/libcman.h
@@ -142,7 +142,7 @@ typedef struct cman_cluster
/* Flags in ei_flags
NOTE: These have changed from Cluster2/3! */
-#define CMAN_EXTRA_FLAG_DIRTY 1
+#define CMAN_EXTRA_FLAG_HASSTATE 1
#define CMAN_EXTRA_FLAG_DISALLOWED 2
#define CMAN_EXTRA_FLAG_2NODE 4
#define CMAN_EXTRA_FLAG_QUORATE 8
diff --git a/cman/services/quorum/Makefile b/cman/services/quorum/Makefile
deleted file mode 100644
index d65439f..0000000
--- a/cman/services/quorum/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-include ../../../make/defines.mk
-include $(OBJDIR)/make/passthrough.mk
-
-SUBDIRS=services lib test
diff --git a/cman/services/quorum/include/corosync/cmanquorum.h b/cman/services/quorum/include/corosync/cmanquorum.h
deleted file mode 100644
index 3881106..0000000
--- a/cman/services/quorum/include/corosync/cmanquorum.h
+++ /dev/null
@@ -1,172 +0,0 @@
-#ifndef COROSYNC_CMANQUORUM_H_DEFINED
-#define COROSYNC_CMANQUORUM_H_DEFINED
-
-typedef uint64_t cmanquorum_handle_t;
-
-
-#define CMANQUORUM_MAX_QDISK_NAME_LEN 255
-
-#define CMANQUORUM_INFO_FLAG_DIRTY 1
-#define CMANQUORUM_INFO_FLAG_DISALLOWED 2
-#define CMANQUORUM_INFO_FLAG_TWONODE 4
-#define CMANQUORUM_INFO_FLAG_QUORATE 8
-
-#define NODESTATE_JOINING 1
-#define NODESTATE_MEMBER 2
-#define NODESTATE_DEAD 3
-#define NODESTATE_LEAVING 4
-#define NODESTATE_DISALLOWED 5
-
-
-/** @} */
-
-struct cmanquorum_info {
- unsigned int node_id;
- unsigned int node_votes;
- unsigned int node_expected_votes;
- unsigned int highest_expected;
- unsigned int total_votes;
- unsigned int quorum;
- unsigned int flags;
-};
-
-struct cmanquorum_qdisk_info {
- unsigned int votes;
- unsigned int state;
- char name[CMANQUORUM_MAX_QDISK_NAME_LEN];
-};
-
-typedef struct {
- uint32_t nodeid;
- uint32_t state;
-} cmanquorum_node_t;
-
-
-typedef void (*cmanquorum_notification_fn_t) (
- cmanquorum_handle_t handle,
- uint64_t context,
- uint32_t quorate,
- uint32_t node_list_entries,
- cmanquorum_node_t node_list[]
- );
-
-typedef struct {
- cmanquorum_notification_fn_t cmanquorum_notify_fn;
-} cmanquorum_callbacks_t;
-
-
-/*
- * Create a new quorum connection
- */
-cs_error_t cmanquorum_initialize (
- cmanquorum_handle_t *handle,
- cmanquorum_callbacks_t *callbacks);
-
-/*
- * Close the quorum handle
- */
-cs_error_t cmanquorum_finalize (
- cmanquorum_handle_t handle);
-
-
-/*
- * Dispatch messages and configuration changes
- */
-cs_error_t cmanquorum_dispatch (
- cmanquorum_handle_t handle,
- cs_dispatch_flags_t dispatch_types);
-
-
-/*
- * Get quorum information.
- */
-cs_error_t cmanquorum_getinfo (
- cmanquorum_handle_t handle,
- unsigned int nodeid,
- struct cmanquorum_info *info);
-
-/*
- * set expected_votes
- */
-cs_error_t cmanquorum_setexpected (
- cmanquorum_handle_t handle,
- unsigned int expected_votes);
-
-/*
- * set votes for a node
- */
-cs_error_t cmanquorum_setvotes (
- cmanquorum_handle_t handle,
- unsigned int nodeid,
- unsigned int votes);
-
-/*
- * Register a quorum device
- * it will be DEAD until polled
- */
-cs_error_t cmanquorum_qdisk_register (
- cmanquorum_handle_t handle,
- char *name,
- unsigned int votes);
-
-/*
- * Unregister a quorum device
- */
-cs_error_t cmanquorum_qdisk_unregister (
- cmanquorum_handle_t handle);
-
-/*
- * Poll a quorum device
- */
-cs_error_t cmanquorum_qdisk_poll (
- cmanquorum_handle_t handle,
- unsigned int state);
-
-/*
- * Get quorum device information
- */
-cs_error_t cmanquorum_qdisk_getinfo (
- cmanquorum_handle_t handle,
- struct cmanquorum_qdisk_info *info);
-
-/*
- * Set the dirty bit for this node
- */
-cs_error_t cmanquorum_setdirty (
- cmanquorum_handle_t handle);
-
-/*
- * Force a node to exit
- */
-cs_error_t cmanquorum_killnode (
- cmanquorum_handle_t handle,
- unsigned int nodeid,
- unsigned int reason);
-
-/* Track node and quorum changes */
-cs_error_t cmanquorum_trackstart (
- cmanquorum_handle_t handle,
- uint64_t context,
- unsigned int flags );
-
-cs_error_t cmanquorum_trackstop (
- cmanquorum_handle_t handle);
-
-/*
- * Set our LEAVING flag. we should exit soon after this
- */
-cs_error_t cmanquorum_leaving (
- cmanquorum_handle_t handle);
-
-/*
- * Save and retrieve private data/context
- */
-cs_error_t cmanquorum_context_get (
- cmanquorum_handle_t handle,
- void **context);
-
-cs_error_t cmanquorum_context_set (
- cmanquorum_handle_t handle,
- void *context);
-
-#endif /* COROSYNC_CMANQUORUM_H_DEFINED */
diff --git a/cman/services/quorum/include/corosync/ipc_cmanquorum.h b/cman/services/quorum/include/corosync/ipc_cmanquorum.h
deleted file mode 100644
index 5b04f60..0000000
--- a/cman/services/quorum/include/corosync/ipc_cmanquorum.h
+++ /dev/null
@@ -1,123 +0,0 @@
-#ifndef IPC_CMANQUORUM_H_DEFINED
-#define IPC_CMANQUORUM_H_DEFINED
-
-#include "corosync/corotypes.h"
-#include "corosync/ipc_gen.h"
-
-// ILLEGAL value!!
-#define CMANQUORUM_SERVICE 15
-
-#define CMANQUORUM_MAX_QDISK_NAME_LEN 255
-
-
-enum req_cmanquorum_types {
- MESSAGE_REQ_CMANQUORUM_GETINFO = 0,
- MESSAGE_REQ_CMANQUORUM_SETEXPECTED,
- MESSAGE_REQ_CMANQUORUM_SETVOTES,
- MESSAGE_REQ_CMANQUORUM_QDISK_REGISTER,
- MESSAGE_REQ_CMANQUORUM_QDISK_UNREGISTER,
- MESSAGE_REQ_CMANQUORUM_QDISK_POLL,
- MESSAGE_REQ_CMANQUORUM_QDISK_GETINFO,
- MESSAGE_REQ_CMANQUORUM_SETDIRTY,
- MESSAGE_REQ_CMANQUORUM_KILLNODE,
- MESSAGE_REQ_CMANQUORUM_LEAVING,
- MESSAGE_REQ_CMANQUORUM_TRACKSTART,
- MESSAGE_REQ_CMANQUORUM_TRACKSTOP
-};
-
-enum res_cmanquorum_types {
- MESSAGE_RES_CMANQUORUM_STATUS = 0,
- MESSAGE_RES_CMANQUORUM_GETINFO,
- MESSAGE_RES_CMANQUORUM_QDISK_GETINFO,
- MESSAGE_RES_CMANQUORUM_TRACKSTART,
- MESSAGE_RES_CMANQUORUM_NOTIFICATION
-};
-
-struct req_lib_cmanquorum_setvotes {
- mar_req_header_t header __attribute__((aligned(8)));
- unsigned int votes;
- int nodeid;
-};
-
-struct req_lib_cmanquorum_qdisk_register {
- mar_req_header_t header __attribute__((aligned(8)));
- unsigned int votes;
- char name[CMANQUORUM_MAX_QDISK_NAME_LEN];
-};
-
-struct req_lib_cmanquorum_qdisk_poll {
- mar_req_header_t header __attribute__((aligned(8)));
- int state;
-};
-
-struct req_lib_cmanquorum_setexpected {
- mar_req_header_t header __attribute__((aligned(8)));
- unsigned int expected_votes;
-};
-
-struct req_lib_cmanquorum_trackstart {
- mar_req_header_t header __attribute__((aligned(8)));
- uint64_t context;
- unsigned int track_flags;
-};
-
-struct req_lib_cmanquorum_general {
- mar_req_header_t header __attribute__((aligned(8)));
-};
-
-#define CMANQUORUM_REASON_KILL_REJECTED 1
-#define CMANQUORUM_REASON_KILL_APPLICATION 2
-#define CMANQUORUM_REASON_KILL_REJOIN 3
-
-struct req_lib_cmanquorum_killnode {
- mar_req_header_t header __attribute__((aligned(8)));
- int nodeid;
- unsigned int reason;
-};
-
-struct req_lib_cmanquorum_getinfo {
- mar_req_header_t header __attribute__((aligned(8)));
- int nodeid;
-};
-
-struct res_lib_cmanquorum_status {
- mar_res_header_t header __attribute__((aligned(8)));
-};
-
-#define CMANQUORUM_INFO_FLAG_DIRTY 1
-#define CMANQUORUM_INFO_FLAG_DISALLOWED 2
-#define CMANQUORUM_INFO_FLAG_TWONODE 4
-#define CMANQUORUM_INFO_FLAG_QUORATE 8
-
-struct res_lib_cmanquorum_getinfo {
- mar_res_header_t header __attribute__((aligned(8)));
- int nodeid;
- unsigned int votes;
- unsigned int expected_votes;
- unsigned int highest_expected;
- unsigned int total_votes;
- unsigned int quorum;
- unsigned int flags;
-};
-
-struct res_lib_cmanquorum_qdisk_getinfo {
- mar_res_header_t header __attribute__((aligned(8)));
- unsigned int votes;
- unsigned int state;
- char name[CMANQUORUM_MAX_QDISK_NAME_LEN];
-};
-
-struct cmanquorum_node {
- mar_uint32_t nodeid;
- mar_uint32_t state;
-};
-
-struct res_lib_cmanquorum_notification {
- mar_res_header_t header __attribute__((aligned(8)));
- mar_uint32_t quorate __attribute__((aligned(8)));
- mar_uint64_t context __attribute__((aligned(8)));
- mar_uint32_t node_list_entries __attribute__((aligned(8)));
- struct cmanquorum_node node_list[] __attribute__((aligned(8)));
-};
-
-#endif
diff --git a/cman/services/quorum/lib/Makefile b/cman/services/quorum/lib/Makefile
deleted file mode 100644
index 8656b4a..0000000
--- a/cman/services/quorum/lib/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET= libcmanquorum
-
-COROSYNCINCDIRT=../include/corosync/cmanquorum.h
-
-include ../../../../make/defines.mk
-include $(OBJDIR)/make/libs.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -fPIC
-CFLAGS += -I${incdir}
-CFLAGS += -I../include
diff --git a/cman/services/quorum/lib/libcmanquorum.c b/cman/services/quorum/lib/libcmanquorum.c
deleted file mode 100644
index b488367..0000000
--- a/cman/services/quorum/lib/libcmanquorum.c
+++ /dev/null
@@ -1,830 +0,0 @@
-/*
- * Provides a quorum API using the corosync executive
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <errno.h>
-
-#include <corosync/mar_gen.h>
-#include <corosync/ipc_gen.h>
-#include <corosync/ais_util.h>
-#include "corosync/cmanquorum.h"
-#include "corosync/ipc_cmanquorum.h"
-
-struct cmanquorum_inst {
- int response_fd;
- int dispatch_fd;
- int finalize;
- void *context;
- cmanquorum_callbacks_t callbacks;
- pthread_mutex_t response_mutex;
- pthread_mutex_t dispatch_mutex;
-};
-
-static void cmanquorum_instance_destructor (void *instance);
-
-static struct saHandleDatabase cmanquorum_handle_t_db = {
- .handleCount = 0,
- .handles = 0,
- .mutex = PTHREAD_MUTEX_INITIALIZER,
- .handleInstanceDestructor = cmanquorum_instance_destructor
-};
-
-/*
- * Clean up function for a quorum instance (cmanquorum_initialize) handle
- */
-static void cmanquorum_instance_destructor (void *instance)
-{
- struct cmanquorum_inst *cmanquorum_inst = instance;
-
- pthread_mutex_destroy (&cmanquorum_inst->response_mutex);
-}
-
-cs_error_t cmanquorum_initialize (
- cmanquorum_handle_t *handle,
- cmanquorum_callbacks_t *callbacks)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
-
- error = saHandleCreate (&cmanquorum_handle_t_db, sizeof (struct cmanquorum_inst), handle);
- if (error != CS_OK) {
- goto error_no_destroy;
- }
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, *handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- goto error_destroy;
- }
-
- error = saServiceConnect (&cmanquorum_inst->dispatch_fd,
- &cmanquorum_inst->response_fd,
- CMANQUORUM_SERVICE);
- if (error != CS_OK) {
- goto error_put_destroy;
- }
-
- pthread_mutex_init (&cmanquorum_inst->response_mutex, NULL);
- pthread_mutex_init (&cmanquorum_inst->dispatch_mutex, NULL);
- if (callbacks)
- memcpy(&cmanquorum_inst->callbacks, callbacks, sizeof (callbacks));
- else
- memset(&cmanquorum_inst->callbacks, 0, sizeof (callbacks));
-
- saHandleInstancePut (&cmanquorum_handle_t_db, *handle);
-
- return (CS_OK);
-
-error_put_destroy:
- saHandleInstancePut (&cmanquorum_handle_t_db, *handle);
-error_destroy:
- saHandleDestroy (&cmanquorum_handle_t_db, *handle);
-error_no_destroy:
- return (error);
-}
-
-cs_error_t cmanquorum_finalize (
- cmanquorum_handle_t handle)
-{
- struct cmanquorum_inst *cmanquorum_inst;
- cs_error_t error;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- /*
- * Another thread has already started finalizing
- */
- if (cmanquorum_inst->finalize) {
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
- return (CS_ERR_BAD_HANDLE);
- }
-
- cmanquorum_inst->finalize = 1;
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- saHandleDestroy (&cmanquorum_handle_t_db, handle);
-
- /*
- * Disconnect from the server
- */
- if (cmanquorum_inst->response_fd != -1) {
- shutdown(cmanquorum_inst->response_fd, 0);
- close(cmanquorum_inst->response_fd);
- }
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (CS_OK);
-}
-
-
-cs_error_t cmanquorum_getinfo (
- cmanquorum_handle_t handle,
- unsigned int nodeid,
- struct cmanquorum_info *info)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
- struct iovec iov[2];
- struct req_lib_cmanquorum_getinfo req_lib_cmanquorum_getinfo;
- struct res_lib_cmanquorum_getinfo res_lib_cmanquorum_getinfo;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- req_lib_cmanquorum_getinfo.header.size = sizeof (struct req_lib_cmanquorum_getinfo);
- req_lib_cmanquorum_getinfo.header.id = MESSAGE_REQ_CMANQUORUM_GETINFO;
- req_lib_cmanquorum_getinfo.nodeid = nodeid;
-
- iov[0].iov_base = (char *)&req_lib_cmanquorum_getinfo;
- iov[0].iov_len = sizeof (struct req_lib_cmanquorum_getinfo);
-
- error = saSendMsgReceiveReply (cmanquorum_inst->response_fd, iov, 1,
- &res_lib_cmanquorum_getinfo, sizeof (struct res_lib_cmanquorum_getinfo));
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_cmanquorum_getinfo.header.error;
-
- info->node_id = res_lib_cmanquorum_getinfo.nodeid;
- info->node_votes = res_lib_cmanquorum_getinfo.votes;
- info->node_expected_votes = res_lib_cmanquorum_getinfo.expected_votes;
- info->highest_expected = res_lib_cmanquorum_getinfo.highest_expected;
- info->total_votes = res_lib_cmanquorum_getinfo.total_votes;
- info->quorum = res_lib_cmanquorum_getinfo.quorum;
- info->flags = res_lib_cmanquorum_getinfo.flags;
-
-error_exit:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (error);
-}
-
-cs_error_t cmanquorum_setexpected (
- cmanquorum_handle_t handle,
- unsigned int expected_votes)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
- struct iovec iov[2];
- struct req_lib_cmanquorum_setexpected req_lib_cmanquorum_setexpected;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- req_lib_cmanquorum_setexpected.header.size = sizeof (struct req_lib_cmanquorum_setexpected);
- req_lib_cmanquorum_setexpected.header.id = MESSAGE_REQ_CMANQUORUM_SETEXPECTED;
- req_lib_cmanquorum_setexpected.expected_votes = expected_votes;
-
- iov[0].iov_base = (char *)&req_lib_cmanquorum_setexpected;
- iov[0].iov_len = sizeof (struct req_lib_cmanquorum_setexpected);
-
- error = saSendMsgReceiveReply (cmanquorum_inst->response_fd, iov, 1,
- &res_lib_cmanquorum_status, sizeof (struct res_lib_cmanquorum_status));
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_cmanquorum_status.header.error;
-
-error_exit:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (error);
-}
-
-cs_error_t cmanquorum_setvotes (
- cmanquorum_handle_t handle,
- unsigned int nodeid,
- unsigned int votes)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
- struct iovec iov[2];
- struct req_lib_cmanquorum_setvotes req_lib_cmanquorum_setvotes;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- req_lib_cmanquorum_setvotes.header.size = sizeof (struct req_lib_cmanquorum_setvotes);
- req_lib_cmanquorum_setvotes.header.id = MESSAGE_REQ_CMANQUORUM_SETVOTES;
- req_lib_cmanquorum_setvotes.nodeid = nodeid;
- req_lib_cmanquorum_setvotes.votes = votes;
-
- iov[0].iov_base = (char *)&req_lib_cmanquorum_setvotes;
- iov[0].iov_len = sizeof (struct req_lib_cmanquorum_setvotes);
-
- error = saSendMsgReceiveReply (cmanquorum_inst->response_fd, iov, 1,
- &res_lib_cmanquorum_status, sizeof (struct res_lib_cmanquorum_status));
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_cmanquorum_status.header.error;
-
-error_exit:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (error);
-}
-
-cs_error_t cmanquorum_qdisk_register (
- cmanquorum_handle_t handle,
- char *name,
- unsigned int votes)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
- struct iovec iov[2];
- struct req_lib_cmanquorum_qdisk_register req_lib_cmanquorum_qdisk_register;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
-
- if (strlen(name) > CMANQUORUM_MAX_QDISK_NAME_LEN)
- return CS_ERR_INVALID_PARAM;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- req_lib_cmanquorum_qdisk_register.header.size = sizeof (struct req_lib_cmanquorum_qdisk_register);
- req_lib_cmanquorum_qdisk_register.header.id = MESSAGE_REQ_CMANQUORUM_QDISK_REGISTER;
- strcpy(req_lib_cmanquorum_qdisk_register.name, name);
- req_lib_cmanquorum_qdisk_register.votes = votes;
-
- iov[0].iov_base = (char *)&req_lib_cmanquorum_qdisk_register;
- iov[0].iov_len = sizeof (struct req_lib_cmanquorum_qdisk_register);
-
- error = saSendMsgReceiveReply (cmanquorum_inst->response_fd, iov, 1,
- &res_lib_cmanquorum_status, sizeof (struct res_lib_cmanquorum_status));
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_cmanquorum_status.header.error;
-
-error_exit:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (error);
-}
-
-cs_error_t cmanquorum_qdisk_poll (
- cmanquorum_handle_t handle,
- unsigned int state)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
- struct iovec iov[2];
- struct req_lib_cmanquorum_qdisk_poll req_lib_cmanquorum_qdisk_poll;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- req_lib_cmanquorum_qdisk_poll.header.size = sizeof (struct req_lib_cmanquorum_qdisk_poll);
- req_lib_cmanquorum_qdisk_poll.header.id = MESSAGE_REQ_CMANQUORUM_QDISK_POLL;
- req_lib_cmanquorum_qdisk_poll.state = state;
-
- iov[0].iov_base = (char *)&req_lib_cmanquorum_qdisk_poll;
- iov[0].iov_len = sizeof (struct req_lib_cmanquorum_qdisk_poll);
-
- error = saSendMsgReceiveReply (cmanquorum_inst->response_fd, iov, 1,
- &res_lib_cmanquorum_status, sizeof (struct res_lib_cmanquorum_status));
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_cmanquorum_status.header.error;
-
-error_exit:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (error);
-}
-
-cs_error_t cmanquorum_qdisk_unregister (
- cmanquorum_handle_t handle)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
- struct iovec iov[2];
- struct req_lib_cmanquorum_general req_lib_cmanquorum_general;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- req_lib_cmanquorum_general.header.size = sizeof (struct req_lib_cmanquorum_general);
- req_lib_cmanquorum_general.header.id = MESSAGE_REQ_CMANQUORUM_QDISK_UNREGISTER;
-
- iov[0].iov_base = (char *)&req_lib_cmanquorum_general;
- iov[0].iov_len = sizeof (struct req_lib_cmanquorum_general);
-
- error = saSendMsgReceiveReply (cmanquorum_inst->response_fd, iov, 1,
- &res_lib_cmanquorum_status, sizeof (struct res_lib_cmanquorum_status));
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_cmanquorum_status.header.error;
-
-error_exit:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (error);
-}
-
-
-
-cs_error_t cmanquorum_qdisk_getinfo (
- cmanquorum_handle_t handle,
- struct cmanquorum_qdisk_info *qinfo)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
- struct iovec iov[2];
- struct req_lib_cmanquorum_general req_lib_cmanquorum_general;
- struct res_lib_cmanquorum_qdisk_getinfo res_lib_cmanquorum_qdisk_getinfo;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- req_lib_cmanquorum_general.header.size = sizeof (struct req_lib_cmanquorum_general);
- req_lib_cmanquorum_general.header.id = MESSAGE_REQ_CMANQUORUM_QDISK_GETINFO;
-
- iov[0].iov_base = (char *)&req_lib_cmanquorum_general;
- iov[0].iov_len = sizeof (struct req_lib_cmanquorum_general);
-
- error = saSendMsgReceiveReply (cmanquorum_inst->response_fd, iov, 1,
- &res_lib_cmanquorum_qdisk_getinfo, sizeof (struct res_lib_cmanquorum_qdisk_getinfo));
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_cmanquorum_qdisk_getinfo.header.error;
-
- qinfo->votes = res_lib_cmanquorum_qdisk_getinfo.votes;
- qinfo->state = res_lib_cmanquorum_qdisk_getinfo.state;
- strcpy(qinfo->name, res_lib_cmanquorum_qdisk_getinfo.name);
-
-
-error_exit:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (error);
-}
-
-cs_error_t cmanquorum_setdirty (
- cmanquorum_handle_t handle)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
- struct iovec iov[2];
- struct req_lib_cmanquorum_general req_lib_cmanquorum_general;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- req_lib_cmanquorum_general.header.size = sizeof (struct req_lib_cmanquorum_general);
- req_lib_cmanquorum_general.header.id = MESSAGE_REQ_CMANQUORUM_SETDIRTY;
-
- iov[0].iov_base = (char *)&req_lib_cmanquorum_general;
- iov[0].iov_len = sizeof (struct req_lib_cmanquorum_general);
-
- error = saSendMsgReceiveReply (cmanquorum_inst->response_fd, iov, 1,
- &res_lib_cmanquorum_status, sizeof (struct res_lib_cmanquorum_status));
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_cmanquorum_status.header.error;
-
-error_exit:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (error);
-}
-
-cs_error_t cmanquorum_leaving (
- cmanquorum_handle_t handle)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
- struct iovec iov[2];
- struct req_lib_cmanquorum_general req_lib_cmanquorum_general;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- req_lib_cmanquorum_general.header.size = sizeof (struct req_lib_cmanquorum_general);
- req_lib_cmanquorum_general.header.id = MESSAGE_REQ_CMANQUORUM_LEAVING;
-
- iov[0].iov_base = (char *)&req_lib_cmanquorum_general;
- iov[0].iov_len = sizeof (struct req_lib_cmanquorum_general);
-
- error = saSendMsgReceiveReply (cmanquorum_inst->response_fd, iov, 1,
- &res_lib_cmanquorum_status, sizeof (struct res_lib_cmanquorum_status));
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_cmanquorum_status.header.error;
-
-error_exit:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (error);
-}
-
-cs_error_t cmanquorum_killnode (
- cmanquorum_handle_t handle,
- unsigned int nodeid,
- unsigned int reason)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
- struct iovec iov[2];
- struct req_lib_cmanquorum_killnode req_lib_cmanquorum_killnode;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- req_lib_cmanquorum_killnode.header.size = sizeof (struct req_lib_cmanquorum_killnode);
- req_lib_cmanquorum_killnode.header.id = MESSAGE_REQ_CMANQUORUM_KILLNODE;
- req_lib_cmanquorum_killnode.nodeid = nodeid;
- req_lib_cmanquorum_killnode.reason = reason;
-
- iov[0].iov_base = (char *)&req_lib_cmanquorum_killnode;
- iov[0].iov_len = sizeof (struct req_lib_cmanquorum_killnode);
-
- error = saSendMsgReceiveReply (cmanquorum_inst->response_fd, iov, 1,
- &res_lib_cmanquorum_status, sizeof (struct res_lib_cmanquorum_status));
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_cmanquorum_status.header.error;
-
-error_exit:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (error);
-}
-
-cs_error_t cmanquorum_trackstart (
- cmanquorum_handle_t handle,
- uint64_t context,
- unsigned int flags )
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
- struct iovec iov[2];
- struct req_lib_cmanquorum_trackstart req_lib_cmanquorum_trackstart;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- req_lib_cmanquorum_trackstart.header.size = sizeof (struct req_lib_cmanquorum_trackstart);
- req_lib_cmanquorum_trackstart.header.id = MESSAGE_REQ_CMANQUORUM_TRACKSTART;
- req_lib_cmanquorum_trackstart.track_flags = flags;
- req_lib_cmanquorum_trackstart.context = context;
-
- iov[0].iov_base = (char *)&req_lib_cmanquorum_trackstart;
- iov[0].iov_len = sizeof (struct req_lib_cmanquorum_trackstart);
-
- error = saSendMsgReceiveReply (cmanquorum_inst->response_fd, iov, 1,
- &res_lib_cmanquorum_status, sizeof (struct res_lib_cmanquorum_status));
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_cmanquorum_status.header.error;
-
-error_exit:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (error);
-}
-
-cs_error_t cmanquorum_trackstop (
- cmanquorum_handle_t handle)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
- struct iovec iov[2];
- struct req_lib_cmanquorum_general req_lib_cmanquorum_general;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- pthread_mutex_lock (&cmanquorum_inst->response_mutex);
-
- req_lib_cmanquorum_general.header.size = sizeof (struct req_lib_cmanquorum_general);
- req_lib_cmanquorum_general.header.id = MESSAGE_REQ_CMANQUORUM_TRACKSTOP;
-
- iov[0].iov_base = (char *)&req_lib_cmanquorum_general;
- iov[0].iov_len = sizeof (struct req_lib_cmanquorum_general);
-
- error = saSendMsgReceiveReply (cmanquorum_inst->response_fd, iov, 1,
- &res_lib_cmanquorum_status, sizeof (struct res_lib_cmanquorum_status));
-
- pthread_mutex_unlock (&cmanquorum_inst->response_mutex);
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_cmanquorum_status.header.error;
-
-error_exit:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (error);
-}
-
-
-cs_error_t cmanquorum_context_get (
- cmanquorum_handle_t handle,
- void **context)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- *context = cmanquorum_inst->context;
-
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (CS_OK);
-}
-
-cs_error_t cmanquorum_context_set (
- cmanquorum_handle_t handle,
- void *context)
-{
- cs_error_t error;
- struct cmanquorum_inst *cmanquorum_inst;
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle, (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- cmanquorum_inst->context = context;
-
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
-
- return (CS_OK);
-}
-
-
-struct res_overlay {
- mar_res_header_t header __attribute__((aligned(8)));
- char data[512000];
-};
-
-cs_error_t cmanquorum_dispatch (
- cmanquorum_handle_t handle,
- cs_dispatch_flags_t dispatch_types)
-{
- struct pollfd ufds;
- int timeout = -1;
- cs_error_t error;
- int cont = 1; /* always continue do loop except when set to 0 */
- int dispatch_avail;
- struct cmanquorum_inst *cmanquorum_inst;
- cmanquorum_callbacks_t callbacks;
- struct res_overlay dispatch_data;
- struct res_lib_cmanquorum_notification *res_lib_cmanquorum_notification;
-
- if (dispatch_types != CS_DISPATCH_ONE &&
- dispatch_types != CS_DISPATCH_ALL &&
- dispatch_types != CS_DISPATCH_BLOCKING) {
-
- return (CS_ERR_INVALID_PARAM);
- }
-
- error = saHandleInstanceGet (&cmanquorum_handle_t_db, handle,
- (void *)&cmanquorum_inst);
- if (error != CS_OK) {
- return (error);
- }
-
- /*
- * Timeout instantly for CS_DISPATCH_ONE or CS_DISPATCH_ALL and
- * wait indefinately for CS_DISPATCH_BLOCKING
- */
- if (dispatch_types == CS_DISPATCH_ALL) {
- timeout = 0;
- }
-
- do {
- ufds.fd = cmanquorum_inst->dispatch_fd;
- ufds.events = POLLIN;
- ufds.revents = 0;
-
- pthread_mutex_lock (&cmanquorum_inst->dispatch_mutex);
-
- error = saPollRetry (&ufds, 1, timeout);
- if (error != CS_OK) {
- goto error_unlock;
- }
-
- /*
- * Handle has been finalized in another thread
- */
- if (cmanquorum_inst->finalize == 1) {
- error = CS_OK;
- goto error_unlock;
- }
-
- if ((ufds.revents & (POLLERR|POLLHUP|POLLNVAL)) != 0) {
- error = CS_ERR_BAD_HANDLE;
- goto error_unlock;
- }
-
- dispatch_avail = ufds.revents & POLLIN;
- if (dispatch_avail == 0 && dispatch_types == CS_DISPATCH_ALL) {
- pthread_mutex_unlock (&cmanquorum_inst->dispatch_mutex);
- break; /* exit do while cont is 1 loop */
- } else
- if (dispatch_avail == 0) {
- pthread_mutex_unlock (&cmanquorum_inst->dispatch_mutex);
- continue; /* next poll */
- }
-
- if (ufds.revents & POLLIN) {
- error = saRecvRetry (cmanquorum_inst->dispatch_fd, &dispatch_data.header,
- sizeof (mar_res_header_t));
- if (error != CS_OK) {
- goto error_unlock;
- }
- if (dispatch_data.header.size > sizeof (mar_res_header_t)) {
- error = saRecvRetry (cmanquorum_inst->dispatch_fd, &dispatch_data.data,
- dispatch_data.header.size - sizeof (mar_res_header_t));
- if (error != CS_OK) {
- goto error_unlock;
- }
- }
- } else {
- pthread_mutex_unlock (&cmanquorum_inst->dispatch_mutex);
- continue;
- }
-
- /*
- * Make copy of callbacks, message data, unlock instance, and call callback
- * A risk of this dispatch method is that the callback routines may
- * operate at the same time that cmanquorum_finalize has been called in another thread.
- */
- memcpy (&callbacks, &cmanquorum_inst->callbacks, sizeof (cmanquorum_callbacks_t));
- pthread_mutex_unlock (&cmanquorum_inst->dispatch_mutex);
-
- /*
- * Dispatch incoming message
- */
- switch (dispatch_data.header.id) {
-
- case MESSAGE_RES_CMANQUORUM_NOTIFICATION:
- if (callbacks.cmanquorum_notify_fn == NULL) {
- continue;
- }
- res_lib_cmanquorum_notification = (struct res_lib_cmanquorum_notification *)&dispatch_data;
-
- callbacks.cmanquorum_notify_fn ( handle,
- res_lib_cmanquorum_notification->context,
- res_lib_cmanquorum_notification->quorate,
- res_lib_cmanquorum_notification->node_list_entries,
- (cmanquorum_node_t *)res_lib_cmanquorum_notification->node_list );
- ;
- break;
-
- default:
- error = CS_ERR_LIBRARY;
- goto error_put;
- break;
- }
-
- /*
- * Determine if more messages should be processed
- * */
- switch (dispatch_types) {
- case CS_DISPATCH_ONE:
- cont = 0;
- break;
- case CS_DISPATCH_ALL:
- break;
- case CS_DISPATCH_BLOCKING:
- break;
- }
- } while (cont);
-
- goto error_put;
-
-error_unlock:
- pthread_mutex_unlock (&cmanquorum_inst->dispatch_mutex);
-
-error_put:
- saHandleInstancePut (&cmanquorum_handle_t_db, handle);
- return (error);
-}
diff --git a/cman/services/quorum/services/Makefile b/cman/services/quorum/services/Makefile
deleted file mode 100644
index 92e5445..0000000
--- a/cman/services/quorum/services/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-TARGET= service_cmanquorum.lcrso
-
-LCRSOT=$(TARGET)
-
-all: ${TARGET}
-
-include ../../../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -fPIC
-CFLAGS += -I${openaisincdir} -I${corosyncincdir}
-CFLAGS += -I${incdir}
-CFLAGS += -I ../include
-
-LDFLAGS += -L${libdir}
-
-${TARGET}: cmanquorum.o
- $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
-
-clean: generalclean
-
--include $(OBJS1:.o=.d)
--include $(OBJS2:.o=.d)
diff --git a/cman/services/quorum/services/cmanquorum.c b/cman/services/quorum/services/cmanquorum.c
deleted file mode 100644
index 3a368c9..0000000
--- a/cman/services/quorum/services/cmanquorum.c
+++ /dev/null
@@ -1,1657 +0,0 @@
-#include <sys/types.h>
-#ifndef COROSYNC_BSD
-#include <alloca.h>
-#endif
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <sys/uio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <signal.h>
-#include <time.h>
-#include <unistd.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <corosync/corotypes.h>
-#include <corosync/cfg.h>
-#include <corosync/list.h>
-#include <corosync/lcr/lcr_comp.h>
-#include <corosync/engine/logsys.h>
-#include <corosync/ipc_gen.h>
-#include <corosync/engine/coroapi.h>
-#include <corosync/engine/quorum.h>
-#include <corosync/ipc_cmanquorum.h>
-#include <corosync/list.h>
-
-#define CMANQUORUM_MAJOR_VERSION 6
-#define CMANQUORUM_MINOR_VERSION 3
-#define CMANQUORUM_PATCH_VERSION 0
-
- /* Silly default to prevent accidents! */
-#define DEFAULT_EXPECTED 1024
-#define DEFAULT_QDEV_POLL 10000
-
-LOGSYS_DECLARE_SUBSYS ("CMANQ", LOG_INFO);
-
-enum quorum_message_req_types {
- MESSAGE_REQ_EXEC_CMANQUORUM_NODEINFO = 0,
- MESSAGE_REQ_EXEC_CMANQUORUM_RECONFIGURE = 1,
- MESSAGE_REQ_EXEC_CMANQUORUM_KILLNODE = 2,
-};
-
-#define NODE_FLAGS_BEENDOWN 1
-#define NODE_FLAGS_SEESDISALLOWED 8
-#define NODE_FLAGS_DIRTY 16
-#define NODE_FLAGS_QDISK 32
-#define NODE_FLAGS_REMOVED 64
-#define NODE_FLAGS_US 128
-
-
-typedef enum { NODESTATE_JOINING=1, NODESTATE_MEMBER,
- NODESTATE_DEAD, NODESTATE_LEAVING, NODESTATE_DISALLOWED } nodestate_t;
-
-
-/* This structure is tacked onto the start of a cluster message packet for our
- * own nefarious purposes. */
-struct q_protheader {
- unsigned char tgtport; /* Target port number */
- unsigned char srcport; /* Source (originating) port number */
- unsigned short pad;
- unsigned int flags;
- int srcid; /* Node ID of the sender */
- int tgtid; /* Node ID of the target */
-} __attribute__((packed));
-
-struct cluster_node {
- int flags;
- int node_id;
- unsigned int expected_votes;
- unsigned int votes;
- time_t join_time;
-
- nodestate_t state;
-
- struct timeval last_hello; /* Only used for quorum devices */
-
- struct list_head list;
-};
-
-static int quorum_flags;
-#define CMANQUORUM_FLAG_FEATURE_DISALLOWED 1
-#define CMANQUORUM_FLAG_FEATURE_TWONODE 1
-
-static int quorum;
-static int cluster_is_quorate;
-static int first_trans = 1;
-static unsigned int quorumdev_poll = DEFAULT_QDEV_POLL;
-
-static struct cluster_node *us;
-static struct cluster_node *quorum_device = NULL;
-static char quorum_device_name[CMANQUORUM_MAX_QDISK_NAME_LEN];
-static corosync_timer_handle_t quorum_device_timer;
-static struct list_head cluster_members_list;
-static struct corosync_api_v1 *corosync_api;
-static struct list_head trackers_list;
-static unsigned int cman_members[PROCESSOR_COUNT_MAX+1];
-static int cman_members_entries = 0;
-static struct memb_ring_id cman_ringid;
-static cs_tpg_handle group_handle;
-
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-static struct cluster_node *find_node_by_nodeid(int nodeid);
-static struct cluster_node *allocate_node(int nodeid);
-static char *kill_reason(int reason);
-
-#define CMAN_COMPATIBILITY
-#ifdef CMAN_COMPATIBILITY
-static struct corosync_tpg_group quorum_group[1] = {
- { .group = "CMAN", .group_len = 4},
-};
-static char clustername[16];
-static uint32_t cluster_id;
-static uint32_t config_version;
-#else
-static struct corosync_tpg_group quorum_group[1] = {
- { .group = "CMANQ", .group_len = 5},
-};
-#endif
-
-#define list_iterate(v, head) \
- for (v = (head)->next; v != head; v = v->next)
-
-struct quorum_pd {
- unsigned char track_flags;
- int tracking_enabled;
- uint64_t tracking_context;
- struct list_head list;
- void *conn;
-};
-
-/*
- * Service Interfaces required by service_message_handler struct
- */
-
-static void cmanquorum_init(struct corosync_api_v1 *api,
- quorum_set_quorate_fn_t report);
-
-static void quorum_confchg_fn (
- enum totem_configuration_type configuration_type,
- unsigned int *member_list, int member_list_entries,
- unsigned int *left_list, int left_list_entries,
- unsigned int *joined_list, int joined_list_entries,
- struct memb_ring_id *ring_id);
-
-static void quorum_deliver_fn(unsigned int nodeid, struct iovec *iovec, int iov_len,
- int endian_conversion_required);
-
-static int cmanquorum_exec_init_fn (struct corosync_api_v1 *corosync_api);
-
-static int quorum_lib_init_fn (void *conn);
-
-static int quorum_lib_exit_fn (void *conn);
-
-static void message_handler_req_exec_quorum_nodeinfo (
- void *message,
- unsigned int nodeid);
-
-static void message_handler_req_exec_quorum_reconfigure (
- void *message,
- unsigned int nodeid);
-
-static void message_handler_req_exec_quorum_killnode (
- void *message,
- unsigned int nodeid);
-
-
-static void message_handler_req_lib_cmanquorum_getinfo (void *conn, void *message);
-
-static void message_handler_req_lib_cmanquorum_setexpected (void *conn, void *message);
-
-static void message_handler_req_lib_cmanquorum_setvotes (void *conn, void *message);
-
-static void message_handler_req_lib_cmanquorum_qdisk_register (void *conn, void *message);
-
-static void message_handler_req_lib_cmanquorum_qdisk_unregister (void *conn, void *message);
-
-static void message_handler_req_lib_cmanquorum_qdisk_poll (void *conn, void *message);
-
-static void message_handler_req_lib_cmanquorum_qdisk_getinfo (void *conn, void *message);
-
-static void message_handler_req_lib_cmanquorum_setdirty (void *conn, void *message);
-
-static void message_handler_req_lib_cmanquorum_killnode (void *conn, void *message);
-
-static void message_handler_req_lib_cmanquorum_leaving (void *conn, void *message);
-static void message_handler_req_lib_cmanquorum_trackstart (void *conn, void *msg);
-static void message_handler_req_lib_cmanquorum_trackstop (void *conn, void *msg);
-
-static int quorum_exec_send_nodeinfo(void);
-static int quorum_exec_send_reconfigure(int param, int nodeid, int value);
-static int quorum_exec_send_killnode(int nodeid, unsigned int reason);
-
-static void add_cmanquorum_config_notification(unsigned int quorum_object_handle);
-
-
-/*
- * Library Handler Definition
- */
-static struct corosync_lib_handler quorum_lib_service[] =
-{
- { /* 0 */
- .lib_handler_fn = message_handler_req_lib_cmanquorum_getinfo,
- .response_size = sizeof (struct res_lib_cmanquorum_getinfo),
- .response_id = MESSAGE_RES_CMANQUORUM_GETINFO,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 1 */
- .lib_handler_fn = message_handler_req_lib_cmanquorum_setexpected,
- .response_size = sizeof (struct res_lib_cmanquorum_status),
- .response_id = MESSAGE_RES_CMANQUORUM_STATUS,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 2 */
- .lib_handler_fn = message_handler_req_lib_cmanquorum_setvotes,
- .response_size = sizeof (struct res_lib_cmanquorum_status),
- .response_id = MESSAGE_RES_CMANQUORUM_STATUS,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 3 */
- .lib_handler_fn = message_handler_req_lib_cmanquorum_qdisk_register,
- .response_size = sizeof (struct res_lib_cmanquorum_status),
- .response_id = MESSAGE_RES_CMANQUORUM_STATUS,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 4 */
- .lib_handler_fn = message_handler_req_lib_cmanquorum_qdisk_unregister,
- .response_size = sizeof (struct res_lib_cmanquorum_status),
- .response_id = MESSAGE_RES_CMANQUORUM_STATUS,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 5 */
- .lib_handler_fn = message_handler_req_lib_cmanquorum_qdisk_poll,
- .response_size = sizeof (struct res_lib_cmanquorum_status),
- .response_id = MESSAGE_RES_CMANQUORUM_STATUS,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 6 */
- .lib_handler_fn = message_handler_req_lib_cmanquorum_qdisk_getinfo,
- .response_size = sizeof (struct res_lib_cmanquorum_qdisk_getinfo),
- .response_id = MESSAGE_RES_CMANQUORUM_QDISK_GETINFO,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 7 */
- .lib_handler_fn = message_handler_req_lib_cmanquorum_setdirty,
- .response_size = sizeof (struct res_lib_cmanquorum_status),
- .response_id = MESSAGE_RES_CMANQUORUM_STATUS,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 8 */
- .lib_handler_fn = message_handler_req_lib_cmanquorum_killnode,
- .response_size = sizeof (struct res_lib_cmanquorum_status),
- .response_id = MESSAGE_RES_CMANQUORUM_STATUS,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 9 */
- .lib_handler_fn = message_handler_req_lib_cmanquorum_leaving,
- .response_size = sizeof (struct res_lib_cmanquorum_status),
- .response_id = MESSAGE_RES_CMANQUORUM_STATUS,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 10 */
- .lib_handler_fn = message_handler_req_lib_cmanquorum_trackstart,
- .response_size = sizeof (struct res_lib_cmanquorum_status),
- .response_id = MESSAGE_RES_CMANQUORUM_STATUS,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 11 */
- .lib_handler_fn = message_handler_req_lib_cmanquorum_trackstop,
- .response_size = sizeof (struct res_lib_cmanquorum_status),
- .response_id = MESSAGE_RES_CMANQUORUM_STATUS,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- }
-};
-
-static quorum_set_quorate_fn_t set_quorum;
-/*
- * lcrso object definition
- */
-static struct quorum_services_api_ver1 cmanquorum_iface_ver0 = {
- .init = cmanquorum_init
-};
-
-static struct corosync_service_engine quorum_service_handler = {
- .name = "corosync cman quorum service v0.90",
- .id = CMANQUORUM_SERVICE,
- .private_data_size = sizeof (struct quorum_pd),
- .allow_inquorate = CS_LIB_ALLOW_INQUORATE,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_REQUIRED,
- .lib_init_fn = quorum_lib_init_fn,
- .lib_exit_fn = quorum_lib_exit_fn,
- .lib_engine = quorum_lib_service,
- .lib_engine_count = sizeof (quorum_lib_service) / sizeof (struct corosync_lib_handler),
- .exec_init_fn = cmanquorum_exec_init_fn,
- .exec_engine = NULL,
- .exec_engine_count = 0,
- .confchg_fn = NULL,
-};
-
-/*
- * Dynamic loader definition
- */
-static struct corosync_service_engine *quorum_get_service_handler_ver0 (void);
-
-static struct corosync_service_engine_iface_ver0 quorum_service_handler_iface = {
- .corosync_get_service_engine_ver0 = quorum_get_service_handler_ver0
-};
-
-static struct lcr_iface corosync_quorum_ver0[2] = {
- {
- .name = "corosync_cmanquorum",
- .version = 0,
- .versions_replace = 0,
- .versions_replace_count = 0,
- .dependencies = 0,
- .dependency_count = 0,
- .constructor = NULL,
- .destructor = NULL,
- .interfaces = (void **)(void *)&cmanquorum_iface_ver0
- },
- {
- .name = "corosync_cmanquorum_iface",
- .version = 0,
- .versions_replace = 0,
- .versions_replace_count = 0,
- .dependencies = 0,
- .dependency_count = 0,
- .constructor = NULL,
- .destructor = NULL,
- .interfaces = NULL
- }
-};
-
-static struct lcr_comp quorum_comp_ver0 = {
- .iface_count = 2,
- .ifaces = corosync_quorum_ver0
-};
-
-
-static struct corosync_service_engine *quorum_get_service_handler_ver0 (void)
-{
- return (&quorum_service_handler);
-}
-
-__attribute__ ((constructor)) static void quorum_comp_register (void) {
- lcr_interfaces_set (&corosync_quorum_ver0[0], &cmanquorum_iface_ver0);
- lcr_interfaces_set (&corosync_quorum_ver0[1], &quorum_service_handler_iface);
- lcr_component_register (&quorum_comp_ver0);
-}
-
-static void cmanquorum_init(struct corosync_api_v1 *api,
- quorum_set_quorate_fn_t report)
-{
- ENTER();
- set_quorum = report;
-
- /* Load the library-servicing part of this module */
- api->service_link_and_init(api, "corosync_cmanquorum_iface", 0);
-
- LEAVE();
-}
-
-/* Message types */
-#define CMANQUORUM_MSG_NODEINFO 5
-#define CMANQUORUM_MSG_KILLNODE 6
-#define CMANQUORUM_MSG_RECONFIGURE 8
-
-struct req_exec_quorum_nodeinfo {
- unsigned char cmd;
- unsigned char first_trans;
-#ifdef CMAN_COMPATIBILITY
- uint16_t cluster_id;
-#endif
- unsigned int votes;
- unsigned int expected_votes;
-
- unsigned int major_version; /* Not backwards compatible */
- unsigned int minor_version; /* Backwards compatible */
- unsigned int patch_version; /* Backwards/forwards compatible */
- unsigned int config_version;
- unsigned int flags;
-#ifdef CMAN_COMPATIBILITY
- uint64_t fence_time; /* not used */
- uint64_t join_time;
- char clustername[16]; /* not used */
- char fence_agent[]; /* not used */
-#endif
-} __attribute__((packed));
-
-/* Parameters for RECONFIG command */
-#define RECONFIG_PARAM_EXPECTED_VOTES 1
-#define RECONFIG_PARAM_NODE_VOTES 2
-#define RECONFIG_PARAM_LEAVING 3
-
-struct req_exec_quorum_reconfigure {
- unsigned char cmd;
- unsigned char param;
- unsigned short pad;
- int nodeid;
- unsigned int value;
-};
-
-struct req_exec_quorum_killnode {
- unsigned char cmd;
- unsigned char pad1;
- uint16_t reason;
- int nodeid;
-};
-
-/* These just make the access a little neater */
-static inline int objdb_get_string(struct corosync_api_v1 *corosync, unsigned int object_service_handle,
- char *key, char **value)
-{
- int res;
-
- *value = NULL;
- if ( !(res = corosync_api->object_key_get(object_service_handle,
- key,
- strlen(key),
- (void *)value,
- NULL))) {
- if (*value)
- return 0;
- }
- return -1;
-}
-
-static inline void objdb_get_int(struct corosync_api_v1 *corosync, unsigned int object_service_handle,
- char *key, unsigned int *intvalue, unsigned int default_value)
-{
- char *value = NULL;
-
- *intvalue = default_value;
-
- if (!corosync_api->object_key_get(object_service_handle, key, strlen(key),
- (void *)&value, NULL)) {
- if (value) {
- *intvalue = atoi(value);
- }
- }
-}
-
-static int cmanquorum_send_message(void *message, int len)
-{
- struct iovec iov[2];
- struct q_protheader header;
-
- header.tgtport = 0;
- header.srcport = 0;
- header.flags = 0;
- header.srcid = us->node_id;
- header.tgtid = 0;
-
- iov[0].iov_base = &header;
- iov[0].iov_len = sizeof(header);
- iov[1].iov_base = message;
- iov[1].iov_len = len;
-
- return corosync_api->tpg_joined_mcast(group_handle, iov, 2, TOTEM_AGREED);
-}
-
-static void read_quorum_config(unsigned int quorum_handle)
-{
- unsigned int value = 0;
- int cluster_members = 0;
- struct list_head *tmp;
- struct cluster_node *node;
-
- log_printf(LOG_INFO, "Reading configuration\n");
-
- objdb_get_int(corosync_api, quorum_handle, "expected_votes", &us->expected_votes, DEFAULT_EXPECTED);
- objdb_get_int(corosync_api, quorum_handle, "votes", &us->votes, 1);
- objdb_get_int(corosync_api, quorum_handle, "quorumdev_poll", &quorumdev_poll, DEFAULT_QDEV_POLL);
- objdb_get_int(corosync_api, quorum_handle, "disallowed", &value, 0);
- if (value)
- quorum_flags |= CMANQUORUM_FLAG_FEATURE_DISALLOWED;
- else
- quorum_flags &= ~CMANQUORUM_FLAG_FEATURE_DISALLOWED;
-
- objdb_get_int(corosync_api, quorum_handle, "two_node", &value, 0);
- if (value)
- quorum_flags |= CMANQUORUM_FLAG_FEATURE_TWONODE;
- else
- quorum_flags &= ~CMANQUORUM_FLAG_FEATURE_TWONODE;
-
- /*
- * two_node mode is invalid if there are more than 2 nodes in the cluster!
- */
- list_iterate(tmp, &cluster_members_list) {
- node = list_entry(tmp, struct cluster_node, list);
- cluster_members++;
- }
-
- if (quorum_flags & CMANQUORUM_FLAG_FEATURE_TWONODE && cluster_members > 2) {
- log_printf(LOG_WARNING, "quorum.two_node was set but there are more than 2 nodes in the cluster. It will be ignored.");
- quorum_flags &= ~CMANQUORUM_FLAG_FEATURE_TWONODE;
- }
-}
-
-static int cmanquorum_exec_init_fn (struct corosync_api_v1 *api)
-{
- unsigned int object_handle;
- unsigned int find_handle;
-
- ENTER();
-
- corosync_api = api;
-
- list_init(&cluster_members_list);
- list_init(&trackers_list);
-
- /* Allocate a cluster_node for us */
- us = allocate_node(corosync_api->totem_nodeid_get());
- if (!us)
- return (1);
-
- us->flags |= NODE_FLAGS_US;
- us->state = NODESTATE_MEMBER;
- us->expected_votes = DEFAULT_EXPECTED;
- us->votes = 1;
- time(&us->join_time);
-
- /* Get configuration variables */
- corosync_api->object_find_create(OBJECT_PARENT_HANDLE, "quorum", strlen("quorum"), &find_handle);
-
- if (corosync_api->object_find_next(find_handle, &object_handle) == 0) {
- read_quorum_config(object_handle);
- }
- /* Listen for changes */
- add_cmanquorum_config_notification(object_handle);
- corosync_api->object_find_destroy(find_handle);
-
-#ifdef CMAN_COMPATIBILITY
- corosync_api->object_find_create(OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"), &find_handle);
-
- if (corosync_api->object_find_next(find_handle, &object_handle) == 0) {
- char *name;
- objdb_get_string(corosync_api, object_handle, "name", &name);
- if (strlen(name) < 16)
- strcpy(clustername, name);
-
- objdb_get_int(corosync_api, object_handle, "cluster_id", &cluster_id, 0);
- objdb_get_int(corosync_api, object_handle, "config_version", &config_version, 0);
- }
- corosync_api->object_find_destroy(find_handle);
-#endif
-
-
- api->tpg_init(&group_handle, quorum_deliver_fn, quorum_confchg_fn);
- api->tpg_join(group_handle, quorum_group, 1);
-
- LEAVE();
- return (0);
-}
-
-static int quorum_lib_exit_fn (void *conn)
-{
- struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
-
- ENTER();
- if (quorum_pd->tracking_enabled) {
- list_del (&quorum_pd->list);
- list_init (&quorum_pd->list);
- }
- LEAVE();
- return (0);
-}
-
-
-static int send_quorum_notification(void *conn, uint64_t context)
-{
- struct res_lib_cmanquorum_notification *res_lib_cmanquorum_notification;
- struct list_head *tmp;
- struct cluster_node *node;
- int cluster_members = 0;
- int i = 0;
- int size;
- char *buf;
-
- ENTER();
- list_iterate(tmp, &cluster_members_list) {
- node = list_entry(tmp, struct cluster_node, list);
- cluster_members++;
- }
- if (quorum_device)
- cluster_members++;
-
- size = sizeof(struct res_lib_cmanquorum_notification) + sizeof(struct cmanquorum_node) * cluster_members;
- buf = alloca(size);
- if (!buf) {
- LEAVE();
- return -1;
- }
-
- res_lib_cmanquorum_notification = (struct res_lib_cmanquorum_notification *)buf;
- res_lib_cmanquorum_notification->quorate = cluster_is_quorate;
- res_lib_cmanquorum_notification->node_list_entries = cluster_members;
- res_lib_cmanquorum_notification->context = context;
- list_iterate(tmp, &cluster_members_list) {
- node = list_entry(tmp, struct cluster_node, list);
- res_lib_cmanquorum_notification->node_list[i].nodeid = node->node_id;
- res_lib_cmanquorum_notification->node_list[i++].state = node->state;
- }
- if (quorum_device) {
- res_lib_cmanquorum_notification->node_list[i].nodeid = 0;
- res_lib_cmanquorum_notification->node_list[i++].state = quorum_device->state | 0x80;
- }
- res_lib_cmanquorum_notification->header.id = MESSAGE_RES_CMANQUORUM_NOTIFICATION;
- res_lib_cmanquorum_notification->header.size = size;
- res_lib_cmanquorum_notification->header.error = CS_OK;
-
- /* Send it to all interested parties */
- if (conn) {
- int ret = corosync_api->ipc_conn_send_response(conn, buf, size);
- LEAVE();
- return ret;
- }
- else {
- struct quorum_pd *qpd;
-
- list_iterate(tmp, &trackers_list) {
- qpd = list_entry(tmp, struct quorum_pd, list);
- res_lib_cmanquorum_notification->context = qpd->tracking_context;
- corosync_api->ipc_conn_send_response(corosync_api->ipc_conn_partner_get(qpd->conn), buf, size);
- }
- }
- LEAVE();
- return 0;
-}
-
-static void set_quorate(int total_votes)
-{
- int quorate;
-
- ENTER();
- if (quorum > total_votes) {
- quorate = 0;
- }
- else {
- quorate = 1;
- }
-
- if (cluster_is_quorate && !quorate)
- log_printf(LOG_INFO, "quorum lost, blocking activity\n");
- if (!cluster_is_quorate && quorate)
- log_printf(LOG_INFO, "quorum regained, resuming activity\n");
-
- /* If we are newly quorate, then kill any DISALLOWED nodes */
- if (!cluster_is_quorate && quorate) {
- struct cluster_node *node = NULL;
- struct list_head *tmp;
-
- list_iterate(tmp, &cluster_members_list) {
- node = list_entry(tmp, struct cluster_node, list);
- if (node->state == NODESTATE_DISALLOWED)
- quorum_exec_send_killnode(node->node_id, CMANQUORUM_REASON_KILL_REJOIN);
- }
- }
-
- cluster_is_quorate = quorate;
- set_quorum(cman_members, cman_members_entries, quorate, &cman_ringid);
- ENTER();
-}
-
-static int calculate_quorum(int allow_decrease, int max_expected, unsigned int *ret_total_votes)
-{
- struct list_head *nodelist;
- struct cluster_node *node;
- unsigned int total_votes = 0;
- unsigned int highest_expected = 0;
- unsigned int newquorum, q1, q2;
- unsigned int total_nodes = 0;
- unsigned int leaving = 0;
-
- ENTER();
- list_iterate(nodelist, &cluster_members_list) {
- node = list_entry(nodelist, struct cluster_node, list);
-
- log_printf(LOG_DEBUG, "node %x state=%d, votes=%d, expected=%d\n",
- node->node_id, node->state, node->votes, node->expected_votes);
-
- if (node->state == NODESTATE_MEMBER) {
- if (max_expected)
- node->expected_votes = max_expected;
- else
- highest_expected = max(highest_expected, node->expected_votes);
- total_votes += node->votes;
- total_nodes++;
- }
- if (node->state == NODESTATE_LEAVING) {
- leaving = 1;
- }
- }
-
- if (quorum_device && quorum_device->state == NODESTATE_MEMBER)
- total_votes += quorum_device->votes;
-
- if (max_expected > 0)
- highest_expected = max_expected;
-
- /* This quorum calculation is taken from the OpenVMS Cluster Systems
- * manual, but, then, you guessed that didn't you */
- q1 = (highest_expected + 2) / 2;
- q2 = (total_votes + 2) / 2;
- newquorum = max(q1, q2);
-
- /* Normally quorum never decreases but the system administrator can
- * force it down by setting expected votes to a maximum value */
- if (!allow_decrease)
- newquorum = max(quorum, newquorum);
-
- /* The special two_node mode allows each of the two nodes to retain
- * quorum if the other fails. Only one of the two should live past
- * fencing (as both nodes try to fence each other in split-brain.)
- * Also: if there are more than two nodes, force us inquorate to avoid
- * any damage or confusion.
- */
- if ((quorum_flags & CMANQUORUM_FLAG_FEATURE_TWONODE) && total_nodes <= 2)
- newquorum = 1;
-
- if (ret_total_votes)
- *ret_total_votes = total_votes;
-
- LEAVE();
- return newquorum;
-}
-
-/* Recalculate cluster quorum, set quorate and notify changes */
-static void recalculate_quorum(int allow_decrease)
-{
- unsigned int total_votes;
-
- ENTER();
- quorum = calculate_quorum(allow_decrease, 0, &total_votes);
- set_quorate(total_votes);
- send_quorum_notification(NULL, 0L);
- LEAVE();
-}
-
-static int have_disallowed(void)
-{
- struct cluster_node *node;
- struct list_head *tmp;
-
- list_iterate(tmp, &cluster_members_list) {
- node = list_entry(tmp, struct cluster_node, list);
- if (node->state == NODESTATE_DISALLOWED)
- return 1;
- }
-
- return 0;
-}
-
-static void node_add_ordered(struct cluster_node *newnode)
-{
- struct cluster_node *node = NULL;
- struct list_head *tmp;
- struct list_head *newlist = &newnode->list;
-
- list_iterate(tmp, &cluster_members_list) {
- node = list_entry(tmp, struct cluster_node, list);
-
- if (newnode->node_id < node->node_id)
- break;
- }
-
- if (!node)
- list_add(&newnode->list, &cluster_members_list);
- else {
- newlist->prev = tmp->prev;
- newlist->next = tmp;
- tmp->prev->next = newlist;
- tmp->prev = newlist;
- }
-}
-
-static struct cluster_node *allocate_node(int nodeid)
-{
- struct cluster_node *cl;
-
- cl = malloc(sizeof(struct cluster_node));
- if (cl) {
- memset(cl, 0, sizeof(struct cluster_node));
- cl->node_id = nodeid;
- if (nodeid)
- node_add_ordered(cl);
- }
- return cl;
-}
-
-static struct cluster_node *find_node_by_nodeid(int nodeid)
-{
- struct cluster_node *node;
- struct list_head *tmp;
-
- list_iterate(tmp, &cluster_members_list) {
- node = list_entry(tmp, struct cluster_node, list);
- if (node->node_id == nodeid)
- return node;
- }
- return NULL;
-}
-
-
-static int quorum_exec_send_nodeinfo()
-{
- struct req_exec_quorum_nodeinfo req_exec_quorum_nodeinfo;
- int ret;
-
- ENTER();
-
- req_exec_quorum_nodeinfo.cmd = CMANQUORUM_MSG_NODEINFO;
- req_exec_quorum_nodeinfo.config_version = config_version;
- req_exec_quorum_nodeinfo.expected_votes = us->expected_votes;
- req_exec_quorum_nodeinfo.votes = us->votes;
- req_exec_quorum_nodeinfo.major_version = CMANQUORUM_MAJOR_VERSION;
- req_exec_quorum_nodeinfo.minor_version = CMANQUORUM_MINOR_VERSION;
- req_exec_quorum_nodeinfo.patch_version = CMANQUORUM_PATCH_VERSION;
- req_exec_quorum_nodeinfo.flags = us->flags;
- req_exec_quorum_nodeinfo.join_time = us->join_time;
- req_exec_quorum_nodeinfo.first_trans = first_trans;
- if (have_disallowed())
- req_exec_quorum_nodeinfo.flags |= NODE_FLAGS_SEESDISALLOWED;
-
-#ifdef CMAN_COMPATIBILITY
- strcpy( req_exec_quorum_nodeinfo.clustername, clustername);
- req_exec_quorum_nodeinfo.cluster_id = cluster_id;
-#endif
-
- ret = cmanquorum_send_message(&req_exec_quorum_nodeinfo, sizeof(req_exec_quorum_nodeinfo));
- LEAVE();
- return ret;
-}
-
-
-static int quorum_exec_send_reconfigure(int param, int nodeid, int value)
-{
- struct req_exec_quorum_reconfigure req_exec_quorum_reconfigure;
- int ret;
-
- ENTER();
-
- req_exec_quorum_reconfigure.cmd = CMANQUORUM_MSG_RECONFIGURE;
- req_exec_quorum_reconfigure.param = param;
- req_exec_quorum_reconfigure.nodeid = nodeid;
- req_exec_quorum_reconfigure.value = value;
-
- ret = cmanquorum_send_message(&req_exec_quorum_reconfigure, sizeof(req_exec_quorum_reconfigure));
- LEAVE();
- return ret;
-}
-
-static int quorum_exec_send_killnode(int nodeid, unsigned int reason)
-{
- struct req_exec_quorum_killnode req_exec_quorum_killnode;
- int ret;
-
- ENTER();
-
- req_exec_quorum_killnode.cmd = CMANQUORUM_MSG_KILLNODE;
- req_exec_quorum_killnode.nodeid = nodeid;
- req_exec_quorum_killnode.reason = reason;
-
- ret = cmanquorum_send_message(&req_exec_quorum_killnode, sizeof(req_exec_quorum_killnode));
- LEAVE();
- return ret;
-}
-
-static void quorum_confchg_fn (
- enum totem_configuration_type configuration_type,
- unsigned int *member_list, int member_list_entries,
- unsigned int *left_list, int left_list_entries,
- unsigned int *joined_list, int joined_list_entries,
- struct memb_ring_id *ring_id)
-{
- int i;
- int leaving = 0;
- struct cluster_node *node;
-
- ENTER();
- if (member_list_entries > 1)
- first_trans = 0;
-
- if (left_list_entries) {
- for (i = 0; i< left_list_entries; i++) {
- node = find_node_by_nodeid(left_list[i]);
- if (node) {
- if (node->state == NODESTATE_LEAVING)
- leaving = 1;
- node->state = NODESTATE_DEAD;
- node->flags |= NODE_FLAGS_BEENDOWN;
- }
- }
- recalculate_quorum(leaving);
- }
-
- if (member_list_entries) {
- memcpy(cman_members, member_list, sizeof(unsigned int) * member_list_entries);
- cman_members_entries = member_list_entries;
- if (quorum_device) {
- cman_members[cman_members_entries++] = 0;
- }
- quorum_exec_send_nodeinfo();
- }
-
- memcpy(&cman_ringid, ring_id, sizeof(*ring_id));
- LEAVE();
-}
-
-static void exec_quorum_nodeinfo_endian_convert (void *msg)
-{
- struct req_exec_quorum_nodeinfo *nodeinfo = (struct req_exec_quorum_nodeinfo *)msg;
-
-#ifdef CMAN_COMPATIBILITY
- nodeinfo->cluster_id = swab16(nodeinfo->cluster_id);
-#endif
- nodeinfo->votes = swab32(nodeinfo->votes);
- nodeinfo->expected_votes = swab32(nodeinfo->expected_votes);
- nodeinfo->major_version = swab32(nodeinfo->major_version);
- nodeinfo->minor_version = swab32(nodeinfo->minor_version);
- nodeinfo->patch_version = swab32(nodeinfo->patch_version);
- nodeinfo->config_version = swab32(nodeinfo->config_version);
- nodeinfo->flags = swab32(nodeinfo->flags);
-}
-
-static void exec_quorum_reconfigure_endian_convert (void *msg)
-{
- struct req_exec_quorum_reconfigure *reconfigure = (struct req_exec_quorum_reconfigure *)msg;
- reconfigure->nodeid = swab32(reconfigure->nodeid);
- reconfigure->value = swab32(reconfigure->value);
-}
-
-static void exec_quorum_killnode_endian_convert (void *msg)
-{
- struct req_exec_quorum_killnode *killnode = (struct req_exec_quorum_killnode *)msg;
- killnode->reason = swab16(killnode->reason);
- killnode->nodeid = swab32(killnode->nodeid);
-}
-
-static void quorum_deliver_fn(unsigned int nodeid, struct iovec *iovec, int iov_len,
- int endian_conversion_required)
-{
- struct q_protheader *header = iovec->iov_base;
- char *buf;
-
- ENTER();
-
- if (endian_conversion_required) {
- header->srcid = swab32(header->srcid);
- header->tgtid = swab32(header->tgtid);
- header->flags = swab32(header->flags);
- }
-
- /* Only pass on messages for us or everyone */
- if (header->tgtport == 0 &&
- (header->tgtid == us->node_id ||
- header->tgtid == 0)) {
- buf = iovec->iov_base + sizeof(struct q_protheader);
- switch (*buf) {
-
- case CMANQUORUM_MSG_NODEINFO:
- if (endian_conversion_required)
- exec_quorum_nodeinfo_endian_convert(buf);
- message_handler_req_exec_quorum_nodeinfo (buf, header->srcid);
- break;
- case CMANQUORUM_MSG_RECONFIGURE:
- if (endian_conversion_required)
- exec_quorum_reconfigure_endian_convert(buf);
- message_handler_req_exec_quorum_reconfigure (buf, header->srcid);
- break;
- case CMANQUORUM_MSG_KILLNODE:
- if (endian_conversion_required)
- exec_quorum_killnode_endian_convert(buf);
- message_handler_req_exec_quorum_killnode (buf, header->srcid);
- break;
-
- /* Just ignore other messages */
- }
- }
- LEAVE();
-}
-
-static void message_handler_req_exec_quorum_nodeinfo (
- void *message,
- unsigned int nodeid)
-{
- struct req_exec_quorum_nodeinfo *req_exec_quorum_nodeinfo = (struct req_exec_quorum_nodeinfo *)message;
- struct cluster_node *node;
- int old_votes;
- int old_expected;
- nodestate_t old_state;
- int new_node = 0;
-
- ENTER();
- log_printf(LOG_LEVEL_DEBUG, "got nodeinfo message from cluster node %d\n", nodeid);
-
- node = find_node_by_nodeid(nodeid);
- if (!node) {
- node = allocate_node(nodeid);
- new_node = 1;
- }
- if (!node) {
- corosync_api->error_memory_failure();
- return;
- }
-
- /*
- * If the node sending the message sees disallowed nodes and we don't, then
- * we have to leave
- */
- if (req_exec_quorum_nodeinfo->flags & NODE_FLAGS_SEESDISALLOWED && !have_disallowed()) {
- /* Must use syslog directly here or the message will never arrive */
- syslog(LOG_CRIT, "[CMANQ]: Joined a cluster with disallowed nodes. must die");
- corosync_api->fatal_error(2, __FILE__, __LINE__);
- exit(2);
- }
- old_votes = node->votes;
- old_expected = node->expected_votes;
- old_state = node->state;
-
- /* Update node state */
- if (req_exec_quorum_nodeinfo->minor_version >= 2)
- node->votes = req_exec_quorum_nodeinfo->votes;
- node->expected_votes = req_exec_quorum_nodeinfo->expected_votes;
- node->state = NODESTATE_MEMBER;
-
- /* Check flags for disallowed (if enabled) */
- if (quorum_flags & CMANQUORUM_FLAG_FEATURE_DISALLOWED) {
- if ((req_exec_quorum_nodeinfo->flags & NODE_FLAGS_DIRTY && node->flags & NODE_FLAGS_BEENDOWN) ||
- (req_exec_quorum_nodeinfo->flags & NODE_FLAGS_DIRTY && req_exec_quorum_nodeinfo->first_trans && !(node->flags & NODE_FLAGS_US))) {
- if (node->state != NODESTATE_DISALLOWED) {
- if (cluster_is_quorate) {
- log_printf(LOG_CRIT, "Killing node %d because it has rejoined the cluster with existing state", node->node_id);
- node->state = NODESTATE_DISALLOWED;
- quorum_exec_send_killnode(nodeid, CMANQUORUM_REASON_KILL_REJOIN);
- }
- else {
- log_printf(LOG_CRIT, "Node %d not joined to quorum because it has existing state", node->node_id);
- node->state = NODESTATE_DISALLOWED;
- }
- }
- }
- }
- node->flags &= ~NODE_FLAGS_BEENDOWN;
-
- if (new_node || old_votes != node->votes || old_expected != node->expected_votes || old_state != node->state)
- recalculate_quorum(0);
- LEAVE();
-}
-
-static void message_handler_req_exec_quorum_killnode (
- void *message,
- unsigned int nodeid)
-{
- struct req_exec_quorum_killnode *req_exec_quorum_killnode = (struct req_exec_quorum_killnode *)message;
-
- if (req_exec_quorum_killnode->nodeid == corosync_api->totem_nodeid_get()) {
- log_printf(LOG_CRIT, "Killed by node %d: %s\n", nodeid, kill_reason(req_exec_quorum_killnode->reason));
-
- corosync_api->fatal_error(1, __FILE__, __LINE__);
- exit(1);
- }
-}
-
-static void message_handler_req_exec_quorum_reconfigure (
- void *message,
- unsigned int nodeid)
-{
- struct req_exec_quorum_reconfigure *req_exec_quorum_reconfigure = (struct req_exec_quorum_reconfigure *)message;
- struct cluster_node *node;
- struct list_head *nodelist;
-
- log_printf(LOG_LEVEL_DEBUG, "got reconfigure message from cluster node %d\n", nodeid);
-
- node = find_node_by_nodeid(req_exec_quorum_reconfigure->nodeid);
- if (!node)
- return;
-
- switch(req_exec_quorum_reconfigure->param)
- {
- case RECONFIG_PARAM_EXPECTED_VOTES:
- node->expected_votes = req_exec_quorum_reconfigure->value;
-
- list_iterate(nodelist, &cluster_members_list) {
- node = list_entry(nodelist, struct cluster_node, list);
- if (node->state == NODESTATE_MEMBER &&
- node->expected_votes > req_exec_quorum_reconfigure->value) {
- node->expected_votes = req_exec_quorum_reconfigure->value;
- }
- }
- recalculate_quorum(1); /* Allow decrease */
- break;
-
- case RECONFIG_PARAM_NODE_VOTES:
- node->votes = req_exec_quorum_reconfigure->value;
- recalculate_quorum(1); /* Allow decrease */
- break;
-
- case RECONFIG_PARAM_LEAVING:
- node->state = NODESTATE_LEAVING;
- break;
- }
-}
-
-static int quorum_lib_init_fn (void *conn)
-{
- struct quorum_pd *pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
-
- ENTER();
-
- list_init (&pd->list);
- pd->conn = conn;
-
- LEAVE();
- return (0);
-}
-
-/* Message from the library */
-static void message_handler_req_lib_cmanquorum_getinfo (void *conn, void *message)
-{
- struct req_lib_cmanquorum_getinfo *req_lib_cmanquorum_getinfo = (struct req_lib_cmanquorum_getinfo *)message;
- struct res_lib_cmanquorum_getinfo res_lib_cmanquorum_getinfo;
- struct cluster_node *node;
- unsigned int highest_expected = 0;
- unsigned int total_votes = 0;
- cs_error_t error = CS_OK;
-
- log_printf(LOG_LEVEL_DEBUG, "got getinfo request on %p for node %d\n", conn, req_lib_cmanquorum_getinfo->nodeid);
-
- if (req_lib_cmanquorum_getinfo->nodeid) {
- node = find_node_by_nodeid(req_lib_cmanquorum_getinfo->nodeid);
- }
- else {
- node = us;
- }
-
- if (node) {
- struct cluster_node *iternode;
- struct list_head *nodelist;
-
- list_iterate(nodelist, &cluster_members_list) {
- iternode = list_entry(nodelist, struct cluster_node, list);
-
- if (node->state == NODESTATE_MEMBER) {
- highest_expected =
- max(highest_expected, node->expected_votes);
- total_votes += node->votes;
- }
- }
-
- if (quorum_device && quorum_device->state == NODESTATE_MEMBER) {
- total_votes += quorum_device->votes;
- }
-
- res_lib_cmanquorum_getinfo.votes = us->votes;
- res_lib_cmanquorum_getinfo.expected_votes = us->expected_votes;
- res_lib_cmanquorum_getinfo.highest_expected = highest_expected;
-
- res_lib_cmanquorum_getinfo.quorum = quorum;
- res_lib_cmanquorum_getinfo.total_votes = total_votes;
- res_lib_cmanquorum_getinfo.flags = 0;
- res_lib_cmanquorum_getinfo.nodeid = node->node_id;
-
- if (us->flags & NODE_FLAGS_DIRTY)
- res_lib_cmanquorum_getinfo.flags |= CMANQUORUM_INFO_FLAG_DIRTY;
- if (quorum_flags & CMANQUORUM_FLAG_FEATURE_TWONODE)
- res_lib_cmanquorum_getinfo.flags |= CMANQUORUM_INFO_FLAG_TWONODE;
- if (cluster_is_quorate)
- res_lib_cmanquorum_getinfo.flags |= CMANQUORUM_INFO_FLAG_QUORATE;
- if (us->flags & NODE_FLAGS_SEESDISALLOWED)
- res_lib_cmanquorum_getinfo.flags |= CMANQUORUM_INFO_FLAG_DISALLOWED;
- }
- else {
- error = CS_ERR_NOT_EXIST;
- }
-
- res_lib_cmanquorum_getinfo.header.size = sizeof(res_lib_cmanquorum_getinfo);
- res_lib_cmanquorum_getinfo.header.id = MESSAGE_RES_CMANQUORUM_GETINFO;
- res_lib_cmanquorum_getinfo.header.error = error;
- corosync_api->ipc_conn_send_response(conn, &res_lib_cmanquorum_getinfo, sizeof(res_lib_cmanquorum_getinfo));
- log_printf(LOG_LEVEL_DEBUG, "getinfo response error: %d\n", error);
-}
-
-/* Message from the library */
-static void message_handler_req_lib_cmanquorum_killnode (void *conn, void *message)
-{
- struct req_lib_cmanquorum_killnode *req_lib_cmanquorum_killnode = (struct req_lib_cmanquorum_killnode *)message;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
- cs_error_t error = CS_OK;
-
- ENTER();
-
- quorum_exec_send_killnode(req_lib_cmanquorum_killnode->nodeid, req_lib_cmanquorum_killnode->reason);
-
- /* send status */
- res_lib_cmanquorum_status.header.size = sizeof(res_lib_cmanquorum_status);
- res_lib_cmanquorum_status.header.id = MESSAGE_RES_CMANQUORUM_STATUS;
- res_lib_cmanquorum_status.header.error = error;
- corosync_api->ipc_conn_send_response(conn, &res_lib_cmanquorum_status, sizeof(res_lib_cmanquorum_status));
- LEAVE();
-}
-
-/* Message from the library */
-static void message_handler_req_lib_cmanquorum_setexpected (void *conn, void *message)
-{
- struct req_lib_cmanquorum_setexpected *req_lib_cmanquorum_setexpected = (struct req_lib_cmanquorum_setexpected *)message;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
- cs_error_t error = CS_OK;
- unsigned int newquorum;
- unsigned int total_votes;
-
- ENTER();
-
- /*
- * If there are disallowed nodes, then we can't allow the user
- * to bypass them by fiddling with expected votes.
- */
- if (quorum_flags & CMANQUORUM_FLAG_FEATURE_DISALLOWED && have_disallowed()) {
- error = CS_ERR_EXIST;
- goto error_exit;
- }
-
- /* Validate new expected votes */
- newquorum = calculate_quorum(1, req_lib_cmanquorum_setexpected->expected_votes, &total_votes);
- if (newquorum < total_votes / 2
- || newquorum > total_votes) {
- error = CS_ERR_INVALID_PARAM;
- goto error_exit;
- }
-
- quorum_exec_send_reconfigure(RECONFIG_PARAM_EXPECTED_VOTES, us->node_id, req_lib_cmanquorum_setexpected->expected_votes);
-
- /* send status */
-error_exit:
- res_lib_cmanquorum_status.header.size = sizeof(res_lib_cmanquorum_status);
- res_lib_cmanquorum_status.header.id = MESSAGE_RES_CMANQUORUM_STATUS;
- res_lib_cmanquorum_status.header.error = error;
- corosync_api->ipc_conn_send_response(conn, &res_lib_cmanquorum_status, sizeof(res_lib_cmanquorum_status));
- LEAVE();
-}
-
-/* Message from the library */
-static void message_handler_req_lib_cmanquorum_setvotes (void *conn, void *message)
-{
- struct req_lib_cmanquorum_setvotes *req_lib_cmanquorum_setvotes = (struct req_lib_cmanquorum_setvotes *)message;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
- struct cluster_node *node;
- unsigned int newquorum;
- unsigned int total_votes;
- unsigned int saved_votes;
- cs_error_t error = CS_OK;
-
- ENTER();
-
- node = find_node_by_nodeid(req_lib_cmanquorum_setvotes->nodeid);
- if (!node) {
- error = CS_ERR_NAME_NOT_FOUND;
- goto error_exit;
- }
-
- /* Check votes is valid */
- saved_votes = node->votes;
- node->votes = req_lib_cmanquorum_setvotes->votes;
-
- newquorum = calculate_quorum(1, 0, &total_votes);
-
- if (newquorum < total_votes / 2 || newquorum > total_votes) {
- node->votes = saved_votes;
- error = CS_ERR_INVALID_PARAM;
- goto error_exit;
- }
-
- if (!req_lib_cmanquorum_setvotes->nodeid)
- req_lib_cmanquorum_setvotes->nodeid = corosync_api->totem_nodeid_get();
-
- quorum_exec_send_reconfigure(RECONFIG_PARAM_NODE_VOTES, req_lib_cmanquorum_setvotes->nodeid, req_lib_cmanquorum_setvotes->votes);
-
-error_exit:
- /* send status */
- res_lib_cmanquorum_status.header.size = sizeof(res_lib_cmanquorum_status);
- res_lib_cmanquorum_status.header.id = MESSAGE_RES_CMANQUORUM_STATUS;
- res_lib_cmanquorum_status.header.error = error;
- corosync_api->ipc_conn_send_response(conn, &res_lib_cmanquorum_status, sizeof(res_lib_cmanquorum_status));
- LEAVE();
-}
-
-static void message_handler_req_lib_cmanquorum_leaving (void *conn, void *message)
-{
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
- cs_error_t error = CS_OK;
-
- ENTER();
-
- quorum_exec_send_reconfigure(RECONFIG_PARAM_LEAVING, us->node_id, 0);
-
- /* send status */
- res_lib_cmanquorum_status.header.size = sizeof(res_lib_cmanquorum_status);
- res_lib_cmanquorum_status.header.id = MESSAGE_RES_CMANQUORUM_STATUS;
- res_lib_cmanquorum_status.header.error = error;
- corosync_api->ipc_conn_send_response(conn, &res_lib_cmanquorum_status, sizeof(res_lib_cmanquorum_status));
- LEAVE();
-}
-
-static void quorum_device_timer_fn(void *arg)
-{
- struct timeval now;
-
- ENTER();
- if (!quorum_device || quorum_device->state == NODESTATE_DEAD)
- return;
- gettimeofday(&now, NULL);
- if (quorum_device->last_hello.tv_sec + quorumdev_poll/1000 < now.tv_sec) {
- quorum_device->state = NODESTATE_DEAD;
- log_printf(LOG_INFO, "lost contact with quorum device\n");
- recalculate_quorum(0);
- }
- else {
- corosync_api->timer_add_duration((unsigned long long)quorumdev_poll*1000000, quorum_device,
- quorum_device_timer_fn, &quorum_device_timer);
- }
- LEAVE();
-}
-
-
-static void message_handler_req_lib_cmanquorum_qdisk_register (void *conn, void *message)
-{
- struct req_lib_cmanquorum_qdisk_register *req_lib_cmanquorum_qdisk_register = (struct req_lib_cmanquorum_qdisk_register *)message;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
- cs_error_t error = CS_OK;
-
- ENTER();
-
- if (quorum_device) {
- error = CS_ERR_EXIST;
- }
- else {
- quorum_device = allocate_node(0);
- quorum_device->state = NODESTATE_DEAD;
- quorum_device->votes = req_lib_cmanquorum_qdisk_register->votes;
- strcpy(quorum_device_name, req_lib_cmanquorum_qdisk_register->name);
- list_add(&quorum_device->list, &cluster_members_list);
- }
-
- /* send status */
- res_lib_cmanquorum_status.header.size = sizeof(res_lib_cmanquorum_status);
- res_lib_cmanquorum_status.header.id = MESSAGE_RES_CMANQUORUM_STATUS;
- res_lib_cmanquorum_status.header.error = error;
- corosync_api->ipc_conn_send_response(conn, &res_lib_cmanquorum_status, sizeof(res_lib_cmanquorum_status));
- LEAVE();
-}
-
-static void message_handler_req_lib_cmanquorum_qdisk_unregister (void *conn, void *message)
-{
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
- cs_error_t error = CS_OK;
-
- ENTER();
-
- if (quorum_device) {
- struct cluster_node *node = quorum_device;
-
- quorum_device = NULL;
- list_del(&node->list);
- free(node);
- recalculate_quorum(0);
- }
- else {
- error = CS_ERR_NOT_EXIST;
- }
-
- /* send status */
- res_lib_cmanquorum_status.header.size = sizeof(res_lib_cmanquorum_status);
- res_lib_cmanquorum_status.header.id = MESSAGE_RES_CMANQUORUM_STATUS;
- res_lib_cmanquorum_status.header.error = error;
- corosync_api->ipc_conn_send_response(conn, &res_lib_cmanquorum_status, sizeof(res_lib_cmanquorum_status));
- LEAVE();
-}
-
-static void message_handler_req_lib_cmanquorum_qdisk_poll (void *conn, void *message)
-{
- struct req_lib_cmanquorum_qdisk_poll *req_lib_cmanquorum_qdisk_poll = (struct req_lib_cmanquorum_qdisk_poll *)message;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
- cs_error_t error = CS_OK;
-
- ENTER();
-
- if (quorum_device) {
- if (req_lib_cmanquorum_qdisk_poll->state) {
- gettimeofday(&quorum_device->last_hello, NULL);
- if (quorum_device->state == NODESTATE_DEAD) {
- quorum_device->state = NODESTATE_MEMBER;
- recalculate_quorum(0);
-
- corosync_api->timer_add_duration((unsigned long long)quorumdev_poll*1000000, quorum_device,
- quorum_device_timer_fn, &quorum_device_timer);
- }
- }
- else {
- if (quorum_device->state == NODESTATE_MEMBER) {
- quorum_device->state = NODESTATE_DEAD;
- recalculate_quorum(0);
- corosync_api->timer_delete(quorum_device_timer);
- }
- }
- }
- else {
- error = CS_ERR_NOT_EXIST;
- }
-
- /* send status */
- res_lib_cmanquorum_status.header.size = sizeof(res_lib_cmanquorum_status);
- res_lib_cmanquorum_status.header.id = MESSAGE_RES_CMANQUORUM_STATUS;
- res_lib_cmanquorum_status.header.error = error;
- corosync_api->ipc_conn_send_response(conn, &res_lib_cmanquorum_status, sizeof(res_lib_cmanquorum_status));
-
- LEAVE();
-}
-
-static void message_handler_req_lib_cmanquorum_qdisk_getinfo (void *conn, void *message)
-{
- struct res_lib_cmanquorum_qdisk_getinfo res_lib_cmanquorum_qdisk_getinfo;
- cs_error_t error = CS_OK;
-
- ENTER();
-
- if (quorum_device) {
- log_printf(LOG_LEVEL_DEBUG, "got qdisk_getinfo state %d\n", quorum_device->state);
- res_lib_cmanquorum_qdisk_getinfo.votes = quorum_device->votes;
- if (quorum_device->state == NODESTATE_MEMBER)
- res_lib_cmanquorum_qdisk_getinfo.state = 1;
- else
- res_lib_cmanquorum_qdisk_getinfo.state = 0;
- strcpy(res_lib_cmanquorum_qdisk_getinfo.name, quorum_device_name);
- }
- else {
- error = CS_ERR_NOT_EXIST;
- }
-
- /* send status */
- res_lib_cmanquorum_qdisk_getinfo.header.size = sizeof(res_lib_cmanquorum_qdisk_getinfo);
- res_lib_cmanquorum_qdisk_getinfo.header.id = MESSAGE_RES_CMANQUORUM_GETINFO;
- res_lib_cmanquorum_qdisk_getinfo.header.error = error;
- corosync_api->ipc_conn_send_response(conn, &res_lib_cmanquorum_qdisk_getinfo, sizeof(res_lib_cmanquorum_qdisk_getinfo));
-
- LEAVE();
-}
-
-static void message_handler_req_lib_cmanquorum_setdirty (void *conn, void *message)
-{
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
- cs_error_t error = CS_OK;
-
- ENTER();
-
- us->flags |= NODE_FLAGS_DIRTY;
-
- /* send status */
- res_lib_cmanquorum_status.header.size = sizeof(res_lib_cmanquorum_status);
- res_lib_cmanquorum_status.header.id = MESSAGE_RES_CMANQUORUM_STATUS;
- res_lib_cmanquorum_status.header.error = error;
- corosync_api->ipc_conn_send_response(conn, &res_lib_cmanquorum_status, sizeof(res_lib_cmanquorum_status));
-
- LEAVE();
-}
-
-static void message_handler_req_lib_cmanquorum_trackstart (void *conn, void *msg)
-{
- struct req_lib_cmanquorum_trackstart *req_lib_cmanquorum_trackstart = (struct req_lib_cmanquorum_trackstart *)msg;
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
- struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
-
- ENTER();
- /*
- * If an immediate listing of the current cluster membership
- * is requested, generate membership list
- */
- if (req_lib_cmanquorum_trackstart->track_flags & CS_TRACK_CURRENT ||
- req_lib_cmanquorum_trackstart->track_flags & CS_TRACK_CHANGES) {
- log_printf(LOG_LEVEL_DEBUG, "sending initial status to %p\n", conn);
- send_quorum_notification(corosync_api->ipc_conn_partner_get (conn), req_lib_cmanquorum_trackstart->context);
- }
-
- /*
- * Record requests for tracking
- */
- if (req_lib_cmanquorum_trackstart->track_flags & CS_TRACK_CHANGES ||
- req_lib_cmanquorum_trackstart->track_flags & CS_TRACK_CHANGES_ONLY) {
-
- quorum_pd->track_flags = req_lib_cmanquorum_trackstart->track_flags;
- quorum_pd->tracking_enabled = 1;
- quorum_pd->tracking_context = req_lib_cmanquorum_trackstart->context;
-
- list_add (&quorum_pd->list, &trackers_list);
- }
-
- /* Send status */
- res_lib_cmanquorum_status.header.size = sizeof(res_lib_cmanquorum_status);
- res_lib_cmanquorum_status.header.id = MESSAGE_RES_CMANQUORUM_STATUS;
- res_lib_cmanquorum_status.header.error = CS_OK;
- corosync_api->ipc_conn_send_response(conn, &res_lib_cmanquorum_status, sizeof(res_lib_cmanquorum_status));
-
- LEAVE();
-}
-
-static void message_handler_req_lib_cmanquorum_trackstop (void *conn, void *msg)
-{
- struct res_lib_cmanquorum_status res_lib_cmanquorum_status;
- struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
- int error = CS_OK;
-
- ENTER();
-
- if (quorum_pd->tracking_enabled) {
- error = CS_OK;
- quorum_pd->tracking_enabled = 0;
- list_del (&quorum_pd->list);
- list_init (&quorum_pd->list);
- } else {
- error = CS_ERR_NOT_EXIST;
- }
-
- /* send status */
- res_lib_cmanquorum_status.header.size = sizeof(res_lib_cmanquorum_status);
- res_lib_cmanquorum_status.header.id = MESSAGE_RES_CMANQUORUM_STATUS;
- res_lib_cmanquorum_status.header.error = error;
- corosync_api->ipc_conn_send_response(conn, &res_lib_cmanquorum_status, sizeof(res_lib_cmanquorum_status));
-
- LEAVE();
-}
-
-
-static char *kill_reason(int reason)
-{
- static char msg[1024];
-
- switch (reason)
- {
- case CMANQUORUM_REASON_KILL_REJECTED:
- return "our membership application was rejected";
-
- case CMANQUORUM_REASON_KILL_APPLICATION:
- return "we were killed by an application request";
-
- case CMANQUORUM_REASON_KILL_REJOIN:
- return "we rejoined the cluster without a full restart";
-
- default:
- sprintf(msg, "we got kill message number %d", reason);
- return msg;
- }
-}
-
-static void reread_config(unsigned int object_handle)
-{
- unsigned int old_votes;
- unsigned int old_expected;
-
- old_votes = us->votes;
- old_expected = us->expected_votes;
-
- /*
- * Reload the configuration
- */
- read_quorum_config(object_handle);
-
- /*
- * Check for fundamental changes that we need to propogate
- */
- if (old_votes != us->votes) {
- quorum_exec_send_reconfigure(RECONFIG_PARAM_NODE_VOTES, us->node_id, us->votes);
- }
- if (old_expected != us->expected_votes) {
- quorum_exec_send_reconfigure(RECONFIG_PARAM_EXPECTED_VOTES, us->node_id, us->expected_votes);
- }
-}
-
-static void quorum_key_change_notify(object_change_type_t change_type,
- unsigned int parent_object_handle,
- unsigned int object_handle,
- void *object_name_pt, int object_name_len,
- void *key_name_pt, int key_len,
- void *key_value_pt, int key_value_len,
- void *priv_data_pt)
-{
- if (memcmp(object_name_pt, "quorum", object_name_len) == 0)
- reread_config(object_handle);
-}
-
-
-/* Called when the objdb is reloaded */
-static void cmanquorum_objdb_reload_notify(
- objdb_reload_notify_type_t type, int flush,
- void *priv_data_pt)
-{
- /*
- * A new quorum {} key might exist, cancel the
- * existing notification at the start of reload,
- * and start a new one on the new object when
- * it's all settled.
- */
-
- if (type == OBJDB_RELOAD_NOTIFY_START) {
- corosync_api->object_track_stop(
- quorum_key_change_notify,
- NULL,
- NULL,
- NULL,
- NULL);
- }
-
- if (type == OBJDB_RELOAD_NOTIFY_END ||
- type == OBJDB_RELOAD_NOTIFY_FAILED) {
- unsigned int find_handle;
- unsigned int object_handle;
-
- corosync_api->object_find_create(OBJECT_PARENT_HANDLE, "quorum", strlen("quorum"), &find_handle);
- if (corosync_api->object_find_next(find_handle, &object_handle) == 0) {
- add_cmanquorum_config_notification(object_handle);
-
- reread_config(object_handle);
- }
- else {
- log_printf(LOG_LEVEL_ERROR, "cmanquorum objdb tracking stopped, cannot find quorum{} handle in objdb\n");
- }
- }
-}
-
-
-static void add_cmanquorum_config_notification(
- unsigned int quorum_object_handle)
-{
-
- corosync_api->object_track_start(quorum_object_handle,
- 1,
- quorum_key_change_notify,
- NULL,
- NULL,
- NULL,
- NULL);
-
- /*
- * Reload notify must be on the parent object
- */
- corosync_api->object_track_start(OBJECT_PARENT_HANDLE,
- 1,
- NULL,
- NULL,
- NULL,
- cmanquorum_objdb_reload_notify,
- NULL);
-}
diff --git a/cman/services/quorum/test/Makefile b/cman/services/quorum/test/Makefile
deleted file mode 100644
index 4279c0b..0000000
--- a/cman/services/quorum/test/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-TARGETS= testcmanquorum1 testcmanquorum2
-
-all: depends ${TARGETS}
-
-include ../../../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -I../include
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L../lib -lcmanquorum
-LDFLAGS += -L${libdir}
-LDFLAGS += -L${corosynclibdir} -lcoroutil
-
-${TARGET}: ${OBJS}
- $(CC) -o $@ $^ $(LDFLAGS)
-
-depends:
- $(MAKE) -C ../lib all
-
-clean: generalclean
-
--include $(OBJS:.o=.d)
diff --git a/cman/services/quorum/test/testcmanquorum1.c b/cman/services/quorum/test/testcmanquorum1.c
deleted file mode 100644
index d34c0eb..0000000
--- a/cman/services/quorum/test/testcmanquorum1.c
+++ /dev/null
@@ -1,126 +0,0 @@
-#include <sys/types.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <corosync/corotypes.h>
-#include <corosync/cmanquorum.h>
-
-static cmanquorum_handle_t handle;
-
-static char *node_state(int state)
-{
- switch (state) {
- case NODESTATE_JOINING:
- return "Joining";
- break;
- case NODESTATE_MEMBER:
- return "Member";
- break;
- case NODESTATE_DEAD:
- return "Dead";
- break;
- case NODESTATE_LEAVING:
- return "Leaving";
- break;
- case NODESTATE_DISALLOWED:
- return "Disallowed";
- break;
- default:
- return "UNKNOWN";
- break;
- }
-}
-
-static void cmanquorum_notification_fn(
- cmanquorum_handle_t handle,
- uint64_t context,
- uint32_t quorate,
- uint32_t node_list_entries,
- cmanquorum_node_t node_list[]
- )
-{
- int i;
-
- printf("cmanquorum notification called \n");
- printf(" quorate = %d\n", quorate);
- printf(" number of nodes = %d\n", node_list_entries);
-
- for (i = 0; i< node_list_entries; i++) {
- printf(" %d: %s\n", node_list[i].nodeid, node_state(node_list[i].state));
- }
- printf("\n");
-}
-
-
-int main(int argc, char *argv[])
-{
- struct cmanquorum_info info;
- cmanquorum_callbacks_t callbacks;
- int err;
-
- if (argc > 1 && strcmp(argv[1], "-h")==0) {
- fprintf(stderr, "usage: %s [new-expected] [new-votes]\n", argv[0]);
- return 0;
- }
-
- callbacks.cmanquorum_notify_fn = cmanquorum_notification_fn;
- if ( (err=cmanquorum_initialize(&handle, &callbacks)) != CS_OK)
- fprintf(stderr, "cmanquorum_initialize FAILED: %d\n", err);
-
- if ( (err = cmanquorum_trackstart(handle, handle, CS_TRACK_CHANGES)) != CS_OK)
- fprintf(stderr, "cmanquorum_trackstart FAILED: %d\n", err);
-
- if ( (err=cmanquorum_getinfo(handle, 0, &info)) != CS_OK)
- fprintf(stderr, "cmanquorum_getinfo FAILED: %d\n", err);
- else {
- printf("node votes %d\n", info.node_votes);
- printf("expected votes %d\n", info.node_expected_votes);
- printf("highest expected %d\n", info.highest_expected);
- printf("total votes %d\n", info.total_votes);
- printf("quorum %d\n", info.quorum);
- printf("flags ");
- if (info.flags & CMANQUORUM_INFO_FLAG_DIRTY) printf("Dirty ");
- if (info.flags & CMANQUORUM_INFO_FLAG_DISALLOWED) printf("Disallowed ");
- if (info.flags & CMANQUORUM_INFO_FLAG_TWONODE) printf("2Node ");
- if (info.flags & CMANQUORUM_INFO_FLAG_QUORATE) printf("Quorate ");
- printf("\n");
- }
-
- if (argc >= 2 && atoi(argv[1])) {
- if ( (err=cmanquorum_setexpected(handle, atoi(argv[1]))) != CS_OK)
- fprintf(stderr, "set expected votes FAILED: %d\n", err);
- }
- if (argc >= 3 && atoi(argv[2])) {
- if ( (err=cmanquorum_setvotes(handle, 0, atoi(argv[2]))) != CS_OK)
- fprintf(stderr, "set votes FAILED: %d\n", err);
- }
-
- if (argc >= 2) {
- if ( (err=cmanquorum_getinfo(handle, 0, &info)) != CS_OK)
- fprintf(stderr, "cmanquorum_getinfo2 FAILED: %d\n", err);
- else {
- printf("-------------------\n");
- printf("node votes %d\n", info.node_votes);
- printf("expected votes %d\n", info.node_expected_votes);
- printf("highest expected %d\n", info.highest_expected);
- printf("total votes %d\n", info.total_votes);
- printf("cmanquorum %d\n", info.quorum);
- printf("flags ");
- if (info.flags & CMANQUORUM_INFO_FLAG_DIRTY) printf("Dirty ");
- if (info.flags & CMANQUORUM_INFO_FLAG_DISALLOWED) printf("Disallowed ");
- if (info.flags & CMANQUORUM_INFO_FLAG_TWONODE) printf("2Node ");
- if (info.flags & CMANQUORUM_INFO_FLAG_QUORATE) printf("Quorate ");
- printf("\n");
- }
- }
-
- printf("Waiting for cmanquorum events, press ^C to finish\n");
- printf("-------------------\n");
-
- while (1)
- cmanquorum_dispatch(handle, CS_DISPATCH_ALL);
-
- return 0;
-}
diff --git a/cman/services/quorum/test/testcmanquorum2.c b/cman/services/quorum/test/testcmanquorum2.c
deleted file mode 100644
index 7bb54e2..0000000
--- a/cman/services/quorum/test/testcmanquorum2.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <corosync/corotypes.h>
-#include <corosync/cmanquorum.h>
-
-static cmanquorum_handle_t handle;
-
-
-static void print_info(int ok_to_fail)
-{
- struct cmanquorum_qdisk_info qinfo;
- int err;
-
- if ( (err=cmanquorum_qdisk_getinfo(handle, &qinfo)) != CS_OK)
- fprintf(stderr, "cmanquorum_qdisk_getinfo error %d: %s\n", err, ok_to_fail?"OK":"FAILED");
- else {
- printf("qdisk votes %d\n", qinfo.votes);
- printf("state %d\n", qinfo.state);
- printf("name %s\n", qinfo.name);
- printf("\n");
- }
-}
-
-int main(int argc, char *argv[])
-{
- int pollcount=0, polltime=1;
- int err;
-
- if ( (err=cmanquorum_initialize(&handle, NULL)) != CS_OK) {
- fprintf(stderr, "cmanquorum_initialize FAILED: %d\n", err);
- return -1;
- }
-
- print_info(1);
-
- if (argc >= 2 && atoi(argv[1])) {
- pollcount = atoi(argv[1]);
- }
- if (argc >= 3 && atoi(argv[2])) {
- polltime = atoi(argv[2]);
- }
-
- if (argc >= 2) {
- if ( (err=cmanquorum_qdisk_register(handle, "QDISK", 4)) != CS_OK)
- fprintf(stderr, "qdisk_register FAILED: %d\n", err);
-
- while (pollcount--) {
- print_info(0);
- if ((err=cmanquorum_qdisk_poll(handle, 1)) != CS_OK)
- fprintf(stderr, "qdisk poll FAILED: %d\n", err);
- print_info(0);
- sleep(polltime);
- }
- if ((err= cmanquorum_qdisk_unregister(handle)) != CS_OK)
- fprintf(stderr, "qdisk unregister FAILED: %d\n", err);
- }
- print_info(1);
-
- return 0;
-}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-01-26 13:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-26 13:14 cluster: master - cman: Remove quorum service & use votequorum from corosync Christine Caulfield
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).