]> git.proxmox.com Git - mirror_corosync.git/commitdiff
votequorum: ifdef qdiskd API out
authorFabio M. Di Nitto <fdinitto@redhat.com>
Wed, 18 Jan 2012 05:16:31 +0000 (06:16 +0100)
committerFabio M. Di Nitto <fdinitto@redhat.com>
Wed, 18 Jan 2012 13:23:06 +0000 (14:23 +0100)
as agreed, the API has not been tested yet. Adding later is better than
removing it.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
exec/votequorum.c
include/corosync/ipc_votequorum.h
include/corosync/votequorum.h
lib/votequorum.c
test/testvotequorum2.c

index 1bc459acb466fafcf345f281f9429ee8650bb4f0..741f8ae3583d43fa6edb2a913ba6aa6b947f9e9c 100644 (file)
@@ -68,10 +68,13 @@ static struct corosync_api_v1 *corosync_api;
  * Silly default to prevent accidents!
  */
 #define DEFAULT_EXPECTED   1024
+
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
 #define DEFAULT_QDEV_POLL 10000
 
 static unsigned int quorumdev_poll = DEFAULT_QDEV_POLL;
 static char quorum_device_name[VOTEQUORUM_MAX_QDISK_NAME_LEN];
+#endif
 
 static uint8_t two_node = 0;
 
@@ -202,7 +205,9 @@ static struct list_head trackers_list;
  * votequorum timers
  */
 
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
 static corosync_timer_handle_t quorum_device_timer;
+#endif
 static corosync_timer_handle_t last_man_standing_timer;
 static int last_man_standing_timer_set = 0;
 
@@ -264,6 +269,13 @@ static void message_handler_req_lib_votequorum_setexpected (void *conn,
 static void message_handler_req_lib_votequorum_setvotes (void *conn,
                                                         const void *message);
 
+static void message_handler_req_lib_votequorum_trackstart (void *conn,
+                                                          const void *message);
+
+static void message_handler_req_lib_votequorum_trackstop (void *conn,
+                                                         const void *message);
+
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
 static void message_handler_req_lib_votequorum_qdisk_register (void *conn,
                                                               const void *message);
 
@@ -275,11 +287,7 @@ static void message_handler_req_lib_votequorum_qdisk_poll (void *conn,
 
 static void message_handler_req_lib_votequorum_qdisk_getinfo (void *conn,
                                                              const void *message);
-
-static void message_handler_req_lib_votequorum_trackstart (void *conn,
-                                                          const void *message);
-static void message_handler_req_lib_votequorum_trackstop (void *conn,
-                                                         const void *message);
+#endif
 
 static struct corosync_lib_handler quorum_lib_service[] =
 {
@@ -296,28 +304,30 @@ static struct corosync_lib_handler quorum_lib_service[] =
                .flow_control           = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
        },
        { /* 3 */
-               .lib_handler_fn         = message_handler_req_lib_votequorum_qdisk_register,
+               .lib_handler_fn         = message_handler_req_lib_votequorum_trackstart,
                .flow_control           = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
        },
        { /* 4 */
-               .lib_handler_fn         = message_handler_req_lib_votequorum_qdisk_unregister,
+               .lib_handler_fn         = message_handler_req_lib_votequorum_trackstop,
                .flow_control           = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
        },
        { /* 5 */
-               .lib_handler_fn         = message_handler_req_lib_votequorum_qdisk_poll,
+               .lib_handler_fn         = message_handler_req_lib_votequorum_qdisk_register,
                .flow_control           = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
        },
        { /* 6 */
-               .lib_handler_fn         = message_handler_req_lib_votequorum_qdisk_getinfo,
+               .lib_handler_fn         = message_handler_req_lib_votequorum_qdisk_unregister,
                .flow_control           = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
        },
        { /* 7 */
-               .lib_handler_fn         = message_handler_req_lib_votequorum_trackstart,
+               .lib_handler_fn         = message_handler_req_lib_votequorum_qdisk_poll,
                .flow_control           = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
        },
        { /* 8 */
-               .lib_handler_fn         = message_handler_req_lib_votequorum_trackstop,
+               .lib_handler_fn         = message_handler_req_lib_votequorum_qdisk_getinfo,
                .flow_control           = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
+#endif
        }
 };
 
@@ -703,9 +713,11 @@ static void votequorum_readconfig_dynamic(void)
                us->votes = 1;
        }
 
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
        if (icmap_get_uint32("quorum.quorumdev_poll", &quorumdev_poll) != CS_OK) {
                quorumdev_poll = DEFAULT_QDEV_POLL;
        }
