From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx> Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx> --- :100644 100644 c059e0b... d542776... M exec/votequorum.c :100644 100644 d5108e2... c7bb3ed... M include/corosync/ipc_votequorum.h :100644 100644 5703e96... c85f281... M include/corosync/votequorum.h :100644 100644 9944987... daac847... M lib/votequorum.c :100644 100644 efc8ddb... fc2fa4c... M man/votequorum_getinfo.3.in :100644 100644 3fb3060... 7198029... M test/testvotequorum2.c :100644 100644 d309f19... c776cf4... M tools/corosync-quorumtool.c exec/votequorum.c | 57 +++++++++++++++++------------------- include/corosync/ipc_votequorum.h | 18 ++++++----- include/corosync/votequorum.h | 13 ++++---- lib/votequorum.c | 14 ++++---- man/votequorum_getinfo.3.in | 2 +- test/testvotequorum2.c | 2 +- tools/corosync-quorumtool.c | 4 +- 7 files changed, 55 insertions(+), 55 deletions(-) diff --git a/exec/votequorum.c b/exec/votequorum.c index c059e0b..d542776 100644 --- a/exec/votequorum.c +++ b/exec/votequorum.c @@ -62,11 +62,10 @@ static struct corosync_api_v1 *corosync_api; * votequorum global config vars */ -#define DEFAULT_QDEVICE_TIMEOUT 10000 -static char qdevice_name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; +static char qdevice_name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; static struct cluster_node *qdevice = NULL; -static unsigned int qdevice_timeout = DEFAULT_QDEVICE_TIMEOUT; +static unsigned int qdevice_timeout = VOTEQUORUM_QDEVICE_DEFAULT_TIMEOUT; static uint8_t qdevice_can_operate = 1; static void *qdevice_reg_conn = NULL; static uint8_t qdevice_master_wins = 0; @@ -111,13 +110,13 @@ struct req_exec_quorum_reconfigure { struct req_exec_quorum_qdevice_reg { struct qb_ipc_request_header header __attribute__((aligned(8))); uint32_t operation; - char qdevice_name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; + char qdevice_name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; } __attribute__((packed)); struct req_exec_quorum_qdevice_reconfigure { struct qb_ipc_request_header header __attribute__((aligned(8))); - char oldname[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; - char newname[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; + char oldname[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; + char newname[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; } __attribute__((packed)); /* @@ -162,8 +161,6 @@ static int votequorum_exec_send_reconfigure(uint8_t param, unsigned int nodeid, #define NODE_FLAGS_QDEVICE_CAST_VOTE 64 #define NODE_FLAGS_QDEVICE_MASTER_WINS 128 -#define NODEID_QDEVICE 0 - typedef enum { NODESTATE_MEMBER=1, NODESTATE_DEAD, @@ -463,7 +460,7 @@ static struct cluster_node *allocate_node(unsigned int nodeid) memset(cl, 0, sizeof(struct cluster_node)); cl->node_id = nodeid; - if (nodeid != NODEID_QDEVICE) { + if (nodeid != VOTEQUORUM_QDEVICE_NODEID) { node_add_ordered(cl); } @@ -485,7 +482,7 @@ static struct cluster_node *find_node_by_nodeid(unsigned int nodeid) return us; } - if (nodeid == NODEID_QDEVICE) { + if (nodeid == VOTEQUORUM_QDEVICE_NODEID) { LEAVE(); return qdevice; } @@ -930,7 +927,7 @@ static int votequorum_qdevice_is_configured(uint32_t *qdevice_votes) *qdevice_votes = -1; } if (icmap_get_uint32("quorum.device.timeout", &qdevice_timeout) != CS_OK) { - qdevice_timeout = DEFAULT_QDEVICE_TIMEOUT; + qdevice_timeout = VOTEQUORUM_QDEVICE_DEFAULT_TIMEOUT; } update_qdevice_can_operate(1); return 1; @@ -1188,7 +1185,7 @@ static void votequorum_refresh_config( * activate new config */ votequorum_exec_send_nodeinfo(us->node_id); - votequorum_exec_send_nodeinfo(NODEID_QDEVICE); + votequorum_exec_send_nodeinfo(VOTEQUORUM_QDEVICE_NODEID); LEAVE(); } @@ -1264,7 +1261,7 @@ static int votequorum_exec_send_nodeinfo(uint32_t nodeid) req_exec_quorum_nodeinfo.votes = node->votes; req_exec_quorum_nodeinfo.expected_votes = node->expected_votes; req_exec_quorum_nodeinfo.flags = node->flags; - if (nodeid != NODEID_QDEVICE) { + if (nodeid != VOTEQUORUM_QDEVICE_NODEID) { decode_flags(node->flags); } @@ -1356,7 +1353,7 @@ static int votequorum_exec_send_quorum_notification(void *conn, uint64_t context res_lib_votequorum_notification->node_list[i++].state = node->state; } if (us->flags & NODE_FLAGS_QDEVICE_REGISTERED) { - res_lib_votequorum_notification->node_list[i].nodeid = NODEID_QDEVICE; + res_lib_votequorum_notification->node_list[i].nodeid = VOTEQUORUM_QDEVICE_NODEID; res_lib_votequorum_notification->node_list[i++].state = qdevice->state; } res_lib_votequorum_notification->header.id = MESSAGE_RES_VOTEQUORUM_NOTIFICATION; @@ -1430,7 +1427,7 @@ static void message_handler_req_exec_votequorum_qdevice_reconfigure ( if (!strcmp(req_exec_quorum_qdevice_reconfigure->oldname, qdevice_name)) { log_printf(LOGSYS_LEVEL_DEBUG, "Allowing qdevice rename"); - memset(qdevice_name, 0, VOTEQUORUM_MAX_QDEVICE_NAME_LEN); + memset(qdevice_name, 0, VOTEQUORUM_QDEVICE_MAX_NAME_LEN); strcpy(qdevice_name, req_exec_quorum_qdevice_reconfigure->newname); /* * TODO: notify qdevices about name change? @@ -1512,9 +1509,9 @@ static void message_handler_req_exec_votequorum_qdevice_reg ( * check if it is our device or something else */ if ((!strncmp(req_exec_quorum_qdevice_reg->qdevice_name, - qdevice_name, VOTEQUORUM_MAX_QDEVICE_NAME_LEN))) { + qdevice_name, VOTEQUORUM_QDEVICE_MAX_NAME_LEN))) { us->flags |= NODE_FLAGS_QDEVICE_REGISTERED; - votequorum_exec_send_nodeinfo(NODEID_QDEVICE); + votequorum_exec_send_nodeinfo(VOTEQUORUM_QDEVICE_NODEID); votequorum_exec_send_nodeinfo(us->node_id); } else { log_printf(LOGSYS_LEVEL_WARNING, @@ -1539,7 +1536,7 @@ static void message_handler_req_exec_votequorum_qdevice_reg ( } if (wipe_qdevice_name) { - memset(qdevice_name, 0, VOTEQUORUM_MAX_QDEVICE_NAME_LEN); + memset(qdevice_name, 0, VOTEQUORUM_QDEVICE_MAX_NAME_LEN); } break; @@ -1585,7 +1582,7 @@ static void message_handler_req_exec_votequorum_nodeinfo ( req_exec_quorum_nodeinfo->expected_votes, req_exec_quorum_nodeinfo->flags); - if (nodeid != NODEID_QDEVICE) { + if (nodeid != VOTEQUORUM_QDEVICE_NODEID) { decode_flags(req_exec_quorum_nodeinfo->flags); } @@ -1612,7 +1609,7 @@ static void message_handler_req_exec_votequorum_nodeinfo ( old_flags = node->flags; } - if (nodeid == NODEID_QDEVICE) { + if (nodeid == VOTEQUORUM_QDEVICE_NODEID) { struct cluster_node *sender_node = find_node_by_nodeid(sender_nodeid); if ((!cluster_is_quorate) && (sender_node->flags & NODE_FLAGS_QUORATE)) { @@ -1785,13 +1782,13 @@ static char *votequorum_exec_init_fn (struct corosync_api_v1 *api) /* * Allocate a cluster_node for qdevice */ - qdevice = allocate_node(NODEID_QDEVICE); + qdevice = allocate_node(VOTEQUORUM_QDEVICE_NODEID); if (!qdevice) { LEAVE(); return ((char *)"Could not allocate node."); } qdevice->votes = 0; - memset(qdevice_name, 0, VOTEQUORUM_MAX_QDEVICE_NAME_LEN); + memset(qdevice_name, 0, VOTEQUORUM_QDEVICE_MAX_NAME_LEN); /* * Allocate a cluster_node for us @@ -1888,7 +1885,7 @@ static void votequorum_confchg_fn ( memcpy(quorum_members, member_list, sizeof(unsigned int) * member_list_entries); quorum_members_entries = member_list_entries; votequorum_exec_send_nodeinfo(us->node_id); - votequorum_exec_send_nodeinfo(NODEID_QDEVICE); + votequorum_exec_send_nodeinfo(VOTEQUORUM_QDEVICE_NODEID); if (strlen(qdevice_name)) { votequorum_exec_send_qdevice_reg(VOTEQUORUM_QDEVICE_OPERATION_REGISTER, qdevice_name); @@ -2010,7 +2007,7 @@ static void message_handler_req_lib_votequorum_getinfo (void *conn, const void * log_printf(LOGSYS_LEVEL_DEBUG, "got getinfo request on %p for node %u", conn, req_lib_votequorum_getinfo->nodeid); - if (nodeid == NODEID_QDEVICE) { + if (nodeid == VOTEQUORUM_QDEVICE_NODEID) { nodeid = us->node_id; } @@ -2076,7 +2073,7 @@ static void message_handler_req_lib_votequorum_getinfo (void *conn, const void * res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_ALLOW_DOWNSCALE; } - memset(res_lib_votequorum_getinfo.qdevice_name, 0, VOTEQUORUM_MAX_QDEVICE_NAME_LEN); + memset(res_lib_votequorum_getinfo.qdevice_name, 0, VOTEQUORUM_QDEVICE_MAX_NAME_LEN); res_lib_votequorum_getinfo.qdevice_votes = 0; if (node->flags & NODE_FLAGS_QDEVICE_REGISTERED) { @@ -2272,7 +2269,7 @@ static void message_handler_req_lib_votequorum_qdevice_register (void *conn, if (us->flags & NODE_FLAGS_QDEVICE_REGISTERED) { if ((!strncmp(req_lib_votequorum_qdevice_register->name, - qdevice_name, VOTEQUORUM_MAX_QDEVICE_NAME_LEN))) { + qdevice_name, VOTEQUORUM_QDEVICE_MAX_NAME_LEN))) { goto out; } else { log_printf(LOGSYS_LEVEL_WARNING, @@ -2321,7 +2318,7 @@ static void message_handler_req_lib_votequorum_qdevice_unregister (void *conn, ENTER(); if (us->flags & NODE_FLAGS_QDEVICE_REGISTERED) { - if (strncmp(req_lib_votequorum_qdevice_unregister->name, qdevice_name, VOTEQUORUM_MAX_QDEVICE_NAME_LEN)) { + if (strncmp(req_lib_votequorum_qdevice_unregister->name, qdevice_name, VOTEQUORUM_QDEVICE_MAX_NAME_LEN)) { error = CS_ERR_INVALID_PARAM; goto out; } @@ -2359,7 +2356,7 @@ static void message_handler_req_lib_votequorum_qdevice_update (void *conn, ENTER(); if (us->flags & NODE_FLAGS_QDEVICE_REGISTERED) { - if (strncmp(req_lib_votequorum_qdevice_update->oldname, qdevice_name, VOTEQUORUM_MAX_QDEVICE_NAME_LEN)) { + if (strncmp(req_lib_votequorum_qdevice_update->oldname, qdevice_name, VOTEQUORUM_QDEVICE_MAX_NAME_LEN)) { error = CS_ERR_INVALID_PARAM; goto out; } @@ -2394,7 +2391,7 @@ static void message_handler_req_lib_votequorum_qdevice_poll (void *conn, } if (us->flags & NODE_FLAGS_QDEVICE_REGISTERED) { - if (strncmp(req_lib_votequorum_qdevice_poll->name, qdevice_name, VOTEQUORUM_MAX_QDEVICE_NAME_LEN)) { + if (strncmp(req_lib_votequorum_qdevice_poll->name, qdevice_name, VOTEQUORUM_QDEVICE_MAX_NAME_LEN)) { error = CS_ERR_INVALID_PARAM; goto out; } @@ -2450,7 +2447,7 @@ static void message_handler_req_lib_votequorum_qdevice_master_wins (void *conn, } if (us->flags & NODE_FLAGS_QDEVICE_REGISTERED) { - if (strncmp(req_lib_votequorum_qdevice_master_wins->name, qdevice_name, VOTEQUORUM_MAX_QDEVICE_NAME_LEN)) { + if (strncmp(req_lib_votequorum_qdevice_master_wins->name, qdevice_name, VOTEQUORUM_QDEVICE_MAX_NAME_LEN)) { error = CS_ERR_INVALID_PARAM; goto out; } diff --git a/include/corosync/ipc_votequorum.h b/include/corosync/ipc_votequorum.h index d5108e2..c7bb3ed 100644 --- a/include/corosync/ipc_votequorum.h +++ b/include/corosync/ipc_votequorum.h @@ -36,7 +36,9 @@ #define IPC_VOTEQUORUM_H_DEFINED #include <corosync/mar_gen.h> -#define VOTEQUORUM_MAX_QDEVICE_NAME_LEN 255 +#define VOTEQUORUM_QDEVICE_NODEID 0 +#define VOTEQUORUM_QDEVICE_MAX_NAME_LEN 255 +#define VOTEQUORUM_QDEVICE_DEFAULT_TIMEOUT 10000 enum req_votequorum_types { MESSAGE_REQ_VOTEQUORUM_GETINFO = 0, @@ -61,29 +63,29 @@ enum res_votequorum_types { struct req_lib_votequorum_qdevice_register { struct qb_ipc_request_header header __attribute__((aligned(8))); - char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; + char name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; }; struct req_lib_votequorum_qdevice_unregister { struct qb_ipc_request_header header __attribute__((aligned(8))); - char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; + char name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; }; struct req_lib_votequorum_qdevice_update { struct qb_ipc_request_header header __attribute__((aligned(8))); - char oldname[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; - char newname[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; + char oldname[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; + char newname[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; }; struct req_lib_votequorum_qdevice_poll { struct qb_ipc_request_header header __attribute__((aligned(8))); - char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; + char name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; int cast_vote; }; struct req_lib_votequorum_qdevice_master_wins { struct qb_ipc_request_header header __attribute__((aligned(8))); - char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; + char name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; unsigned int allow; }; @@ -143,7 +145,7 @@ struct res_lib_votequorum_getinfo { unsigned int quorum; unsigned int flags; unsigned int qdevice_votes; - char qdevice_name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; + char qdevice_name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; }; struct votequorum_node { diff --git a/include/corosync/votequorum.h b/include/corosync/votequorum.h index 5703e96..c85f281 100644 --- a/include/corosync/votequorum.h +++ b/include/corosync/votequorum.h @@ -53,12 +53,13 @@ typedef uint64_t votequorum_handle_t; #define VOTEQUORUM_INFO_QDEVICE_CAST_VOTE 256 #define VOTEQUORUM_INFO_QDEVICE_MASTER_WINS 512 -#define VOTEQUORUM_NODEID_QDEVICE 0 -#define VOTEQUORUM_MAX_QDEVICE_NAME_LEN 255 +#define VOTEQUORUM_QDEVICE_NODEID 0 +#define VOTEQUORUM_QDEVICE_MAX_NAME_LEN 255 +#define VOTEQUORUM_QDEVICE_DEFAULT_TIMEOUT 10000 -#define VOTEQUORUM_NODESTATE_MEMBER 1 -#define VOTEQUORUM_NODESTATE_DEAD 2 -#define VOTEQUORUM_NODESTATE_LEAVING 3 +#define VOTEQUORUM_NODESTATE_MEMBER 1 +#define VOTEQUORUM_NODESTATE_DEAD 2 +#define VOTEQUORUM_NODESTATE_LEAVING 3 /** @} */ @@ -72,7 +73,7 @@ struct votequorum_info { unsigned int quorum; unsigned int flags; unsigned int qdevice_votes; - char qdevice_name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; + char qdevice_name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; }; typedef struct { diff --git a/lib/votequorum.c b/lib/votequorum.c index 9944987..daac847 100644 --- a/lib/votequorum.c +++ b/lib/votequorum.c @@ -189,7 +189,7 @@ cs_error_t votequorum_getinfo ( info->quorum = res_lib_votequorum_getinfo.quorum; info->flags = res_lib_votequorum_getinfo.flags; info->qdevice_votes = res_lib_votequorum_getinfo.qdevice_votes; - memset(info->qdevice_name, 0, VOTEQUORUM_MAX_QDEVICE_NAME_LEN); + memset(info->qdevice_name, 0, VOTEQUORUM_QDEVICE_MAX_NAME_LEN); strcpy(info->qdevice_name, res_lib_votequorum_getinfo.qdevice_name); error_exit: @@ -564,7 +564,7 @@ cs_error_t votequorum_qdevice_register ( struct res_lib_votequorum_status res_lib_votequorum_status; if ((strlen(name) == 0) || - (strlen(name) >= VOTEQUORUM_MAX_QDEVICE_NAME_LEN)) { + (strlen(name) >= VOTEQUORUM_QDEVICE_MAX_NAME_LEN)) { return CS_ERR_INVALID_PARAM; } @@ -612,7 +612,7 @@ cs_error_t votequorum_qdevice_poll ( struct res_lib_votequorum_status res_lib_votequorum_status; if ((strlen(name) == 0) || - (strlen(name) >= VOTEQUORUM_MAX_QDEVICE_NAME_LEN)) { + (strlen(name) >= VOTEQUORUM_QDEVICE_MAX_NAME_LEN)) { return CS_ERR_INVALID_PARAM; } @@ -660,7 +660,7 @@ cs_error_t votequorum_qdevice_master_wins ( struct res_lib_votequorum_status res_lib_votequorum_status; if ((strlen(name) == 0) || - (strlen(name) >= VOTEQUORUM_MAX_QDEVICE_NAME_LEN)) { + (strlen(name) >= VOTEQUORUM_QDEVICE_MAX_NAME_LEN)) { return CS_ERR_INVALID_PARAM; } @@ -708,9 +708,9 @@ cs_error_t votequorum_qdevice_update ( struct res_lib_votequorum_status res_lib_votequorum_status; if ((strlen(oldname) == 0) || - (strlen(oldname) >= VOTEQUORUM_MAX_QDEVICE_NAME_LEN) || + (strlen(oldname) >= VOTEQUORUM_QDEVICE_MAX_NAME_LEN) || (strlen(newname) == 0) || - (strlen(newname) >= VOTEQUORUM_MAX_QDEVICE_NAME_LEN)) { + (strlen(newname) >= VOTEQUORUM_QDEVICE_MAX_NAME_LEN)) { return CS_ERR_INVALID_PARAM; } @@ -757,7 +757,7 @@ cs_error_t votequorum_qdevice_unregister ( struct res_lib_votequorum_status res_lib_votequorum_status; if ((strlen(name) == 0) || - (strlen(name) >= VOTEQUORUM_MAX_QDEVICE_NAME_LEN)) { + (strlen(name) >= VOTEQUORUM_QDEVICE_MAX_NAME_LEN)) { return CS_ERR_INVALID_PARAM; } diff --git a/man/votequorum_getinfo.3.in b/man/votequorum_getinfo.3.in index efc8ddb..fc2fa4c 100644 --- a/man/votequorum_getinfo.3.in +++ b/man/votequorum_getinfo.3.in @@ -61,7 +61,7 @@ struct votequorum_info { unsigned int quorum; unsigned int flags; unsigned int qdevice_votes; - char qdevice_name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN]; + char qdevice_name[VOTEQUORUM_QDEVICE_MAX_NAME_LEN]; }; .fi diff --git a/test/testvotequorum2.c b/test/testvotequorum2.c index 3fb3060..7198029 100644 --- a/test/testvotequorum2.c +++ b/test/testvotequorum2.c @@ -49,7 +49,7 @@ static void print_info(int ok_to_fail) struct votequorum_info info; int err; - if ( (err=votequorum_getinfo(handle, VOTEQUORUM_NODEID_QDEVICE, &info)) != CS_OK) + if ( (err=votequorum_getinfo(handle, VOTEQUORUM_QDEVICE_NODEID, &info)) != CS_OK) fprintf(stderr, "votequorum_getinfo error %d: %s\n", err, ok_to_fail?"OK":"FAILED"); else { printf("name %s\n", info.qdevice_name); diff --git a/tools/corosync-quorumtool.c b/tools/corosync-quorumtool.c index d309f19..c776cf4 100644 --- a/tools/corosync-quorumtool.c +++ b/tools/corosync-quorumtool.c @@ -349,9 +349,9 @@ static void display_nodes_data(uint32_t nodeid, nodeid_format_t nodeid_format, n fprintf(stderr, "Unable to get quorum device info: %s\n", cs_strerror(err)); } else { if (nodeid_format == NODEID_FORMAT_DECIMAL) { - print_uint32_padded(VOTEQUORUM_NODEID_QDEVICE); + print_uint32_padded(VOTEQUORUM_QDEVICE_NODEID); } else { - printf("0x%08x ", VOTEQUORUM_NODEID_QDEVICE); + printf("0x%08x ", VOTEQUORUM_QDEVICE_NODEID); } print_uint32_padded(info.qdevice_votes); printf("%s (%s/%s/%s)\n", info.qdevice_name, -- 1.7.7.6 _______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss