summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-09-13 16:54:24 +0530
committerVijay Bellur <vijay@gluster.com>2011-09-13 09:55:26 -0700
commitb039cb193eddc51c6f31bf9a230281faada475fe (patch)
tree8d4aefbf3fda4366bb1e8699fd575e872f161f67 /xlators/mgmt/glusterd
parent25daa42911d2ff697880ee29c591cac5f2abebed (diff)
glusterd rebalance: fix minor issues
there were bugs introduced due to parallelizing rebalance op. * argument to dict_set_str () should be static as for the life of dict * uuid_utoa() output should not be considered as static * overloading 'volinfo->defrag' in other nodes is a overkill, just KISS Change-Id: I43d00c8e22beb2dd5c5f9824552f7337543b2255 BUG: 2112 Reviewed-on: http://review.gluster.com/407 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c31
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c46
2 files changed, 42 insertions, 35 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index 8832c69ed4f..66467373b5c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -945,7 +945,16 @@ glusterd_op_add_brick (dict_t *dict, char **op_errstr)
goto out;
}
- volinfo->defrag_status = 0;
+ /* Need to reset the defrag/rebalance status accordingly */
+ switch (volinfo->defrag_status) {
+ case GF_DEFRAG_STATUS_FAILED:
+ case GF_DEFRAG_STATUS_COMPLETE:
+ case GF_DEFRAG_STATUS_LAYOUT_FIX_COMPLETE:
+ case GF_DEFRAG_STATUS_MIGRATE_DATA_COMPLETE:
+ volinfo->defrag_status = 0;
+ default:
+ break;
+ }
ret = glusterd_store_volinfo (volinfo, GLUSTERD_VOLINFO_VER_AC_INCREMENT);
if (ret)
@@ -1006,9 +1015,6 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
case GF_OP_CMD_PAUSE:
{
if (volinfo->decommission_in_progress) {
- if (volinfo->defrag == (void *)1)
- volinfo->defrag = NULL;
-
if (volinfo->defrag) {
LOCK (&volinfo->defrag->lock);
@@ -1026,9 +1032,6 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
case GF_OP_CMD_ABORT:
{
if (volinfo->decommission_in_progress) {
- if (volinfo->defrag == (void *)1)
- volinfo->defrag = NULL;
-
if (volinfo->defrag) {
LOCK (&volinfo->defrag->lock);
@@ -1054,9 +1057,6 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
case GF_OP_CMD_COMMIT_FORCE:
if (volinfo->decommission_in_progress) {
- if (volinfo->defrag == (void *)1)
- volinfo->defrag = NULL;
-
if (volinfo->defrag) {
LOCK (&volinfo->defrag->lock);
/* Fake 'rebalance-complete' so the graph change
@@ -1109,7 +1109,16 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
goto out;
}
- volinfo->defrag_status = 0;
+ /* Need to reset the defrag/rebalance status accordingly */
+ switch (volinfo->defrag_status) {
+ case GF_DEFRAG_STATUS_FAILED:
+ case GF_DEFRAG_STATUS_COMPLETE:
+ case GF_DEFRAG_STATUS_LAYOUT_FIX_COMPLETE:
+ case GF_DEFRAG_STATUS_MIGRATE_DATA_COMPLETE:
+ volinfo->defrag_status = 0;
+ default:
+ break;
+ }
if (!force && need_rebalance) {
/* perform the rebalance operations */
ret = glusterd_handle_defrag_start (volinfo, err_str, 4096,
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index defaf947f4d..934c927732a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -332,18 +332,20 @@ glusterd_defrag_stop (glusterd_volinfo_t *volinfo, u_quad_t *files,
GF_ASSERT (size);
GF_ASSERT (op_errstr);
- if (!volinfo || !volinfo->defrag) {
+ if (!volinfo) {
ret = -1;
goto out;
}
ret = glusterd_defrag_stop_validate (volinfo, op_errstr, len);
- if (ret)
+ if (ret) {
+ /* rebalance may be happening on other nodes */
+ ret = 0;
goto out;
+ }
ret = 0;
if (volinfo->defrag_status == GF_DEFRAG_STATUS_NOT_STARTED) {
- volinfo->defrag = NULL;
goto out;
}
@@ -691,10 +693,11 @@ out:
int
glusterd_handle_defrag_volume_v2 (rpcsvc_request_t *req)
{
- int32_t ret = -1;
- gf1_cli_defrag_vol_req cli_req = {0,};
- glusterd_conf_t *priv = NULL;
- dict_t *dict = NULL;
+ int32_t ret = -1;
+ gf1_cli_defrag_vol_req cli_req = {0,};
+ glusterd_conf_t *priv = NULL;
+ dict_t *dict = NULL;
+ char *volname = NULL;
GF_ASSERT (req);
@@ -713,11 +716,16 @@ glusterd_handle_defrag_volume_v2 (rpcsvc_request_t *req)
if (!dict)
goto out;
- ret = dict_set_str (dict, "volname", cli_req.volname);
+ volname = gf_strdup (cli_req.volname);
+ if (!volname)
+ goto out;
+
+ /* let 'volname' be freed in dict_destroy */
+ ret = dict_set_dynstr (dict, "volname", volname);
if (ret)
goto out;
- ret = dict_set_str (dict, "node-uuid", uuid_utoa (priv->uuid));
+ ret = dict_set_static_bin (dict, "node-uuid", priv->uuid, 16);
if (ret)
goto out;
@@ -738,6 +746,7 @@ out:
ret = glusterd_op_send_cli_response (GD_OP_REBALANCE, ret, 0, req,
NULL, "operation failed");
}
+
if (cli_req.volname)
free (cli_req.volname);//malloced by xdr
@@ -806,8 +815,7 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
glusterd_volinfo_t *volinfo = NULL;
uint64_t files = 0;
uint64_t size = 0;
- char *uuid_str = NULL;
- uuid_t node_uuid = {0,};
+ void *node_uuid = NULL;
glusterd_conf_t *priv = NULL;
dict_t *tmp_dict = NULL;
@@ -824,6 +832,7 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
gf_log (THIS->name, GF_LOG_DEBUG, "command not given");
goto out;
}
+
ret = glusterd_rebalance_cmd_validate (cmd, volname, &volinfo,
msg, sizeof (msg));
if (ret) {
@@ -833,28 +842,17 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if ((cmd != GF_DEFRAG_CMD_STATUS) ||
(cmd != GF_DEFRAG_CMD_STOP)) {
- ret = dict_get_str (dict, "node-uuid", &uuid_str);
+ ret = dict_get_ptr (dict, "node-uuid", &node_uuid);
if (ret) {
gf_log (THIS->name, GF_LOG_DEBUG, "node-uuid not found");
goto out;
}
- ret = uuid_parse (uuid_str, node_uuid);
- if (ret) {
- gf_log (THIS->name, GF_LOG_DEBUG,
- "uuid-unparse failed %s", uuid_str);
- goto out;
- }
-
/* perform this on only the node which has
issued the command */
if (uuid_compare (node_uuid, priv->uuid)) {
gf_log (THIS->name, GF_LOG_DEBUG,
- "not the source node %s %s", uuid_str,
- uuid_utoa (priv->uuid));
- /* Need to initialize the 'volinfo->defrag' to some
- value to say operation is in progress */
- volinfo->defrag = (void *)1;
+ "not the source node %s", uuid_utoa (priv->uuid));
goto out;
}
}