+#endif
 
        icmap_get_uint8("quorum.two_node", &two_node);
 
@@ -1261,6 +1273,7 @@ static int quorum_lib_exit_fn (void *conn)
  * library internal functions
  */
 
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
 static void quorum_device_timer_fn(void *arg)
 {
        ENTER();
@@ -1282,6 +1295,7 @@ static void quorum_device_timer_fn(void *arg)
 
        LEAVE();
 }
+#endif
 
 /*
  * Library Handler Functions
@@ -1439,6 +1453,72 @@ error_exit:
        LEAVE();
 }
 
+static void message_handler_req_lib_votequorum_trackstart (void *conn,
+                                                          const void *message)
+{
+       const struct req_lib_votequorum_trackstart *req_lib_votequorum_trackstart = message;
+       struct res_lib_votequorum_status res_lib_votequorum_status;
+       struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
+
+       ENTER();
+       /*
+        * If an immediate listing of the current cluster membership
+        * is requested, generate membership list
+        */
+       if (req_lib_votequorum_trackstart->track_flags & CS_TRACK_CURRENT ||
+           req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES) {
+               log_printf(LOGSYS_LEVEL_DEBUG, "sending initial status to %p\n", conn);
+               votequorum_exec_send_quorum_notification(conn, req_lib_votequorum_trackstart->context);
+       }
+
+       /*
+        * Record requests for tracking
+        */
+       if (req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES ||
+           req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES_ONLY) {
+
+               quorum_pd->track_flags = req_lib_votequorum_trackstart->track_flags;
+               quorum_pd->tracking_enabled = 1;
+               quorum_pd->tracking_context = req_lib_votequorum_trackstart->context;
+
+               list_add (&quorum_pd->list, &trackers_list);
+       }
+
+       res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
+       res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
+       res_lib_votequorum_status.header.error = CS_OK;
+       corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
+
+       LEAVE();
+}
+
+static void message_handler_req_lib_votequorum_trackstop (void *conn,
+                                                         const void *message)
+{
+       struct res_lib_votequorum_status res_lib_votequorum_status;
+       struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
+       int error = CS_OK;
+
+       ENTER();
+
+       if (quorum_pd->tracking_enabled) {
+               error = CS_OK;
+               quorum_pd->tracking_enabled = 0;
+               list_del (&quorum_pd->list);
+               list_init (&quorum_pd->list);
+       } else {
+               error = CS_ERR_NOT_EXIST;
+       }
+
+       res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
+       res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
+       res_lib_votequorum_status.header.error = error;
+       corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
+
+       LEAVE();
+}
+
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
 static void message_handler_req_lib_votequorum_qdisk_register (void *conn,
                                                               const void *message)
 {
@@ -1562,68 +1642,4 @@ static void message_handler_req_lib_votequorum_qdisk_getinfo (void *conn,
 
        LEAVE();
 }
-
-static void message_handler_req_lib_votequorum_trackstart (void *conn,
-                                                          const void *message)
-{
-       const struct req_lib_votequorum_trackstart *req_lib_votequorum_trackstart = message;
-       struct res_lib_votequorum_status res_lib_votequorum_status;
-       struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
-
-       ENTER();
-       /*
-        * If an immediate listing of the current cluster membership
-        * is requested, generate membership list
-        */
-       if (req_lib_votequorum_trackstart->track_flags & CS_TRACK_CURRENT ||
-           req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES) {
-               log_printf(LOGSYS_LEVEL_DEBUG, "sending initial status to %p\n", conn);
-               votequorum_exec_send_quorum_notification(conn, req_lib_votequorum_trackstart->context);
-       }
-
-       /*
-        * Record requests for tracking
-        */
-       if (req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES ||
-           req_lib_votequorum_trackstart->track_flags & CS_TRACK_CHANGES_ONLY) {
-
-               quorum_pd->track_flags = req_lib_votequorum_trackstart->track_flags;
-               quorum_pd->tracking_enabled = 1;
-               quorum_pd->tracking_context = req_lib_votequorum_trackstart->context;
-
-               list_add (&quorum_pd->list, &trackers_list);
-       }
-
-       res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
-       res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
-       res_lib_votequorum_status.header.error = CS_OK;
-       corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
-
-       LEAVE();
-}
-
-static void message_handler_req_lib_votequorum_trackstop (void *conn,
-                                                         const void *message)
-{
-       struct res_lib_votequorum_status res_lib_votequorum_status;
-       struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
-       int error = CS_OK;
-
-       ENTER();
-
-       if (quorum_pd->tracking_enabled) {
-               error = CS_OK;
-               quorum_pd->tracking_enabled = 0;
-               list_del (&quorum_pd->list);
-               list_init (&quorum_pd->list);
-       } else {
-               error = CS_ERR_NOT_EXIST;
-       }
-
-       res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
-       res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
-       res_lib_votequorum_status.header.error = error;
-       corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
-
-       LEAVE();
-}
+#endif
index 8a59d09874c147af1f2b215304f97f80a23a6e62..d0839461d45a2ce749be683add231d8994dd07d5 100644 (file)
@@ -42,12 +42,15 @@ enum req_votequorum_types {
        MESSAGE_REQ_VOTEQUORUM_GETINFO = 0,
        MESSAGE_REQ_VOTEQUORUM_SETEXPECTED,
        MESSAGE_REQ_VOTEQUORUM_SETVOTES,
+       MESSAGE_REQ_VOTEQUORUM_TRACKSTART,
+       MESSAGE_REQ_VOTEQUORUM_TRACKSTOP
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
+       ,
        MESSAGE_REQ_VOTEQUORUM_QDISK_REGISTER,
        MESSAGE_REQ_VOTEQUORUM_QDISK_UNREGISTER,
        MESSAGE_REQ_VOTEQUORUM_QDISK_POLL,
-       MESSAGE_REQ_VOTEQUORUM_QDISK_GETINFO,
-       MESSAGE_REQ_VOTEQUORUM_TRACKSTART,
-       MESSAGE_REQ_VOTEQUORUM_TRACKSTOP
+       MESSAGE_REQ_VOTEQUORUM_QDISK_GETINFO
+#endif
 };
 
 enum res_votequorum_types {
index 45ffddc7f5acd54cd44b72401decabbc49d93cb6..9292ca1c951cfc7bd404e233d8d54552c40db771 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009-2011 Red Hat, Inc.
+ * Copyright (c) 2009-2012 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -42,7 +42,9 @@ extern "C" {
 
 typedef uint64_t votequorum_handle_t;
 
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
 #define VOTEQUORUM_MAX_QDISK_NAME_LEN 255
+#endif
 
 #define VOTEQUORUM_INFO_FLAG_TWONODE            1
 #define VOTEQUORUM_INFO_FLAG_QUORATE            2
@@ -70,11 +72,13 @@ struct votequorum_info {
        unsigned int flags;
 };
 
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
 struct votequorum_qdisk_info {
        unsigned int votes;
        unsigned int state;
        char name[VOTEQUORUM_MAX_QDISK_NAME_LEN];
 };
+#endif
 
 typedef struct {
        uint32_t nodeid;
@@ -153,6 +157,29 @@ cs_error_t votequorum_setvotes (
        unsigned int nodeid,
        unsigned int votes);
 
+/**
+ * Track node and quorum changes
+ */
+cs_error_t votequorum_trackstart (
+       votequorum_handle_t handle,
+       uint64_t context,
+       unsigned int flags );
+
+cs_error_t votequorum_trackstop (
+       votequorum_handle_t handle);
+
+/**
+ * Save and retrieve private data/context
+ */
+cs_error_t votequorum_context_get (
+       votequorum_handle_t handle,
+       void **context);
+
+cs_error_t votequorum_context_set (
+       votequorum_handle_t handle,
+       void *context);
+
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
 /**
  * Register a quorum device
  *
@@ -183,27 +210,7 @@ cs_error_t votequorum_qdisk_getinfo (
        votequorum_handle_t handle,
        struct votequorum_qdisk_info *info);
 
-/**
- * Track node and quorum changes
- */
-cs_error_t votequorum_trackstart (
-       votequorum_handle_t handle,
-       uint64_t context,
-       unsigned int flags );
-
-cs_error_t votequorum_trackstop (
-       votequorum_handle_t handle);
-
-/**
- * Save and retrieve private data/context
- */
-cs_error_t votequorum_context_get (
-       votequorum_handle_t handle,
-       void **context);
-
-cs_error_t votequorum_context_set (
-       votequorum_handle_t handle,
-       void *context);
+#endif
 
 #ifdef __cplusplus
 }
index 21468feadbd5fbec1e6542001e0202d43a59489f..e3ad3f9c8bcad2f0b69bc916c849166b5f058e3b 100644 (file)
@@ -272,182 +272,6 @@ error_exit:
        return (error);
 }
 
-cs_error_t votequorum_qdisk_register (
-       votequorum_handle_t handle,
-       const char *name,
-       unsigned int votes)
-{
-       cs_error_t error;
-       struct votequorum_inst *votequorum_inst;
-       struct iovec iov;
-       struct req_lib_votequorum_qdisk_register req_lib_votequorum_qdisk_register;
-       struct res_lib_votequorum_status res_lib_votequorum_status;
-
-       if (strlen(name) > VOTEQUORUM_MAX_QDISK_NAME_LEN)
-               return CS_ERR_INVALID_PARAM;
-
-       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_qdisk_register.header.size = sizeof (struct req_lib_votequorum_qdisk_register);
-       req_lib_votequorum_qdisk_register.header.id = MESSAGE_REQ_VOTEQUORUM_QDISK_REGISTER;
-       strcpy(req_lib_votequorum_qdisk_register.name, name);
-       req_lib_votequorum_qdisk_register.votes = votes;
-
-       iov.iov_base = (char *)&req_lib_votequorum_qdisk_register;
-       iov.iov_len = sizeof (struct req_lib_votequorum_qdisk_register);
-
-        error = qb_to_cs_error(qb_ipcc_sendv_recv (
-               votequorum_inst->c,
-               &iov,
-               1,
-                &res_lib_votequorum_status,
-               sizeof (struct res_lib_votequorum_status), CS_IPC_TIMEOUT_MS));
-
-       if (error != CS_OK) {
-               goto error_exit;
-       }
-
-       error = res_lib_votequorum_status.header.error;
-
-error_exit:
-       hdb_handle_put (&votequorum_handle_t_db, handle);
-
-       return (error);
-}
-
-cs_error_t votequorum_qdisk_poll (
-       votequorum_handle_t handle,
-       unsigned int state)
-{
-       cs_error_t error;
-       struct votequorum_inst *votequorum_inst;
-       struct iovec iov;
-       struct req_lib_votequorum_qdisk_poll req_lib_votequorum_qdisk_poll;
-       struct res_lib_votequorum_status res_lib_votequorum_status;
-
-       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_qdisk_poll.header.size = sizeof (struct req_lib_votequorum_qdisk_poll);
-       req_lib_votequorum_qdisk_poll.header.id = MESSAGE_REQ_VOTEQUORUM_QDISK_POLL;
-       req_lib_votequorum_qdisk_poll.state = state;
-
-       iov.iov_base = (char *)&req_lib_votequorum_qdisk_poll;
-       iov.iov_len = sizeof (struct req_lib_votequorum_qdisk_poll);
-
-        error = qb_to_cs_error(qb_ipcc_sendv_recv (
-               votequorum_inst->c,
-               &iov,
-               1,
-                &res_lib_votequorum_status,
-               sizeof (struct res_lib_votequorum_status), CS_IPC_TIMEOUT_MS));
-
-       if (error != CS_OK) {
-               goto error_exit;
-       }
-
-       error = res_lib_votequorum_status.header.error;
-
-error_exit:
-       hdb_handle_put (&votequorum_handle_t_db, handle);
-
-       return (error);
-}
-
-cs_error_t votequorum_qdisk_unregister (
-       votequorum_handle_t handle)
-{
-       cs_error_t error;
-       struct votequorum_inst *votequorum_inst;
-       struct iovec iov;
-       struct req_lib_votequorum_general req_lib_votequorum_general;
-       struct res_lib_votequorum_status res_lib_votequorum_status;
-
-       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_general.header.size = sizeof (struct req_lib_votequorum_general);
-       req_lib_votequorum_general.header.id = MESSAGE_REQ_VOTEQUORUM_QDISK_UNREGISTER;
-
-       iov.iov_base = (char *)&req_lib_votequorum_general;
-       iov.iov_len = sizeof (struct req_lib_votequorum_general);
-
-        error = qb_to_cs_error(qb_ipcc_sendv_recv (
-               votequorum_inst->c,
-               &iov,
-               1,
-                &res_lib_votequorum_status,
-               sizeof (struct res_lib_votequorum_status), CS_IPC_TIMEOUT_MS));
-
-       if (error != CS_OK) {
-               goto error_exit;
-       }
-
-       error = res_lib_votequorum_status.header.error;
-
-error_exit:
-       hdb_handle_put (&votequorum_handle_t_db, handle);
-
-       return (error);
-}
-
-
-
-cs_error_t votequorum_qdisk_getinfo (
-       votequorum_handle_t handle,
-       struct votequorum_qdisk_info *qinfo)
-{
-       cs_error_t error;
-       struct votequorum_inst *votequorum_inst;
-       struct iovec iov;
-       struct req_lib_votequorum_general req_lib_votequorum_general;
-       struct res_lib_votequorum_qdisk_getinfo res_lib_votequorum_qdisk_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_general.header.size = sizeof (struct req_lib_votequorum_general);
-       req_lib_votequorum_general.header.id = MESSAGE_REQ_VOTEQUORUM_QDISK_GETINFO;
-
-       iov.iov_base = (char *)&req_lib_votequorum_general;
-       iov.iov_len = sizeof (struct req_lib_votequorum_general);
-
-        error = qb_to_cs_error(qb_ipcc_sendv_recv (
-               votequorum_inst->c,
-               &iov,
-               1,
-                &res_lib_votequorum_qdisk_getinfo,
-               sizeof (struct res_lib_votequorum_qdisk_getinfo), CS_IPC_TIMEOUT_MS));
-
-       if (error != CS_OK) {
-               goto error_exit;
-       }
-
-       error = res_lib_votequorum_qdisk_getinfo.header.error;
-
-       qinfo->votes = res_lib_votequorum_qdisk_getinfo.votes;
-       qinfo->state = res_lib_votequorum_qdisk_getinfo.state;
-       strcpy(qinfo->name, res_lib_votequorum_qdisk_getinfo.name);
-
-
-error_exit:
-       hdb_handle_put (&votequorum_handle_t_db, handle);
-
-       return (error);
-}
-
 cs_error_t votequorum_trackstart (
        votequorum_handle_t handle,
        uint64_t context,
@@ -704,3 +528,180 @@ error_put:
        hdb_handle_put (&votequorum_handle_t_db, handle);
        return (error);
 }
+
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
+cs_error_t votequorum_qdisk_register (
+       votequorum_handle_t handle,
+       const char *name,
+       unsigned int votes)
+{
+       cs_error_t error;
+       struct votequorum_inst *votequorum_inst;
+       struct iovec iov;
+       struct req_lib_votequorum_qdisk_register req_lib_votequorum_qdisk_register;
+       struct res_lib_votequorum_status res_lib_votequorum_status;
+
+       if (strlen(name) > VOTEQUORUM_MAX_QDISK_NAME_LEN)
+               return CS_ERR_INVALID_PARAM;
+
+       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_qdisk_register.header.size = sizeof (struct req_lib_votequorum_qdisk_register);
+       req_lib_votequorum_qdisk_register.header.id = MESSAGE_REQ_VOTEQUORUM_QDISK_REGISTER;
+       strcpy(req_lib_votequorum_qdisk_register.name, name);
+       req_lib_votequorum_qdisk_register.votes = votes;
+
+       iov.iov_base = (char *)&req_lib_votequorum_qdisk_register;
+       iov.iov_len = sizeof (struct req_lib_votequorum_qdisk_register);
+
+        error = qb_to_cs_error(qb_ipcc_sendv_recv (
+               votequorum_inst->c,
+               &iov,
+               1,
+                &res_lib_votequorum_status,
+               sizeof (struct res_lib_votequorum_status), CS_IPC_TIMEOUT_MS));
+
+       if (error != CS_OK) {
+               goto error_exit;
+       }
+
+       error = res_lib_votequorum_status.header.error;
+
+error_exit:
+       hdb_handle_put (&votequorum_handle_t_db, handle);
+
+       return (error);
+}
+
+cs_error_t votequorum_qdisk_poll (
+       votequorum_handle_t handle,
+       unsigned int state)
+{
+       cs_error_t error;
+       struct votequorum_inst *votequorum_inst;
+       struct iovec iov;
+       struct req_lib_votequorum_qdisk_poll req_lib_votequorum_qdisk_poll;
+       struct res_lib_votequorum_status res_lib_votequorum_status;
+
+       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_qdisk_poll.header.size = sizeof (struct req_lib_votequorum_qdisk_poll);
+       req_lib_votequorum_qdisk_poll.header.id = MESSAGE_REQ_VOTEQUORUM_QDISK_POLL;
+       req_lib_votequorum_qdisk_poll.state = state;
+
+       iov.iov_base = (char *)&req_lib_votequorum_qdisk_poll;
+       iov.iov_len = sizeof (struct req_lib_votequorum_qdisk_poll);
+
+        error = qb_to_cs_error(qb_ipcc_sendv_recv (
+               votequorum_inst->c,
+               &iov,
+               1,
+                &res_lib_votequorum_status,
+               sizeof (struct res_lib_votequorum_status), CS_IPC_TIMEOUT_MS));
+
+       if (error != CS_OK) {
+               goto error_exit;
+       }
+
+       error = res_lib_votequorum_status.header.error;
+
+error_exit:
+       hdb_handle_put (&votequorum_handle_t_db, handle);
+
+       return (error);
+}
+
+cs_error_t votequorum_qdisk_unregister (
+       votequorum_handle_t handle)
+{
+       cs_error_t error;
+       struct votequorum_inst *votequorum_inst;
+       struct iovec iov;
+       struct req_lib_votequorum_general req_lib_votequorum_general;
+       struct res_lib_votequorum_status res_lib_votequorum_status;
+
+       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_general.header.size = sizeof (struct req_lib_votequorum_general);
+       req_lib_votequorum_general.header.id = MESSAGE_REQ_VOTEQUORUM_QDISK_UNREGISTER;
+
+       iov.iov_base = (char *)&req_lib_votequorum_general;
+       iov.iov_len = sizeof (struct req_lib_votequorum_general);
+
+        error = qb_to_cs_error(qb_ipcc_sendv_recv (
+               votequorum_inst->c,
+               &iov,
+               1,
+                &res_lib_votequorum_status,
+               sizeof (struct res_lib_votequorum_status), CS_IPC_TIMEOUT_MS));
+
+       if (error != CS_OK) {
+               goto error_exit;
+       }
+
+       error = res_lib_votequorum_status.header.error;
+
+error_exit:
+       hdb_handle_put (&votequorum_handle_t_db, handle);
+
+       return (error);
+}
+
+cs_error_t votequorum_qdisk_getinfo (
+       votequorum_handle_t handle,
+       struct votequorum_qdisk_info *qinfo)
+{
+       cs_error_t error;
+       struct votequorum_inst *votequorum_inst;
+       struct iovec iov;
+       struct req_lib_votequorum_general req_lib_votequorum_general;
+       struct res_lib_votequorum_qdisk_getinfo res_lib_votequorum_qdisk_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_general.header.size = sizeof (struct req_lib_votequorum_general);
+       req_lib_votequorum_general.header.id = MESSAGE_REQ_VOTEQUORUM_QDISK_GETINFO;
+
+       iov.iov_base = (char *)&req_lib_votequorum_general;
+       iov.iov_len = sizeof (struct req_lib_votequorum_general);
+
+        error = qb_to_cs_error(qb_ipcc_sendv_recv (
+               votequorum_inst->c,
+               &iov,
+               1,
+                &res_lib_votequorum_qdisk_getinfo,
+               sizeof (struct res_lib_votequorum_qdisk_getinfo), CS_IPC_TIMEOUT_MS));
+
+       if (error != CS_OK) {
+               goto error_exit;
+       }
+
+       error = res_lib_votequorum_qdisk_getinfo.header.error;
+
+       qinfo->votes = res_lib_votequorum_qdisk_getinfo.votes;
+       qinfo->state = res_lib_votequorum_qdisk_getinfo.state;
+       strcpy(qinfo->name, res_lib_votequorum_qdisk_getinfo.name);
+
+
+error_exit:
+       hdb_handle_put (&votequorum_handle_t_db, handle);
+
+       return (error);
+}
+#endif
+
index 0d81234bda772ff5f1233c6f5088621094e75dda..e702131255f3fd761fa5dd9a561e39b5cddb8270 100644 (file)
@@ -42,9 +42,9 @@
 #include <corosync/corotypes.h>
 #include <corosync/votequorum.h>
 
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
 static votequorum_handle_t handle;
 
-
 static void print_info(int ok_to_fail)
 {
        struct votequorum_qdisk_info qinfo;
@@ -59,9 +59,11 @@ static void print_info(int ok_to_fail)
                printf("\n");
        }
 }
+#endif
 
 int main(int argc, char *argv[])
 {
+#ifdef EXPERIMENTAL_QUORUM_DEVICE_API
        int pollcount=0, polltime=1;
        int err;
 
@@ -95,5 +97,9 @@ int main(int argc, char *argv[])
        }
        print_info(1);
 
+       votequorum_finalize(handle);
+#else
+       fprintf(stderr, "qdisk support is not built in corosync/votequorum\n"); 
+#endif
        return 0;
 }