From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx> STATE is confusing and overloaded term in votequorum as it's used for nodes and other bits. make the name unique and ALIVE means that the qdevice is heartbeating to votequorum. improve display of the status in tools and tests. Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx> --- :100644 100644 cdb03b9... a32609a... M exec/votequorum.c :100644 100644 0036a5c... 7214bbc... M include/corosync/ipc_votequorum.h :100644 100644 ba2434b... 95e6f4f... M include/corosync/votequorum.h :100644 100644 37ed0a4... 28d111e... M lib/votequorum.c :100644 100644 5ffc26f... d499d73... M man/votequorum_getinfo.3.in :100644 100644 ec7c1f2... d00e206... M man/votequorum_qdevice_getinfo.3.in :100644 100644 b58d8ee... 9bc3b2d... M test/testvotequorum2.c :100644 100644 43b9b64... 574eef5... M tools/corosync-quorumtool.c exec/votequorum.c | 35 +++++++++++++++++------------------ include/corosync/ipc_votequorum.h | 3 ++- include/corosync/votequorum.h | 3 ++- lib/votequorum.c | 2 +- man/votequorum_getinfo.3.in | 2 ++ man/votequorum_qdevice_getinfo.3.in | 2 +- test/testvotequorum2.c | 2 +- tools/corosync-quorumtool.c | 2 +- 8 files changed, 27 insertions(+), 24 deletions(-) diff --git a/exec/votequorum.c b/exec/votequorum.c index cdb03b9..a32609a 100644 --- a/exec/votequorum.c +++ b/exec/votequorum.c @@ -158,7 +158,7 @@ static int votequorum_exec_send_reconfigure(uint8_t param, unsigned int nodeid, #define NODE_FLAGS_WFASTATUS 4 #define NODE_FLAGS_FIRST 8 #define NODE_FLAGS_QDEVICE_REGISTERED 16 -#define NODE_FLAGS_QDEVICE_STATE 32 +#define NODE_FLAGS_QDEVICE_ALIVE 32 #define NODEID_QDEVICE 0 @@ -551,7 +551,7 @@ static void decode_flags(uint32_t flags) (flags & NODE_FLAGS_WFASTATUS)?"Yes":"No", (flags & NODE_FLAGS_FIRST)?"Yes":"No", (flags & NODE_FLAGS_QDEVICE_REGISTERED)?"Yes":"No", - (flags & NODE_FLAGS_QDEVICE_STATE)?"Yes":"No"); + (flags & NODE_FLAGS_QDEVICE_ALIVE)?"Yes":"No"); } static void update_wait_for_all_status(uint8_t wfa_status) @@ -1923,7 +1923,7 @@ static void qdevice_timer_fn(void *arg) } qdevice->state = NODESTATE_DEAD; - us->flags &= ~NODE_FLAGS_QDEVICE_STATE; + us->flags &= ~NODE_FLAGS_QDEVICE_ALIVE; log_printf(LOGSYS_LEVEL_INFO, "lost contact with quorum device %s", qdevice_name); votequorum_exec_send_nodeinfo(us->node_id); @@ -1965,7 +1965,7 @@ 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_STATE))) { + ((node->flags & NODE_FLAGS_QDEVICE_REGISTERED) && (node->flags & NODE_FLAGS_QDEVICE_ALIVE))) { total_votes += qdevice->votes; } @@ -2000,6 +2000,9 @@ static void message_handler_req_lib_votequorum_getinfo (void *conn, const void * if (node->flags & NODE_FLAGS_QDEVICE_REGISTERED) { res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_QDEVICE_REGISTERED; } + if (node->flags & NODE_FLAGS_QDEVICE_ALIVE) { + res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_QDEVICE_ALIVE; + } } else { error = CS_ERR_NOT_EXIST; } @@ -2238,7 +2241,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_STATE; + us->flags &= ~NODE_FLAGS_QDEVICE_ALIVE; qdevice->state = NODESTATE_DEAD; votequorum_exec_send_nodeinfo(us->node_id); votequorum_exec_send_qdevice_reg(VOTEQUORUM_QDEVICE_OPERATION_UNREGISTER, @@ -2312,13 +2315,13 @@ static void message_handler_req_lib_votequorum_qdevice_poll (void *conn, if (req_lib_votequorum_qdevice_poll->state) { if (qdevice->state == NODESTATE_DEAD) { qdevice->state = NODESTATE_MEMBER; - us->flags |= NODE_FLAGS_QDEVICE_STATE; + us->flags |= NODE_FLAGS_QDEVICE_ALIVE; votequorum_exec_send_nodeinfo(us->node_id); } } else { if (qdevice->state == NODESTATE_MEMBER) { qdevice->state = NODESTATE_DEAD; - us->flags &= ~NODE_FLAGS_QDEVICE_STATE; + us->flags &= ~NODE_FLAGS_QDEVICE_ALIVE; votequorum_exec_send_nodeinfo(us->node_id); } } @@ -2355,18 +2358,14 @@ 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 state = 0; + int alive_status = 0; - if (node->flags & NODE_FLAGS_QDEVICE_STATE) { - state = 1; + if (node->flags & NODE_FLAGS_QDEVICE_ALIVE) { + alive_status = 1; } - log_printf(LOGSYS_LEVEL_DEBUG, "got qdevice_getinfo node %u state %d", nodeid, state); + log_printf(LOGSYS_LEVEL_DEBUG, "got qdevice_getinfo node %u alive_status %d", nodeid, alive_status); res_lib_votequorum_qdevice_getinfo.votes = qdevice->votes; - if (state) { - res_lib_votequorum_qdevice_getinfo.state = 1; - } else { - res_lib_votequorum_qdevice_getinfo.state = 0; - } + res_lib_votequorum_qdevice_getinfo.alive = alive_status; strcpy(res_lib_votequorum_qdevice_getinfo.name, qdevice_name); } else { error = CS_ERR_NOT_EXIST; @@ -2376,9 +2375,9 @@ static void message_handler_req_lib_votequorum_qdevice_getinfo (void *conn, log_printf(LOGSYS_LEVEL_DEBUG, "got qdevice_getinfo node %u state %d", us->node_id, qdevice->state); res_lib_votequorum_qdevice_getinfo.votes = qdevice->votes; if (qdevice->state == NODESTATE_MEMBER) { - res_lib_votequorum_qdevice_getinfo.state = 1; + res_lib_votequorum_qdevice_getinfo.alive = 1; } else { - res_lib_votequorum_qdevice_getinfo.state = 0; + res_lib_votequorum_qdevice_getinfo.alive = 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 0036a5c..7214bbc 100644 --- a/include/corosync/ipc_votequorum.h +++ b/include/corosync/ipc_votequorum.h @@ -124,6 +124,7 @@ struct res_lib_votequorum_status { #define VOTEQUORUM_INFO_AUTO_TIE_BREAKER 16 #define VOTEQUORUM_INFO_LEAVE_REMOVE 32 #define VOTEQUORUM_INFO_QDEVICE_REGISTERED 64 +#define VOTEQUORUM_INFO_QDEVICE_ALIVE 128 struct res_lib_votequorum_getinfo { struct qb_ipc_response_header header __attribute__((aligned(8))); @@ -140,7 +141,7 @@ struct res_lib_votequorum_getinfo { struct res_lib_votequorum_qdevice_getinfo { struct qb_ipc_response_header header __attribute__((aligned(8))); unsigned int votes; - unsigned int state; + unsigned int alive; char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; }; diff --git a/include/corosync/votequorum.h b/include/corosync/votequorum.h index ba2434b..95e6f4f 100644 --- a/include/corosync/votequorum.h +++ b/include/corosync/votequorum.h @@ -49,6 +49,7 @@ typedef uint64_t votequorum_handle_t; #define VOTEQUORUM_INFO_AUTO_TIE_BREAKER 16 #define VOTEQUORUM_INFO_LEAVE_REMOVE 32 #define VOTEQUORUM_INFO_QDEVICE_REGISTERED 64 +#define VOTEQUORUM_INFO_QDEVICE_ALIVE 128 #define VOTEQUORUM_NODEID_QDEVICE 0 #define VOTEQUORUM_MAX_QDEVICE_NAME_LEN 255 @@ -72,7 +73,7 @@ struct votequorum_info { struct votequorum_qdevice_info { unsigned int votes; - unsigned int state; + unsigned int alive; char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; }; diff --git a/lib/votequorum.c b/lib/votequorum.c index 37ed0a4..28d111e 100644 --- a/lib/votequorum.c +++ b/lib/votequorum.c @@ -725,7 +725,7 @@ cs_error_t votequorum_qdevice_getinfo ( error = res_lib_votequorum_qdevice_getinfo.header.error; qinfo->votes = res_lib_votequorum_qdevice_getinfo.votes; - qinfo->state = res_lib_votequorum_qdevice_getinfo.state; + qinfo->alive = res_lib_votequorum_qdevice_getinfo.alive; strcpy(qinfo->name, res_lib_votequorum_qdevice_getinfo.name); diff --git a/man/votequorum_getinfo.3.in b/man/votequorum_getinfo.3.in index 5ffc26f..d499d73 100644 --- a/man/votequorum_getinfo.3.in +++ b/man/votequorum_getinfo.3.in @@ -81,6 +81,8 @@ The flags are defined as: #define VOTEQUORUM_INFO_AUTO_TIE_BREAKER 16 #define VOTEQUORUM_INFO_LEAVE_REMOVE 32 #define VOTEQUORUM_INFO_QDEVICE_REGISTERED 64 +#define VOTEQUORUM_INFO_QDEVICE_ALIVE 128 + .fi .PP The members starting node_ hold information specific to the requested nodeid, the other are diff --git a/man/votequorum_qdevice_getinfo.3.in b/man/votequorum_qdevice_getinfo.3.in index ec7c1f2..d00e206 100644 --- a/man/votequorum_qdevice_getinfo.3.in +++ b/man/votequorum_qdevice_getinfo.3.in @@ -46,7 +46,7 @@ Returns information about the quorum device in the following structure: .nf struct votequorum_qdevice_info { unsigned int votes; - unsigned int state; + unsigned int alive; char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; }; .fi diff --git a/test/testvotequorum2.c b/test/testvotequorum2.c index b58d8ee..9bc3b2d 100644 --- a/test/testvotequorum2.c +++ b/test/testvotequorum2.c @@ -53,7 +53,7 @@ static void print_info(int ok_to_fail) fprintf(stderr, "votequorum_qdevice_getinfo error %d: %s\n", err, ok_to_fail?"OK":"FAILED"); else { printf("qdevice votes %d\n", qinfo.votes); - printf("state %d\n", qinfo.state); + printf("alive %d\n", qinfo.alive); printf("name %s\n", qinfo.name); printf("\n"); } diff --git a/tools/corosync-quorumtool.c b/tools/corosync-quorumtool.c index 43b9b64..574eef5 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.state?"Voting":"Not voting"); + printf("%s (%s)\n", qinfo.name, qinfo.alive?"Alive":"Not alive"); } } } -- 1.7.7.6 _______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss