]> git.proxmox.com Git - mirror_corosync.git/commitdiff
votequorum: drop votequorum_qdevice_getinfo and collapse data into getinfo
authorFabio M. Di Nitto <fdinitto@redhat.com>
Wed, 25 Jul 2012 09:04:56 +0000 (11:04 +0200)
committerFabio M. Di Nitto <fdinitto@redhat.com>
Tue, 7 Aug 2012 09:07:17 +0000 (11:07 +0200)
it's really pointless to have basically a duplicated API call
to transfer one value and one name.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
exec/votequorum.c
include/corosync/ipc_votequorum.h
include/corosync/votequorum.h
lib/libvotequorum.versions
lib/votequorum.c
man/votequorum_getinfo.3.in
man/votequorum_qdevice_getinfo.3.in [deleted file]
test/testvotequorum2.c
tools/corosync-quorumtool.c

index ab8ebae488bdd9d9f704e59deff5da252f39f3b7..b3c6b525cd37f5fa84a655bf70a16688dfa065c3 100644 (file)
@@ -319,9 +319,6 @@ static void message_handler_req_lib_votequorum_qdevice_update (void *conn,
 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 */
@@ -359,10 +356,6 @@ static struct corosync_lib_handler quorum_lib_service[] =
        { /* 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
        }
 };
 
@@ -2044,8 +2037,14 @@ static void message_handler_req_lib_votequorum_getinfo (void *conn, const void *
                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;
@@ -2392,47 +2391,3 @@ out:
 
        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();
-}
index e148149559d15146088b349164d9b700577972ec..9bb15a97d2b6ad61001227ddb19af28c7faf2843 100644 (file)
@@ -47,14 +47,12 @@ enum req_votequorum_types {
        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
@@ -82,11 +80,6 @@ struct req_lib_votequorum_qdevice_poll {
        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;
@@ -141,14 +134,8 @@ struct res_lib_votequorum_getinfo {
        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 {
index ba8b30c7ea0cd5eafecadbcc70049109ece529f9..0cbc456708126c67529be885ca6224a07fed64fc 100644 (file)
@@ -70,13 +70,8 @@ struct votequorum_info {
        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 {
@@ -210,14 +205,6 @@ cs_error_t votequorum_qdevice_poll (
        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
index 2af705ad73df698f35fdcfc0ef72e0ab531d7f03..7a37030cb8fda56da6e9b5aec284586129164c0c 100644 (file)
@@ -10,7 +10,6 @@ COROSYNC_VOTEQUORUM_1.0 {
                votequorum_qdevice_register;
                votequorum_qdevice_unregister;
                votequorum_qdevice_poll;
-               votequorum_qdevice_getinfo;
                votequorum_trackstart;
                votequorum_trackstop;
                votequorum_context_get;
index e36d114677e3ecd105ae25c835b2f48bc7d19303..d046663c1306b8eb366eaa1d3f7129af1ae8d8d6 100644 (file)
@@ -188,6 +188,9 @@ cs_error_t votequorum_getinfo (
        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);
@@ -687,51 +690,3 @@ error_exit:
 
        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);
-}
index 4c4e349c2abd99ea6d4888cee69256c333eaff96..1694f347d33c2b6806e6fe978a710fabe0d966d3 100644 (file)
@@ -60,6 +60,8 @@ struct votequorum_info {
         unsigned int total_votes;
         unsigned int quorum;
         unsigned int flags;
+        unsigned int qdevice_votes;
+        char qdevice_name[VOTEQUORUM_MAX_QDEVICE_NAME_LEN];
 };
 
 .fi
diff --git a/man/votequorum_qdevice_getinfo.3.in b/man/votequorum_qdevice_getinfo.3.in
deleted file mode 100644 (file)
index 9d6eeeb..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-.\"/*
-.\" * 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
index a66e25ba73011cb7120da84cf6f1cd097da2fa5a..2257a7429077533cf486d903eccf9771617d156d 100644 (file)
@@ -46,16 +46,20 @@ static votequorum_handle_t handle;
 
 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");
        }
 }
index 1d2417b7e6586648c6b29daa32b807a57eb1bac8..40c1d2584c8b1e7f6e32f62730484cfc94eca247 100644 (file)
@@ -219,18 +219,6 @@ static int set_expected(int expected_votes)
        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.
@@ -310,6 +298,18 @@ static void print_uint32_padded(uint32_t value)
        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;
@@ -342,9 +342,9 @@ static void display_nodes_data(uint32_t nodeid, nodeid_format_t nodeid_format, n
 
        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 {
@@ -353,10 +353,10 @@ static void display_nodes_data(uint32_t nodeid, nodeid_format_t nodeid_format, n
                        } 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");
                }
        }
 }
@@ -563,15 +563,19 @@ err_exit:
 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;