cman: improve cman/qdisk interactions
PATCH 1/1 cman: improve cman/qdisk interactions
- libcman/cman: add new quorum API call to update name and votes of a quorum device
- cman: simplify common code to free quorum_device infrastructure and handle quorum recalculation
- cman: do better logging/error reports of the quorum API usage
- cman: use strdup instead of malloc+strcpy (code is more readable)
- libcman: perform better error checking in register_quorum_device/update_quorum_device
- Allow qdisk to update device name in cman using a new libcman quorum API call
- Perform slight better error checking of some update opertaions
Resolves: rhbz#735917
--- cman/daemon/cnxman-socket.h | 1 + cman/daemon/commands.c | 135 +++++++++++++++++++++++++++++++++---------- cman/lib/libcman.c | 19 +++++- cman/lib/libcman.h | 4 + cman/qdisk/main.c | 28 ++++++++- 5 files changed, 150 insertions(+), 37 deletions(-)
cman/daemon/cnxman-socket.h +1 -0
@@ -32,6 +32,7 @@#define CMAN_CMD_REG_QUORUMDEV 0x800000b5#define CMAN_CMD_UNREG_QUORUMDEV 0x800000b6#define CMAN_CMD_POLL_QUORUMDEV 0x800000b7 +#define CMAN_CMD_UPDATE_QUORUMDEV 0x800000b8#define CMAN_CMD_TRY_SHUTDOWN 0x800000bb#define CMAN_CMD_SHUTDOWN_REPLY 0x000000bc#define CMAN_CMD_UPDATE_FENCE_INFO 0x800000bd
cman/daemon/commands.c +104 -31
189 lines not on this page · raw message
cman/lib/libcman.c +15 -4
@@ -1002,14 +1002,15 @@ int cman_replyto_shutdown(cman_handle_t handle, int yesno)return 0 ; } - -int cman_register_quorum_device (cman_handle_t handle,char *name,int votes) +static int cman_set_quorum_device (cman_handle_t handle, +int ops, +char *name,int votes) {struct cman_handle *h = (struct cman_handle *)handle;char buf[strlen (name)+1 +sizeof (int )];VALIDATE_HANDLE (h); -if (strlen (name) >MAX_CLUSTER_MEMBER_NAME_LEN ) +if ((!name) || (strlen (name) >MAX_CLUSTER_MEMBER_NAME_LEN ) || (votes <0 )) { errno =EINVAL ;return -1 ;
@@ -1017,7 +1018,12 @@ int cman_register_quorum_device(cman_handle_t handle, char *name, int votes)memcpy (buf, &votes,sizeof (int ));strcpy (buf+sizeof (int ), name); -return info_call (h,CMAN_CMD_REG_QUORUMDEV , buf,strlen (name)+1 +sizeof (int ),NULL ,0 ); +return info_call (h, ops, buf,strlen (name)+1 +sizeof (int ),NULL ,0 ); +} + +int cman_register_quorum_device (cman_handle_t handle,char *name,int votes) +{ +return cman_set_quorum_device (handle,CMAN_CMD_REG_QUORUMDEV , name, votes); }int cman_unregister_quorum_device (cman_handle_t handle)
@@ -1053,6 +1059,11 @@ int cman_get_quorum_device(cman_handle_t handle, struct cman_qdev_info *info)return ret; } +int cman_update_quorum_device (cman_handle_t handle,char *name,int votes) +{ +return cman_set_quorum_device (handle,CMAN_CMD_UPDATE_QUORUMDEV , name, votes); +} +int cman_get_fenceinfo (cman_handle_t handle,int nodeid,uint64_t *time,int *fenced,char *agent) {struct cman_handle *h = (struct cman_handle *)handle;
cman/lib/libcman.h +4 -0
@@ -420,6 +420,9 @@ int cman_barrier_delete(cman_handle_t handle, const char *name);/* * Add your own quorum device here, needs an admin socket * +* register_quorum and update_quorum arguments are mandatory. +* name has to be a valid null-terminated string and votes >= 0. +* * After creating a quorum device you will need to call 'poll_quorum_device' * at least once every (default) 10 seconds (this can be changed in CCS) * otherwise it will time-out and the cluster will lose its vote.
@@ -428,6 +431,7 @@ int cman_register_quorum_device(cman_handle_t handle, char *name, int votes);int cman_unregister_quorum_device (cman_handle_t handle);int cman_poll_quorum_device (cman_handle_t handle,int isavailable);int cman_get_quorum_device (cman_handle_t handle,struct cman_qdev_info *info); +int cman_update_quorum_device (cman_handle_t handle,char *name,int votes);/* * Sets the dirty bit inside cman. This indicates that the node has
cman/qdisk/main.c +26 -2
@@ -690,6 +690,17 @@ register_device(qd_ctx *ctx) ctx->qc_votes : 0); } +static int +update_device (qd_ctx *ctx) +{ +return cman_update_quorum_device ( + ctx->qc_cman_admin, + (ctx->qc_flags&RF_CMAN_LABEL ) ? + ctx->qc_cman_label : ctx->qc_device, + (!(ctx->qc_flags &RF_MASTER_WINS ) || + ctx->qc_status ==S_MASTER ) ? + ctx->qc_votes :0 ); +}static int adjust_votes (qd_ctx *ctx)
@@ -2119,9 +2130,22 @@ main(int argc, char **argv)if (!_running) goto out; - +/* This registers the quorum device */ -register_device (&ctx); + ret =register_device (&ctx); +if (ret) { +if (errno ==EBUSY ) { +logt_print (LOG_NOTICE ,"quorum device is already registered, updating\n" ); + ret =update_device (&ctx); +if (ret) { +logt_print (LOG_ERR ,"Unable to update quorum device info!\n" ); + goto out; + } + }else { +logt_print (LOG_ERR ,"Unable to register quorum device!\n" ); + goto out; + } + }io_nanny_start (ch_user, ctx.qc_tko * ctx.qc_interval);
Signature · 1 line
1.7.4.4
PATCH 1/1 cman: improve cman/qdisk interactions
Quoted 6 lines · Fabio M. Di Nitto
- libcman/cman: add new quorum API call to update name and votes of a quorum device
- cman: simplify common code to freequorum_deviceinfrastructure and handle quorum recalculation
- cman: do better logging/error reports of the quorum API usage
- cman: use strdup instead of malloc+strcpy (code is more readable)
- libcman: perform better error checking in register_quorum_device/update_quorum_device
Quoted 6 lines
- Allow qdisk to update device name in cman using a new libcman quorum API call
- Perform slight better error checking of some update opertaionsResolves: rhbz#735917
Signed-off-by Fabio M. Di Nitto <[email protected]>
This last version addresses the few comments you had in the other patch.
Fabio
PATCH 1/1 cman: improve cman/qdisk interactions
In reply to Fabio M. Di NittoQuoted 8 lines · Fabio M. Di Nitto
- libcman/cman: add new quorum API call to update name and votes of a quorum device
- cman: simplify common code to freequorum_deviceinfrastructure and handle quorum recalculation
- cman: do better logging/error reports of the quorum API usage
- cman: use strdup instead of malloc+strcpy (code is more readable)
- libcman: perform better error checking in register_quorum_device/update_quorum_device- Allow qdisk to update device name in cman using a new libcman quorum API call
- Perform slight better error checking of some update opertaions
Thanks, looks good.
-- Lon
Signature · 1 line
Lon Hohberger - Red Hat, Inc.