public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* fence: master - fence_tool: replace cman with votequorum
@ 2009-02-11 21:44 David Teigland
0 siblings, 0 replies; only message in thread
From: David Teigland @ 2009-02-11 21:44 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/fence.git?p=fence.git;a=commitdiff;h=7cc4bcfa3a5803cf247ccc8ebe3b4b2bc01ffdaa
Commit: 7cc4bcfa3a5803cf247ccc8ebe3b4b2bc01ffdaa
Parent: 27ef61602c6de5d04ddecc008af7be57c2763609
Author: David Teigland <teigland@redhat.com>
AuthorDate: Wed Feb 11 15:42:06 2009 -0600
Committer: David Teigland <teigland@redhat.com>
CommitterDate: Wed Feb 11 15:42:06 2009 -0600
fence_tool: replace cman with votequorum
libcman calls have been replaced with libvotequorum
Signed-off-by: David Teigland <teigland@redhat.com>
---
fence/fence_tool/Makefile | 8 ++-
fence/fence_tool/fence_tool.c | 115 ++++++++++++++++++++++++-----------------
2 files changed, 72 insertions(+), 51 deletions(-)
diff --git a/fence/fence_tool/Makefile b/fence/fence_tool/Makefile
index 51413fc..0410e58 100644
--- a/fence/fence_tool/Makefile
+++ b/fence/fence_tool/Makefile
@@ -13,11 +13,13 @@ include $(OBJDIR)/make/uninstall.mk
OBJS=fence_tool.o
CFLAGS += -D_FILE_OFFSET_BITS=64
-CFLAGS += -I${ccsincdir} -I${cmanincdir}
+CFLAGS += -I${corosyncincdir}
+CFLAGS += -I${ccsincdir}
CFLAGS += -I$(S)/../libfenced -I$(S)/../include
-CFLAGS += -I${incdir}
+CFLAGS += -I${incdir}
-LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -lccs -lcman
+LDFLAGS += -L${corosynclibdir} -lvotequorum
+LDFLAGS += -L${ccslibdir} -lccs
LDFLAGS += -L../libfenced -lfenced
LDFLAGS += -L${libdir}
diff --git a/fence/fence_tool/fence_tool.c b/fence/fence_tool/fence_tool.c
index f5a857e..436db02 100644
--- a/fence/fence_tool/fence_tool.c
+++ b/fence/fence_tool/fence_tool.c
@@ -18,8 +18,9 @@
#include "ccs.h"
#include "copyright.cf"
-#include "libcman.h"
#include "libfenced.h"
+#include <corosync/corotypes.h>
+#include <corosync/votequorum.h>
#define OP_JOIN 1
#define OP_LEAVE 2
@@ -32,8 +33,8 @@
int all_nodeids[MAX_NODES];
int all_nodeids_count;
-cman_node_t cman_nodes[MAX_NODES];
-int cman_nodes_count;
+static votequorum_node_t quorum_nodes[MAX_NODES];
+static int quorum_node_count;
struct fenced_node nodes[MAX_NODES];
char *prog_name;
int operation;
@@ -223,25 +224,50 @@ static void read_ccs_nodeids(int cd)
}
}
-static int all_nodeids_are_members(cman_handle_t ch)
+static void quorum_callback(votequorum_handle_t h, uint64_t context,
+ uint32_t quorate, uint32_t node_list_entries,
+ votequorum_node_t node_list[])
{
- int i, j, rv, found;
+ int i;
- memset(&cman_nodes, 0, sizeof(cman_nodes));
- cman_nodes_count = 0;
+ for (i = 0; i < node_list_entries; i++) {
+ if (node_list[i].state == NODESTATE_MEMBER) {
+ memcpy(&quorum_nodes[quorum_node_count],
+ &node_list[i], sizeof(votequorum_node_t));
+ quorum_node_count++;
+ }
+ }
+}
- rv = cman_get_nodes(ch, MAX_NODES, &cman_nodes_count, cman_nodes);
- if (rv < 0) {
- printf("cman_get_nodes error %d %d\n", rv, errno);
- return 0;
+static int all_nodeids_are_members(votequorum_handle_t qh)
+{
+ cs_error_t err;
+ int i, j, found;
+
+ memset(&quorum_nodes, 0, sizeof(quorum_nodes));
+ quorum_node_count = 0;
+
+ err = votequorum_trackstart(qh, 0, CS_TRACK_CURRENT);
+ if (err != CS_OK) {
+ printf("votequorum_trackstart error %d %d\n", err, errno);
+ return -1;
+ }
+
+ err = votequorum_dispatch(qh, CS_DISPATCH_ONE);
+ if (err != CS_OK) {
+ printf("votequorum_dispatch error %d %d\n", err, errno);
+ votequorum_trackstop(qh);
+ return -1;
}
+ votequorum_trackstop(qh);
+
for (i = 0; i < all_nodeids_count; i++) {
found = 0;
- for (j = 0; j < cman_nodes_count; j++) {
- if (cman_nodes[j].cn_nodeid == all_nodeids[i] &&
- cman_nodes[j].cn_member) {
+ for (j = 0; j < quorum_node_count; j++) {
+ if (quorum_nodes[j].nodeid == all_nodeids[i] &&
+ quorum_nodes[j].state == NODESTATE_MEMBER) {
found = 1;
break;
}
@@ -253,68 +279,59 @@ static int all_nodeids_are_members(cman_handle_t ch)
return 1;
}
-static void wait_cman(void)
+static votequorum_callbacks_t quorum_callbacks =
+{
+ .votequorum_notify_fn = quorum_callback,
+};
+
+static void wait_quorum(void)
{
- cman_handle_t ch;
- int try_init = 0, try_active = 0, try_quorate = 0;
+ votequorum_handle_t qh;
+ struct votequorum_info qinfo;
+ cs_error_t err;
+ int try_init = 0, try_quorate = 0;
int try_ccs = 0, try_members = 0;
int rv, cd;
while (1) {
- ch = cman_init(NULL);
- if (ch)
+ err = votequorum_initialize(&qh, &quorum_callbacks);
+ if (err == CS_OK)
break;
if (inquorate_fail)
goto fail;
if (try_init++ >= wait_timeout) {
- printf("%s: timed out waiting for cman init\n",
+ printf("%s: timed out waiting for quorum init\n",
prog_name);
goto fail;
}
if (!(try_init % 10))
- printf("%s: waiting for cman to start\n", prog_name);
+ printf("%s: waiting for quorum init\n", prog_name);
sleep(1);
}
while (1) {
- rv = cman_is_active(ch);
- if (rv)
- break;
-
- if (inquorate_fail)
- goto fail;
-
- if (try_active++ >= wait_timeout) {
- printf("%s: timed out waiting for cman active\n",
- prog_name);
+ err = votequorum_getinfo(qh, 0, &qinfo);
+ if (err != CS_OK)
goto fail;
- }
-
- if (!(try_active % 10))
- printf("%s: waiting for cman active\n", prog_name);
- sleep(1);
- }
- while (1) {
- rv = cman_is_quorate(ch);
- if (rv)
+ if (qinfo.quorum)
break;
if (inquorate_fail)
goto fail;
if (try_quorate++ >= wait_timeout) {
- printf("%s: timed out waiting for cman quorum\n",
+ printf("%s: timed out waiting for quorum\n",
prog_name);
goto fail;
}
if (!(try_quorate % 10))
- printf("%s: waiting for cman quorum\n", prog_name);
+ printf("%s: waiting for quorum\n", prog_name);
sleep(1);
}
@@ -341,8 +358,10 @@ static void wait_cman(void)
read_ccs_nodeids(cd);
while (1) {
- rv = all_nodeids_are_members(ch);
- if (rv)
+ rv = all_nodeids_are_members(qh);
+ if (rv < 0)
+ goto fail;
+ if (rv > 0)
break;
if (try_members++ >= wait_members)
@@ -356,12 +375,12 @@ static void wait_cman(void)
out:
ccs_disconnect(cd);
- cman_finish(ch);
+ votequorum_finalize(qh);
return;
fail:
- if (ch)
- cman_finish(ch);
+ if (qh)
+ votequorum_finalize(qh);
exit(EXIT_FAILURE);
}
@@ -369,7 +388,7 @@ static void do_join(int argc, char *argv[])
{
int rv;
- wait_cman();
+ wait_quorum();
rv = fenced_join();
if (rv < 0)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-02-11 21:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-11 21:44 fence: master - fence_tool: replace cman with votequorum David Teigland
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).