Просмотр исходного кода

votequorum: remove last instance of state and rename it to cast_vote

also align naming of vote to cast_vote for info calls

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Fabio M. Di Nitto 13 лет назад
Родитель
Сommit
2dae49e54a

+ 2 - 2
exec/votequorum.c

@@ -2321,7 +2321,7 @@ static void message_handler_req_lib_votequorum_qdevice_poll (void *conn,
 
 
 		us->flags |= NODE_FLAGS_QDEVICE_ALIVE;
 		us->flags |= NODE_FLAGS_QDEVICE_ALIVE;
 
 
-		if (req_lib_votequorum_qdevice_poll->state) {
+		if (req_lib_votequorum_qdevice_poll->cast_vote) {
 			us->flags |= NODE_FLAGS_QDEVICE_CAST_VOTE;
 			us->flags |= NODE_FLAGS_QDEVICE_CAST_VOTE;
 		} else {
 		} else {
 			us->flags &= ~NODE_FLAGS_QDEVICE_CAST_VOTE;
 			us->flags &= ~NODE_FLAGS_QDEVICE_CAST_VOTE;
@@ -2377,7 +2377,7 @@ static void message_handler_req_lib_votequorum_qdevice_getinfo (void *conn,
 						nodeid, alive_status, vote_status);
 						nodeid, alive_status, vote_status);
 		res_lib_votequorum_qdevice_getinfo.votes = qdevice->votes;
 		res_lib_votequorum_qdevice_getinfo.votes = qdevice->votes;
 		res_lib_votequorum_qdevice_getinfo.alive = alive_status;
 		res_lib_votequorum_qdevice_getinfo.alive = alive_status;
-		res_lib_votequorum_qdevice_getinfo.vote = vote_status;
+		res_lib_votequorum_qdevice_getinfo.cast_vote = vote_status;
 		strcpy(res_lib_votequorum_qdevice_getinfo.name, qdevice_name);
 		strcpy(res_lib_votequorum_qdevice_getinfo.name, qdevice_name);
 	} else {
 	} else {
 		error = CS_ERR_NOT_EXIST;
 		error = CS_ERR_NOT_EXIST;

+ 2 - 2
include/corosync/ipc_votequorum.h

@@ -79,7 +79,7 @@ struct req_lib_votequorum_qdevice_update {
 struct req_lib_votequorum_qdevice_poll {
 struct req_lib_votequorum_qdevice_poll {
 	struct qb_ipc_request_header header __attribute__((aligned(8)));
 	struct qb_ipc_request_header header __attribute__((aligned(8)));
 	char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
 	char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
-	int state;
+	int cast_vote;
 };
 };
 
 
 struct req_lib_votequorum_qdevice_getinfo {
 struct req_lib_votequorum_qdevice_getinfo {
@@ -143,7 +143,7 @@ struct res_lib_votequorum_qdevice_getinfo {
 	struct qb_ipc_response_header header __attribute__((aligned(8)));
 	struct qb_ipc_response_header header __attribute__((aligned(8)));
 	unsigned int votes;
 	unsigned int votes;
 	unsigned int alive;
 	unsigned int alive;
-	unsigned int vote;
+	unsigned int cast_vote;
 	char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
 	char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
 };
 };
 
 

+ 2 - 2
include/corosync/votequorum.h

@@ -75,7 +75,7 @@ struct votequorum_info {
 struct votequorum_qdevice_info {
 struct votequorum_qdevice_info {
 	unsigned int votes;
 	unsigned int votes;
 	unsigned int alive;
 	unsigned int alive;
-	unsigned int vote;
+	unsigned int cast_vote;
 	char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
 	char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
 };
 };
 
 
@@ -208,7 +208,7 @@ cs_error_t votequorum_qdevice_update (
 cs_error_t votequorum_qdevice_poll (
 cs_error_t votequorum_qdevice_poll (
 	votequorum_handle_t handle,
 	votequorum_handle_t handle,
 	const char *name,
 	const char *name,
-	unsigned int state);
+	unsigned int cast_vote);
 
 
 /**
 /**
  * Get quorum device information
  * Get quorum device information

+ 3 - 3
lib/votequorum.c

@@ -599,7 +599,7 @@ error_exit:
 cs_error_t votequorum_qdevice_poll (
 cs_error_t votequorum_qdevice_poll (
 	votequorum_handle_t handle,
 	votequorum_handle_t handle,
 	const char *name,
 	const char *name,
-	unsigned int state)
+	unsigned int cast_vote)
 {
 {
 	cs_error_t error;
 	cs_error_t error;
 	struct votequorum_inst *votequorum_inst;
 	struct votequorum_inst *votequorum_inst;
@@ -619,7 +619,7 @@ cs_error_t votequorum_qdevice_poll (
 	req_lib_votequorum_qdevice_poll.header.size = sizeof (struct req_lib_votequorum_qdevice_poll);
 	req_lib_votequorum_qdevice_poll.header.size = sizeof (struct req_lib_votequorum_qdevice_poll);
 	req_lib_votequorum_qdevice_poll.header.id = MESSAGE_REQ_VOTEQUORUM_QDEVICE_POLL;
 	req_lib_votequorum_qdevice_poll.header.id = MESSAGE_REQ_VOTEQUORUM_QDEVICE_POLL;
 	strcpy(req_lib_votequorum_qdevice_poll.name, name);
 	strcpy(req_lib_votequorum_qdevice_poll.name, name);
-	req_lib_votequorum_qdevice_poll.state = state;
+	req_lib_votequorum_qdevice_poll.cast_vote = cast_vote;
 
 
 	iov.iov_base = (char *)&req_lib_votequorum_qdevice_poll;
 	iov.iov_base = (char *)&req_lib_votequorum_qdevice_poll;
 	iov.iov_len = sizeof (struct req_lib_votequorum_qdevice_poll);
 	iov.iov_len = sizeof (struct req_lib_votequorum_qdevice_poll);
@@ -726,7 +726,7 @@ cs_error_t votequorum_qdevice_getinfo (
 
 
 	qinfo->votes = res_lib_votequorum_qdevice_getinfo.votes;
 	qinfo->votes = res_lib_votequorum_qdevice_getinfo.votes;
 	qinfo->alive = res_lib_votequorum_qdevice_getinfo.alive;
 	qinfo->alive = res_lib_votequorum_qdevice_getinfo.alive;
-	qinfo->vote = res_lib_votequorum_qdevice_getinfo.vote;
+	qinfo->cast_vote = res_lib_votequorum_qdevice_getinfo.cast_vote;
 	strcpy(qinfo->name, res_lib_votequorum_qdevice_getinfo.name);
 	strcpy(qinfo->name, res_lib_votequorum_qdevice_getinfo.name);
 
 
 
 

+ 2 - 2
man/votequorum_qdevice_poll.3.in

@@ -37,13 +37,13 @@ votequorum_qdevice_poll \- Tells votequorum the result of the quorum device poll
 .SH SYNOPSIS
 .SH SYNOPSIS
 .B #include <corosync/votequorum.h>
 .B #include <corosync/votequorum.h>
 .sp
 .sp
-.BI "int votequorum_qdevice_poll(votequorum_handle_t " handle ", unsigned int " state ");"
+.BI "int votequorum_qdevice_poll(votequorum_handle_t " handle ", unsigned int " cast_vote ");"
 .SH DESCRIPTION
 .SH DESCRIPTION
 The
 The
 .B votequorum_qdevice_poll
 .B votequorum_qdevice_poll
 is called by the quorum device subsystem (not provided as part of votequorum) to tell
 is called by the quorum device subsystem (not provided as part of votequorum) to tell
 the voting system if the quorum device is present/active or not. If
 the voting system if the quorum device is present/active or not. If
-.B state
+.B cast_vote
 is 1 then the votes for the device are included in the quorum calculation, otherwise not.
 is 1 then the votes for the device are included in the quorum calculation, otherwise not.
 This routine should be called at regular intervals to ensure that the device status
 This routine should be called at regular intervals to ensure that the device status
 is always known to votequorum. If
 is always known to votequorum. If

+ 8 - 4
test/testvotequorum2.c

@@ -53,9 +53,9 @@ static void print_info(int ok_to_fail)
 		fprintf(stderr, "votequorum_qdevice_getinfo error %d: %s\n", err, ok_to_fail?"OK":"FAILED");
 		fprintf(stderr, "votequorum_qdevice_getinfo error %d: %s\n", err, ok_to_fail?"OK":"FAILED");
 	else {
 	else {
 		printf("qdevice votes  %d\n", qinfo.votes);
 		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("alive          %d\n", qinfo.alive);
+		printf("cast vote      %d\n", qinfo.cast_vote);
+		printf("name           %s\n", qinfo.name);
 		printf("\n");
 		printf("\n");
 	}
 	}
 }
 }
@@ -63,6 +63,7 @@ static void print_info(int ok_to_fail)
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
 	int ret = 0;
 	int ret = 0;
+	int cast_vote = 1;
 	int pollcount=0, polltime=1;
 	int pollcount=0, polltime=1;
 	int err;
 	int err;
 
 
@@ -79,6 +80,9 @@ int main(int argc, char *argv[])
 	if (argc >= 3 && atoi(argv[2])) {
 	if (argc >= 3 && atoi(argv[2])) {
 		polltime = atoi(argv[2]);
 		polltime = atoi(argv[2]);
 	}
 	}
+	if (argc >= 4) {
+		cast_vote = atoi(argv[3]);
+	}
 
 
 	if (argc >= 2) {
 	if (argc >= 2) {
 		if ( (err=votequorum_qdevice_register(handle, "QDEVICE")) != CS_OK) {
 		if ( (err=votequorum_qdevice_register(handle, "QDEVICE")) != CS_OK) {
@@ -89,7 +93,7 @@ int main(int argc, char *argv[])
 
 
 		while (pollcount--) {
 		while (pollcount--) {
 			print_info(0);
 			print_info(0);
-			if ((err=votequorum_qdevice_poll(handle, "QDEVICE", 1)) != CS_OK) {
+			if ((err=votequorum_qdevice_poll(handle, "QDEVICE", cast_vote)) != CS_OK) {
 				fprintf(stderr, "qdevice poll FAILED: %d\n", err);
 				fprintf(stderr, "qdevice poll FAILED: %d\n", err);
 				ret = -1;
 				ret = -1;
 				goto out;
 				goto out;

+ 3 - 1
tools/corosync-quorumtool.c

@@ -354,7 +354,9 @@ static void display_nodes_data(uint32_t nodeid, nodeid_format_t nodeid_format, n
 				printf("0x%08x ", VOTEQUORUM_NODEID_QDEVICE);
 				printf("0x%08x ", VOTEQUORUM_NODEID_QDEVICE);
 			}
 			}
 			print_uint32_padded(qinfo.votes);
 			print_uint32_padded(qinfo.votes);
-			printf("%s (%s/%s)\n", qinfo.name, qinfo.alive?"Alive":"Not alive", qinfo.vote?"Voting":"Not voting");
+			printf("%s (%s/%s)\n", qinfo.name,
+			       qinfo.alive?"Alive":"Not alive",
+			       qinfo.cast_vote?"Voting":"Not voting");
 		}
 		}
 	}
 	}
 }
 }