public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: David Teigland <teigland@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: fence: master - fenced: use quorum instead of votequorum Date: Fri, 13 Feb 2009 21:52:00 -0000 [thread overview] Message-ID: <20090213215145.905321201EC@lists.fedorahosted.org> (raw) Gitweb: http://git.fedorahosted.org/git/fence.git?p=fence.git;a=commitdiff;h=9e129822c42208bed59340f195b02bfe1ef30d71 Commit: 9e129822c42208bed59340f195b02bfe1ef30d71 Parent: 7cc4bcfa3a5803cf247ccc8ebe3b4b2bc01ffdaa Author: David Teigland <teigland@redhat.com> AuthorDate: Fri Feb 13 15:49:43 2009 -0600 Committer: David Teigland <teigland@redhat.com> CommitterDate: Fri Feb 13 15:49:43 2009 -0600 fenced: use quorum instead of votequorum The "quorum" api is the more general one. Signed-off-by: David Teigland <teigland@redhat.com> --- fence/fenced/Makefile | 2 +- fence/fenced/member_cman.c | 87 ++++++++++++++++++++++++-------------------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/fence/fenced/Makefile b/fence/fenced/Makefile index a999993..a4dd789 100644 --- a/fence/fenced/Makefile +++ b/fence/fenced/Makefile @@ -25,7 +25,7 @@ CFLAGS += -I${incdir} LDFLAGS += -L${ccslibdir} -L${logtlibdir} -lccs -llogthread LDFLAGS += -L${fencelibdir} -lfence -LDFLAGS += -L${corosynclibdir} -lcpg -lcfg -lvotequorum -lpthread +LDFLAGS += -L${corosynclibdir} -lcpg -lcfg -lquorum -lpthread LDFLAGS += -L${libdir} ${TARGET}: ${OBJS} ${LDDEPS} diff --git a/fence/fenced/member_cman.c b/fence/fenced/member_cman.c index 9e52429..176787a 100644 --- a/fence/fenced/member_cman.c +++ b/fence/fenced/member_cman.c @@ -2,11 +2,11 @@ #include "config.h" #include <corosync/corotypes.h> #include <corosync/cfg.h> -#include <corosync/votequorum.h> +#include <corosync/quorum.h> -static corosync_cfg_handle_t ch; -static votequorum_handle_t qh; -static votequorum_node_t quorum_nodes[MAX_NODES]; +static corosync_cfg_handle_t ch; +static quorum_handle_t qh; +static uint32_t quorum_nodes[MAX_NODES]; static int quorum_node_count; void kick_node_from_cluster(int nodeid) @@ -22,13 +22,13 @@ void kick_node_from_cluster(int nodeid) } } -static int is_member(votequorum_node_t *node_list, int count, int nodeid) +static int is_member(uint32_t *node_list, int count, uint32_t nodeid) { int i; for (i = 0; i < count; i++) { - if (node_list[i].nodeid == nodeid) - return (node_list[i].state == NODESTATE_MEMBER); + if (node_list[i] == nodeid) + return 1; } return 0; } @@ -38,7 +38,7 @@ int is_cluster_member(int nodeid) int rv; /* Note: in fence delay loop we aren't processing callbacks so won't - have dispatched any votequorum callbacks */ + have dispatched any quorum callbacks */ update_cluster(); rv = is_member(quorum_nodes, quorum_node_count, nodeid); @@ -48,9 +48,9 @@ int is_cluster_member(int nodeid) return rv; } -static void quorum_callback(votequorum_handle_t h, uint64_t context, - uint32_t quorate, uint32_t node_list_entries, - votequorum_node_t node_list[]) +static void quorum_callback(quorum_handle_t h, uint32_t quorate, + uint64_t ring_seq, uint32_t node_list_entries, + uint32_t *node_list) { int prev_quorate = cluster_quorate; int i; @@ -60,29 +60,24 @@ static void quorum_callback(votequorum_handle_t h, uint64_t context, quorum_node_count = 0; memset(&quorum_nodes, 0, sizeof(quorum_nodes)); - 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++; - } - } + for (i = 0; i < node_list_entries; i++) + quorum_nodes[quorum_node_count++] = node_list[i]; /* domain may have been waiting for quorum */ if (!prev_quorate && cluster_quorate) process_fd_changes(); } -static votequorum_callbacks_t quorum_callbacks = +static quorum_callbacks_t quorum_callbacks = { - .votequorum_notify_fn = quorum_callback, + .quorum_notify_fn = quorum_callback, }; void process_cluster(int ci) { cs_error_t err; - err = votequorum_dispatch(qh, CS_DISPATCH_ALL); + err = quorum_dispatch(qh, CS_DISPATCH_ALL); if (err != CS_OK) cluster_dead(0); } @@ -92,34 +87,33 @@ void update_cluster(void) { cs_error_t err; - err = votequorum_dispatch(qh, CS_DISPATCH_ONE); + err = quorum_dispatch(qh, CS_DISPATCH_ONE); if (err != CS_OK) cluster_dead(0); } int setup_cluster(void) { - struct votequorum_info qinfo; cs_error_t err; - int fd, rv; + int fd; - err = votequorum_initialize(&qh, &quorum_callbacks); - if (err != CS_OK) + err = quorum_initialize(&qh, &quorum_callbacks); + if (err != CS_OK) { + log_error("quorum init error %d", err); return -1; + } - err = votequorum_fd_get(qh, &fd); - if (err != CS_OK) - goto fail; - - err = votequorum_getinfo(qh, 0, &qinfo); - if (err != CS_OK) + err = quorum_fd_get(qh, &fd); + if (err != CS_OK) { + log_error("quorum fd_get error %d", err); goto fail; - our_nodeid = qinfo.node_id; - log_debug("our_nodeid %d", our_nodeid); + } - err = votequorum_trackstart(qh, 0, CS_TRACK_CURRENT); - if (err != CS_OK) + err = quorum_trackstart(qh, CS_TRACK_CURRENT); + if (err != CS_OK) { + log_error("quorum trackstart error %d", err); goto fail; + } quorum_node_count = 0; memset(&quorum_nodes, 0, sizeof(quorum_nodes)); @@ -128,14 +122,14 @@ int setup_cluster(void) return fd; fail: - votequorum_finalize(qh); + quorum_finalize(qh); return -1; } void close_cluster(void) { - votequorum_trackstop(qh); - votequorum_finalize(qh); + quorum_trackstop(qh); + quorum_finalize(qh); } static void shutdown_callback(corosync_cfg_handle_t h, @@ -172,18 +166,31 @@ void process_cluster_cfg(int ci) int setup_cluster_cfg(void) { cs_error_t err; + unsigned int nodeid; int fd; err = corosync_cfg_initialize(&ch, &cfg_callbacks); - if (err != CS_OK) + if (err != CS_OK) { + log_error("corosync cfg init error %d", err); return -1; + } err = corosync_cfg_fd_get(ch, &fd); if (err != CS_OK) { + log_error("corosync cfg fd_get error %d", err); corosync_cfg_finalize(ch); return -1; } + err = corosync_cfg_local_get(ch, &nodeid); + if (err != CS_OK) { + log_error("corosync cfg local_get error %d", err); + corosync_cfg_finalize(ch); + return -1; + } + our_nodeid = nodeid; + log_debug("our_nodeid %d", our_nodeid); + return fd; }
reply other threads:[~2009-02-13 21:52 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20090213215145.905321201EC@lists.fedorahosted.org \ --to=teigland@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).