From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx> this is a preparation commit for the next changes. right now it is no more than an alias to ALIVE. CAST_VOTE is required to support master/slave feature from qdevice. Effectively a quorum device can be: Not registered / registered (connected to API but nothing else is happening) if registered: Not alive / alive (quorum device is petting the API via poll and timer is running) if alive: Not voting (slave) / voting (master) Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx> --- :100644 100644 a32609a... 18362d0... M exec/votequorum.c :100644 100644 7214bbc... e60a8cb... M include/corosync/ipc_votequorum.h :100644 100644 95e6f4f... 792f81d... M include/corosync/votequorum.h :100644 100644 28d111e... d4c9208... M lib/votequorum.c :100644 100644 d499d73... 180c283... M man/votequorum_getinfo.3.in :100644 100644 d00e206... 9d6eeeb... M man/votequorum_qdevice_getinfo.3.in :100644 100644 9bc3b2d... affbcec... M test/testvotequorum2.c :100644 100644 574eef5... 8055a20... M tools/corosync-quorumtool.c exec/votequorum.c | 25 +++++++++++++++++++++---- include/corosync/ipc_votequorum.h | 2 ++ include/corosync/votequorum.h | 2 ++ lib/votequorum.c | 1 + man/votequorum_getinfo.3.in | 1 + man/votequorum_qdevice_getinfo.3.in | 1 + test/testvotequorum2.c | 1 + tools/corosync-quorumtool.c | 2 +- 8 files changed, 30 insertions(+), 5 deletions(-) diff --git a/exec/votequorum.c b/exec/votequorum.c index a32609a..18362d0 100644 --- a/exec/votequorum.c +++ b/exec/votequorum.c @@ -159,6 +159,7 @@ static int votequorum_exec_send_reconfigure(uint8_t param, unsigned int nodeid, #define NODE_FLAGS_FIRST 8 #define NODE_FLAGS_QDEVICE_REGISTERED 16 #define NODE_FLAGS_QDEVICE_ALIVE 32 +#define NODE_FLAGS_QDEVICE_CAST_VOTE 64 #define NODEID_QDEVICE 0 @@ -545,13 +546,14 @@ static int check_low_node_id_partition(void) static void decode_flags(uint32_t flags) { log_printf(LOGSYS_LEVEL_DEBUG, - "flags: quorate: %s Leaving: %s WFA Status: %s First: %s Qdevice: %s QdeviceState: %s", + "flags: quorate: %s Leaving: %s WFA Status: %s First: %s Qdevice: %s QdeviceAlive: %s QdeviceCastVote: %s", (flags & NODE_FLAGS_QUORATE)?"Yes":"No", (flags & NODE_FLAGS_LEAVING)?"Yes":"No", (flags & NODE_FLAGS_WFASTATUS)?"Yes":"No", (flags & NODE_FLAGS_FIRST)?"Yes":"No", (flags & NODE_FLAGS_QDEVICE_REGISTERED)?"Yes":"No", - (flags & NODE_FLAGS_QDEVICE_ALIVE)?"Yes":"No"); + (flags & NODE_FLAGS_QDEVICE_ALIVE)?"Yes":"No", + (flags & NODE_FLAGS_QDEVICE_CAST_VOTE)?"Yes":"No"); } static void update_wait_for_all_status(uint8_t wfa_status) @@ -1924,6 +1926,7 @@ static void qdevice_timer_fn(void *arg) qdevice->state = NODESTATE_DEAD; us->flags &= ~NODE_FLAGS_QDEVICE_ALIVE; + us->flags &= ~NODE_FLAGS_QDEVICE_CAST_VOTE; log_printf(LOGSYS_LEVEL_INFO, "lost contact with quorum device %s", qdevice_name); votequorum_exec_send_nodeinfo(us->node_id); @@ -1965,7 +1968,9 @@ static void message_handler_req_lib_votequorum_getinfo (void *conn, const void * } if (((qdevice_is_registered) && (qdevice->state == NODESTATE_MEMBER)) || - ((node->flags & NODE_FLAGS_QDEVICE_REGISTERED) && (node->flags & NODE_FLAGS_QDEVICE_ALIVE))) { + ((node->flags & NODE_FLAGS_QDEVICE_REGISTERED) && + (node->flags & NODE_FLAGS_QDEVICE_ALIVE) && + (node->flags & NODE_FLAGS_QDEVICE_CAST_VOTE))) { total_votes += qdevice->votes; } @@ -2003,6 +2008,9 @@ static void message_handler_req_lib_votequorum_getinfo (void *conn, const void * if (node->flags & NODE_FLAGS_QDEVICE_ALIVE) { res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_QDEVICE_ALIVE; } + if (node->flags & NODE_FLAGS_QDEVICE_CAST_VOTE) { + res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_QDEVICE_CAST_VOTE; + } } else { error = CS_ERR_NOT_EXIST; } @@ -2242,6 +2250,7 @@ static void message_handler_req_lib_votequorum_qdevice_unregister (void *conn, qdevice_is_registered = 0; us->flags &= ~NODE_FLAGS_QDEVICE_REGISTERED; us->flags &= ~NODE_FLAGS_QDEVICE_ALIVE; + us->flags &= ~NODE_FLAGS_QDEVICE_CAST_VOTE; qdevice->state = NODESTATE_DEAD; votequorum_exec_send_nodeinfo(us->node_id); votequorum_exec_send_qdevice_reg(VOTEQUORUM_QDEVICE_OPERATION_UNREGISTER, @@ -2316,12 +2325,14 @@ static void message_handler_req_lib_votequorum_qdevice_poll (void *conn, if (qdevice->state == NODESTATE_DEAD) { qdevice->state = NODESTATE_MEMBER; us->flags |= NODE_FLAGS_QDEVICE_ALIVE; + us->flags |= NODE_FLAGS_QDEVICE_CAST_VOTE; votequorum_exec_send_nodeinfo(us->node_id); } } else { if (qdevice->state == NODESTATE_MEMBER) { qdevice->state = NODESTATE_DEAD; us->flags &= ~NODE_FLAGS_QDEVICE_ALIVE; + us->flags &= ~NODE_FLAGS_QDEVICE_CAST_VOTE; votequorum_exec_send_nodeinfo(us->node_id); } } @@ -2358,14 +2369,18 @@ static void message_handler_req_lib_votequorum_qdevice_getinfo (void *conn, node = find_node_by_nodeid(req_lib_votequorum_qdevice_getinfo->nodeid); if ((node) && (node->flags & NODE_FLAGS_QDEVICE_REGISTERED)) { - int alive_status = 0; + int alive_status = 0, vote_status = 0; if (node->flags & NODE_FLAGS_QDEVICE_ALIVE) { alive_status = 1; } + if (node->flags & NODE_FLAGS_QDEVICE_CAST_VOTE) { + vote_status = 1; + } log_printf(LOGSYS_LEVEL_DEBUG, "got qdevice_getinfo node %u alive_status %d", nodeid, alive_status); res_lib_votequorum_qdevice_getinfo.votes = qdevice->votes; res_lib_votequorum_qdevice_getinfo.alive = alive_status; + res_lib_votequorum_qdevice_getinfo.vote = vote_status; strcpy(res_lib_votequorum_qdevice_getinfo.name, qdevice_name); } else { error = CS_ERR_NOT_EXIST; @@ -2376,8 +2391,10 @@ static void message_handler_req_lib_votequorum_qdevice_getinfo (void *conn, res_lib_votequorum_qdevice_getinfo.votes = qdevice->votes; if (qdevice->state == NODESTATE_MEMBER) { res_lib_votequorum_qdevice_getinfo.alive = 1; + res_lib_votequorum_qdevice_getinfo.vote = 1; } else { res_lib_votequorum_qdevice_getinfo.alive = 0; + res_lib_votequorum_qdevice_getinfo.vote = 0; } strcpy(res_lib_votequorum_qdevice_getinfo.name, qdevice_name); } else { diff --git a/include/corosync/ipc_votequorum.h b/include/corosync/ipc_votequorum.h index 7214bbc..e60a8cb 100644 --- a/include/corosync/ipc_votequorum.h +++ b/include/corosync/ipc_votequorum.h @@ -125,6 +125,7 @@ struct res_lib_votequorum_status { #define VOTEQUORUM_INFO_LEAVE_REMOVE 32 #define VOTEQUORUM_INFO_QDEVICE_REGISTERED 64 #define VOTEQUORUM_INFO_QDEVICE_ALIVE 128 +#define VOTEQUORUM_INFO_QDEVICE_CAST_VOTE 256 struct res_lib_votequorum_getinfo { struct qb_ipc_response_header header __attribute__((aligned(8))); @@ -142,6 +143,7 @@ struct res_lib_votequorum_qdevice_getinfo { struct qb_ipc_response_header header __attribute__((aligned(8))); unsigned int votes; unsigned int alive; + unsigned int vote; char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; }; diff --git a/include/corosync/votequorum.h b/include/corosync/votequorum.h index 95e6f4f..792f81d 100644 --- a/include/corosync/votequorum.h +++ b/include/corosync/votequorum.h @@ -50,6 +50,7 @@ typedef uint64_t votequorum_handle_t; #define VOTEQUORUM_INFO_LEAVE_REMOVE 32 #define VOTEQUORUM_INFO_QDEVICE_REGISTERED 64 #define VOTEQUORUM_INFO_QDEVICE_ALIVE 128 +#define VOTEQUORUM_INFO_QDEVICE_CAST_VOTE 256 #define VOTEQUORUM_NODEID_QDEVICE 0 #define VOTEQUORUM_MAX_QDEVICE_NAME_LEN 255 @@ -74,6 +75,7 @@ struct votequorum_info { struct votequorum_qdevice_info { unsigned int votes; unsigned int alive; + unsigned int vote; char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; }; diff --git a/lib/votequorum.c b/lib/votequorum.c index 28d111e..d4c9208 100644 --- a/lib/votequorum.c +++ b/lib/votequorum.c @@ -726,6 +726,7 @@ cs_error_t votequorum_qdevice_getinfo ( qinfo->votes = res_lib_votequorum_qdevice_getinfo.votes; qinfo->alive = res_lib_votequorum_qdevice_getinfo.alive; + qinfo->vote = res_lib_votequorum_qdevice_getinfo.vote; strcpy(qinfo->name, res_lib_votequorum_qdevice_getinfo.name); diff --git a/man/votequorum_getinfo.3.in b/man/votequorum_getinfo.3.in index d499d73..180c283 100644 --- a/man/votequorum_getinfo.3.in +++ b/man/votequorum_getinfo.3.in @@ -82,6 +82,7 @@ The flags are defined as: #define VOTEQUORUM_INFO_LEAVE_REMOVE 32 #define VOTEQUORUM_INFO_QDEVICE_REGISTERED 64 #define VOTEQUORUM_INFO_QDEVICE_ALIVE 128 +#define VOTEQUORUM_INFO_QDEVICE_CAST_VOTE 256 .fi .PP diff --git a/man/votequorum_qdevice_getinfo.3.in b/man/votequorum_qdevice_getinfo.3.in index d00e206..9d6eeeb 100644 --- a/man/votequorum_qdevice_getinfo.3.in +++ b/man/votequorum_qdevice_getinfo.3.in @@ -47,6 +47,7 @@ Returns information about the quorum device in the following structure: struct votequorum_qdevice_info { unsigned int votes; unsigned int alive; + unsigned int vote; char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; }; .fi diff --git a/test/testvotequorum2.c b/test/testvotequorum2.c index 9bc3b2d..affbcec 100644 --- a/test/testvotequorum2.c +++ b/test/testvotequorum2.c @@ -54,6 +54,7 @@ static void print_info(int ok_to_fail) else { printf("qdevice votes %d\n", qinfo.votes); printf("alive %d\n", qinfo.alive); + printf("vote %d\n", qinfo.vote); printf("name %s\n", qinfo.name); printf("\n"); } diff --git a/tools/corosync-quorumtool.c b/tools/corosync-quorumtool.c index 574eef5..8055a20 100644 --- a/tools/corosync-quorumtool.c +++ b/tools/corosync-quorumtool.c @@ -354,7 +354,7 @@ static void display_nodes_data(uint32_t nodeid, nodeid_format_t nodeid_format, n printf("0x%08x ", VOTEQUORUM_NODEID_QDEVICE); } print_uint32_padded(qinfo.votes); - printf("%s (%s)\n", qinfo.name, qinfo.alive?"Alive":"Not alive"); + printf("%s (%s/%s)\n", qinfo.name, qinfo.alive?"Alive":"Not alive", qinfo.vote?"Voting":"Not voting"); } } } -- 1.7.7.6 _______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss