Re: [PATCH 2/2] votequorum: ifdef qdiskd API out

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reviewed-by: Steven Dake <sdake@xxxxxxxxxx>

On 01/18/2012 03:53 AM, Fabio M. Di Nitto wrote:
> From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx>
> 
> as agreed, the API has not been tested yet. Adding later is better than
> removing it.
> 
> Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx>
> ---
>  exec/votequorum.c                 |  168 ++++++++++--------
>  include/corosync/ipc_votequorum.h |    9 +-
>  include/corosync/votequorum.h     |   51 +++---
>  lib/votequorum.c                  |  353 +++++++++++++++++++------------------
>  test/testvotequorum2.c            |    8 +-
>  5 files changed, 311 insertions(+), 278 deletions(-)
> 
> diff --git a/exec/votequorum.c b/exec/votequorum.c
> index d3f7757..f465714 100644
> --- a/exec/votequorum.c
> +++ b/exec/votequorum.c
> @@ -67,10 +67,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);
>  
> @@ -1260,6 +1272,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();
> @@ -1281,6 +1294,7 @@ static void quorum_device_timer_fn(void *arg)
>  
>  	LEAVE();
>  }
> +#endif
>  
>  /*
>   * Library Handler Functions
> @@ -1438,6 +1452,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)
>  {
> @@ -1561,68 +1641,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
> diff --git a/include/corosync/ipc_votequorum.h b/include/corosync/ipc_votequorum.h
> index 8a59d09..d083946 100644
> --- a/include/corosync/ipc_votequorum.h
> +++ b/include/corosync/ipc_votequorum.h
> @@ -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 {
> diff --git a/include/corosync/votequorum.h b/include/corosync/votequorum.h
> index 45ffddc..9292ca1 100644
> --- a/include/corosync/votequorum.h
> +++ b/include/corosync/votequorum.h
> @@ -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;
> @@ -154,6 +158,29 @@ cs_error_t votequorum_setvotes (
>  	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
>   *
>   * it will be DEAD until polled
> @@ -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
>  }
> diff --git a/lib/votequorum.c b/lib/votequorum.c
> index 21468fe..e3ad3f9 100644
> --- a/lib/votequorum.c
> +++ b/lib/votequorum.c
> @@ -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
> +
> diff --git a/test/testvotequorum2.c b/test/testvotequorum2.c
> index 0d81234..e702131 100644
> --- a/test/testvotequorum2.c
> +++ b/test/testvotequorum2.c
> @@ -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;
>  }

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux