static void message_handler_req_lib_votequorum_qdevice_poll (void *conn,
const void *message);
-static void message_handler_req_lib_votequorum_qdevice_getinfo (void *conn,
- const void *message);
-
static struct corosync_lib_handler quorum_lib_service[] =
{
{ /* 0 */
{ /* 8 */
.lib_handler_fn = message_handler_req_lib_votequorum_qdevice_poll,
.flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 9 */
- .lib_handler_fn = message_handler_req_lib_votequorum_qdevice_getinfo,
- .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
}
};
if (allow_downscale) {
res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_ALLOW_DOWNSCALE;
}
+
+ memset(res_lib_votequorum_getinfo.qdevice_name, 0, VOTEQUORUM_MAX_QDEVICE_NAME_LEN);
+ res_lib_votequorum_getinfo.qdevice_votes = 0;
+
if (node->flags & NODE_FLAGS_QDEVICE_REGISTERED) {
res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_QDEVICE_REGISTERED;
+ res_lib_votequorum_getinfo.qdevice_votes = qdevice->votes;
+ strcpy(res_lib_votequorum_getinfo.qdevice_name, qdevice_name);
}
if (node->flags & NODE_FLAGS_QDEVICE_ALIVE) {
res_lib_votequorum_getinfo.flags |= VOTEQUORUM_INFO_QDEVICE_ALIVE;
LEAVE();
}
-
-static void message_handler_req_lib_votequorum_qdevice_getinfo (void *conn,
- const void *message)
-{
- const struct req_lib_votequorum_qdevice_getinfo *req_lib_votequorum_qdevice_getinfo = message;
- struct res_lib_votequorum_qdevice_getinfo res_lib_votequorum_qdevice_getinfo;
- cs_error_t error = CS_OK;
- struct cluster_node *node;
- uint32_t nodeid = req_lib_votequorum_qdevice_getinfo->nodeid;
-
- ENTER();
-
- if (nodeid == NODEID_QDEVICE) {
- nodeid = us->node_id;
- }
-
- node = find_node_by_nodeid(nodeid);
- if ((node) &&
- (node->flags & NODE_FLAGS_QDEVICE_REGISTERED)) {
- 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 vote_status %d",
- nodeid, alive_status, vote_status);
- res_lib_votequorum_qdevice_getinfo.votes = qdevice->votes;
- res_lib_votequorum_qdevice_getinfo.alive = alive_status;
- res_lib_votequorum_qdevice_getinfo.cast_vote = vote_status;
- strcpy(res_lib_votequorum_qdevice_getinfo.name, qdevice_name);
- } else {
- error = CS_ERR_NOT_EXIST;
- }
-
- res_lib_votequorum_qdevice_getinfo.header.size = sizeof(res_lib_votequorum_qdevice_getinfo);
- res_lib_votequorum_qdevice_getinfo.header.id = MESSAGE_RES_VOTEQUORUM_GETINFO;
- res_lib_votequorum_qdevice_getinfo.header.error = error;
- corosync_api->ipc_response_send(conn, &res_lib_votequorum_qdevice_getinfo, sizeof(res_lib_votequorum_qdevice_getinfo));
-
- LEAVE();
-}
MESSAGE_REQ_VOTEQUORUM_QDEVICE_REGISTER,
MESSAGE_REQ_VOTEQUORUM_QDEVICE_UNREGISTER,
MESSAGE_REQ_VOTEQUORUM_QDEVICE_UPDATE,
- MESSAGE_REQ_VOTEQUORUM_QDEVICE_POLL,
- MESSAGE_REQ_VOTEQUORUM_QDEVICE_GETINFO
+ MESSAGE_REQ_VOTEQUORUM_QDEVICE_POLL
};
enum res_votequorum_types {
MESSAGE_RES_VOTEQUORUM_STATUS = 0,
MESSAGE_RES_VOTEQUORUM_GETINFO,
- MESSAGE_RES_VOTEQUORUM_QDEVICE_GETINFO,
MESSAGE_RES_VOTEQUORUM_TRACKSTART,
MESSAGE_RES_VOTEQUORUM_NOTIFICATION,
MESSAGE_RES_VOTEQUORUM_EXPECTEDVOTES_NOTIFICATION
int cast_vote;
};
-struct req_lib_votequorum_qdevice_getinfo {
- struct qb_ipc_request_header header __attribute__((aligned(8)));
- int nodeid;
-};
-
struct req_lib_votequorum_setvotes {
struct qb_ipc_request_header header __attribute__((aligned(8)));
unsigned int votes;
unsigned int total_votes;
unsigned int quorum;
unsigned int flags;
-};
-
-struct res_lib_votequorum_qdevice_getinfo {
- struct qb_ipc_response_header header __attribute__((aligned(8)));
- unsigned int votes;
- unsigned int alive;
- unsigned int cast_vote;
- char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
+ unsigned int qdevice_votes;
+ char qdevice_name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
};
struct votequorum_node {
unsigned int total_votes;
unsigned int quorum;
unsigned int flags;
-};
-
-struct votequorum_qdevice_info {
- unsigned int votes;
- unsigned int alive;
- unsigned int cast_vote;
- char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
+ unsigned int qdevice_votes;
+ char qdevice_name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
};
typedef struct {
const char *name,
unsigned int cast_vote);
-/**
- * Get quorum device information
- */
-cs_error_t votequorum_qdevice_getinfo (
- votequorum_handle_t handle,
- unsigned int nodeid,
- struct votequorum_qdevice_info *info);
-
#ifdef __cplusplus
}
#endif
votequorum_qdevice_register;
votequorum_qdevice_unregister;
votequorum_qdevice_poll;
- votequorum_qdevice_getinfo;
votequorum_trackstart;
votequorum_trackstop;
votequorum_context_get;
info->total_votes = res_lib_votequorum_getinfo.total_votes;
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);
+ strcpy(info->qdevice_name, res_lib_votequorum_getinfo.qdevice_name);
error_exit:
hdb_handle_put (&votequorum_handle_t_db, handle);
return (error);
}
-
-cs_error_t votequorum_qdevice_getinfo (
- votequorum_handle_t handle,
- unsigned int nodeid,
- struct votequorum_qdevice_info *qinfo)
-{
- cs_error_t error;
- struct votequorum_inst *votequorum_inst;
- struct iovec iov;
- struct req_lib_votequorum_qdevice_getinfo req_lib_votequorum_qdevice_getinfo;
- struct res_lib_votequorum_qdevice_getinfo res_lib_votequorum_qdevice_getinfo;
-
- error = hdb_error_to_cs(hdb_handle_get (&votequorum_handle_t_db, handle, (void *)&votequorum_inst));
- if (error != CS_OK) {
- return (error);
- }
-
- req_lib_votequorum_qdevice_getinfo.header.size = sizeof (struct req_lib_votequorum_qdevice_getinfo);
- req_lib_votequorum_qdevice_getinfo.header.id = MESSAGE_REQ_VOTEQUORUM_QDEVICE_GETINFO;
- req_lib_votequorum_qdevice_getinfo.nodeid = nodeid;
-
- iov.iov_base = (char *)&req_lib_votequorum_qdevice_getinfo;
- iov.iov_len = sizeof (struct req_lib_votequorum_qdevice_getinfo);
-
- error = qb_to_cs_error(qb_ipcc_sendv_recv (
- votequorum_inst->c,
- &iov,
- 1,
- &res_lib_votequorum_qdevice_getinfo,
- sizeof (struct res_lib_votequorum_qdevice_getinfo), CS_IPC_TIMEOUT_MS));
-
- if (error != CS_OK) {
- goto error_exit;
- }
-
- error = res_lib_votequorum_qdevice_getinfo.header.error;
-
- qinfo->votes = res_lib_votequorum_qdevice_getinfo.votes;
- qinfo->alive = res_lib_votequorum_qdevice_getinfo.alive;
- qinfo->cast_vote = res_lib_votequorum_qdevice_getinfo.cast_vote;
- strcpy(qinfo->name, res_lib_votequorum_qdevice_getinfo.name);
-
-
-error_exit:
- hdb_handle_put (&votequorum_handle_t_db, handle);
-
- return (error);
-}
unsigned int total_votes;
unsigned int quorum;
unsigned int flags;
+ unsigned int qdevice_votes;
+ char qdevice_name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
};
.fi
+++ /dev/null
-.\"/*
-.\" * Copyright (c) 2009,2012 Red Hat, Inc.
-.\" *
-.\" * All rights reserved.
-.\" *
-.\" * Author: Christine Caulfield <ccaulfie@redhat.com>
-.\" *
-.\" * This software licensed under BSD license, the text of which follows:
-.\" *
-.\" * Redistribution and use in source and binary forms, with or without
-.\" * modification, are permitted provided that the following conditions are met:
-.\" *
-.\" * - Redistributions of source code must retain the above copyright notice,
-.\" * this list of conditions and the following disclaimer.
-.\" * - Redistributions in binary form must reproduce the above copyright notice,
-.\" * this list of conditions and the following disclaimer in the documentation
-.\" * and/or other materials provided with the distribution.
-.\" * - Neither the name of the MontaVista Software, Inc. nor the names of its
-.\" * contributors may be used to endorse or promote products derived from this
-.\" * software without specific prior written permission.
-.\" *
-.\" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-.\" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-.\" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-.\" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-.\" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-.\" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-.\" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-.\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-.\" * THE POSSIBILITY OF SUCH DAMAGE.
-.\" */
-.TH VOTEQUORUM_QDEVICE_GETINFO 3 @BUILDDATE@ "corosync Man Page" "Corosync Cluster Engine Programmer's Manual"
-.SH NAME
-votequorum_qdevice_getinfo \- Get details of the quorum device
-.SH SYNOPSIS
-.B #include <corosync/votequorum.h>
-.sp
-.BI "int votequorum_qdevice_getinfo(votequorum_handle_t " handle ", struct votequorum_qdevice_info " *info ");"
-.SH DESCRIPTION
-The
-.B votequorum_qdevice_getinfo
-Returns information about the quorum device in the following structure:
-
-.nf
-struct votequorum_qdevice_info {
- unsigned int votes;
- unsigned int alive;
- unsigned int vote;
- char name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
-};
-.fi
-.SH RETURN VALUE
-This call returns the CS_OK value if successful, otherwise an error is returned.
-.PP
-.SH ERRORS
-@COMMONIPCERRORS@
-.SH "SEE ALSO"
-.BR votequorum_overview (8),
-.BR votequorum_initialize (3),
-.BR votequorum_finalize (3),
-.BR votequorum_getinfo (3),
-.BR votequorum_trackstart (3),
-.BR votequorum_trackstop (3),
-.BR votequorum_fd_get (3),
-.BR votequorum_dispatch (3),
-.BR votequorum_context_set (3),
-.BR votequorum_context_get (3),
-.BR votequorum_setexpected (3),
-.BR votequorum_setvotes (3),
-.BR votequorum_qdevice_register (3),
-.BR votequorum_qdevice_unregister (3),
-.BR votequorum_qdevice_poll (3)
-.PP
static void print_info(int ok_to_fail)
{
- struct votequorum_qdevice_info qinfo;
+ struct votequorum_info info;
int err;
- if ( (err=votequorum_qdevice_getinfo(handle, VOTEQUORUM_NODEID_QDEVICE, &qinfo)) != CS_OK)
- fprintf(stderr, "votequorum_qdevice_getinfo error %d: %s\n", err, ok_to_fail?"OK":"FAILED");
+ if ( (err=votequorum_getinfo(handle, VOTEQUORUM_NODEID_QDEVICE, &info)) != CS_OK)
+ fprintf(stderr, "votequorum_getinfo error %d: %s\n", err, ok_to_fail?"OK":"FAILED");
else {
- printf("qdevice votes %d\n", qinfo.votes);
- printf("alive %d\n", qinfo.alive);
- printf("cast vote %d\n", qinfo.cast_vote);
- printf("name %s\n", qinfo.name);
+ printf("name %s\n", info.qdevice_name);
+ printf("qdevice votes %d\n", info.qdevice_votes);
+ if (info.flags & VOTEQUORUM_INFO_QDEVICE_ALIVE) {
+ printf("alive\n");
+ }
+ if (info.flags & VOTEQUORUM_INFO_QDEVICE_CAST_VOTE) {
+ printf("cast vote\n");
+ }
printf("\n");
}
}
return err==CS_OK?0:err;
}
-static int get_votes(uint32_t nodeid)
-{
- int votes = -1;
- struct votequorum_info info;
-
- if (votequorum_getinfo(v_handle, nodeid, &info) == CS_OK) {
- votes = info.node_votes;
- }
-
- return votes;
-}
-
/*
* This resolves the first address assigned to a node
* and returns the name or IP address. Use cfgtool if you need more information.
print_string_padded(buf);
}
+static int get_votes(uint32_t nodeid)
+{
+ int votes = -1;
+ struct votequorum_info info;
+
+ if (votequorum_getinfo(v_handle, nodeid, &info) == CS_OK) {
+ votes = info.node_votes;
+ }
+
+ return votes;
+}
+
static void display_nodes_data(uint32_t nodeid, nodeid_format_t nodeid_format, name_format_t name_format)
{
int i;
if ((display_qdevice) && (v_handle)) {
int err;
- struct votequorum_qdevice_info qinfo;
+ struct votequorum_info info;
- err = votequorum_qdevice_getinfo(v_handle, nodeid, &qinfo);
+ err = votequorum_getinfo(v_handle, nodeid, &info);
if (err != CS_OK) {
fprintf(stderr, "Unable to get quorum device info: %s\n", cs_strerror(err));
} else {
} else {
printf("0x%08x ", VOTEQUORUM_NODEID_QDEVICE);
}
- print_uint32_padded(qinfo.votes);
- printf("%s (%s/%s)\n", qinfo.name,
- qinfo.alive?"Alive":"Not alive",
- qinfo.cast_vote?"Voting":"Not voting");
+ print_uint32_padded(info.qdevice_votes);
+ printf("%s (%s/%s)\n", info.qdevice_name,
+ info.flags & VOTEQUORUM_INFO_QDEVICE_ALIVE?"Alive":"Not alive",
+ info.flags & VOTEQUORUM_INFO_QDEVICE_CAST_VOTE?"Voting":"Not voting");
}
}
}
static int unregister_qdevice(void)
{
int err;
- struct votequorum_qdevice_info qinfo;
+ struct votequorum_info info;
- err = votequorum_qdevice_getinfo(v_handle, our_nodeid, &qinfo);
+ err = votequorum_getinfo(v_handle, our_nodeid, &info);
if (err != CS_OK) {
fprintf(stderr, "Unable to get quorum device info: %s\n", cs_strerror(err));
return -1;
}
- err = votequorum_qdevice_unregister(v_handle, qinfo.name);
+ if (!(info.flags & VOTEQUORUM_INFO_QDEVICE_REGISTERED)) {
+ return 0;
+ }
+
+ err = votequorum_qdevice_unregister(v_handle, info.qdevice_name);
if (err != CS_OK) {
fprintf(stderr, "Unable to unregister quorum device: %s\n", cs_strerror(err));
return -1;