summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c69
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c4
3 files changed, 76 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 17a8b06f433..ed9e70b9caa 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -6811,6 +6811,60 @@ glusterd_volume_defrag_restart (glusterd_volinfo_t *volinfo, char *op_errstr,
return ret;
}
+
+void
+glusterd_defrag_info_set (glusterd_volinfo_t *volinfo, dict_t *dict, int cmd,
+ int status, int op)
+{
+
+ xlator_t *this = NULL;
+ dict_t *op_ctx = NULL;
+ int ret = -1;
+ char *task_id_str = NULL;
+ glusterd_rebalance_t *rebal = NULL;
+
+ this = THIS;
+ rebal = &volinfo->rebal;
+
+ rebal->defrag_cmd = cmd;
+ rebal->defrag_status = status;
+ rebal->op = op;
+
+ if (!rebal->rebalance_id)
+ return;
+
+ if (is_origin_glusterd (dict)) {
+
+ ret = glusterd_generate_and_set_task_id(dict,
+ GF_REBALANCE_TID_KEY);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_TASKID_GEN_FAIL,
+ "Failed to generate task-id");
+ goto out;
+ }
+ }
+ ret = dict_get_str (dict, GF_REBALANCE_TID_KEY,
+ &task_id_str);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ GD_MSG_REBALANCE_ID_MISSING, "Missing rebalance-id");
+ ret = 0;
+ goto out;
+ }
+
+ gf_uuid_parse (task_id_str, rebal->rebalance_id);
+out:
+
+ if (ret) {
+ gf_msg_debug (this->name, 0,
+ "Rebalance start validate failed");
+ }
+ return;
+
+}
+
+
void
glusterd_restart_rebalance_for_volume (glusterd_volinfo_t *volinfo)
{
@@ -6819,8 +6873,21 @@ glusterd_restart_rebalance_for_volume (glusterd_volinfo_t *volinfo)
if (!volinfo->rebal.defrag_cmd)
return;
- if (!gd_should_i_start_rebalance (volinfo))
+ if (!gd_should_i_start_rebalance (volinfo)) {
+
+ /* Store the rebalance-id and rebalance command even if
+ * the peer isn't starting a rebalance process. On peers
+ * where a rebalance process is started,
+ * glusterd_handle_defrag_start performs the storing.
+ *
+ * Storing this is needed for having 'volume status'
+ * work correctly.
+ */
+ if (volinfo->type == GF_CLUSTER_TYPE_TIER)
+ glusterd_store_perform_node_state_store (volinfo);
+
return;
+ }
glusterd_volume_defrag_restart (volinfo, op_errstr, PATH_MAX,
volinfo->rebal.defrag_cmd, NULL);
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 84e1fa5d4be..4df04f7f321 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -364,6 +364,10 @@ glusterd_restart_rebalance (glusterd_conf_t *conf);
void
glusterd_restart_rebalance_for_volume (glusterd_volinfo_t *volinfo);
+void
+glusterd_defrag_info_set (glusterd_volinfo_t *volinfo, dict_t *dict, int cmd,
+ int status, int op);
+
int32_t
glusterd_add_bricks_hname_path_to_dict (dict_t *dict,
glusterd_volinfo_t *volinfo);
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index 3174c114875..a07d7612576 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -2461,6 +2461,10 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr)
}
if (volinfo->type == GF_CLUSTER_TYPE_TIER) {
+ glusterd_defrag_info_set (volinfo, dict,
+ GF_DEFRAG_CMD_START_TIER,
+ GF_DEFRAG_CMD_START,
+ GD_OP_REBALANCE);
glusterd_restart_rebalance_for_volume (volinfo);
}