summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-rebalance.c
diff options
context:
space:
mode:
authorhari gowtham <hgowtham@redhat.com>2015-12-16 16:18:29 +0530
committerDan Lambright <dlambrig@redhat.com>2015-12-22 17:45:00 -0800
commit85d34ea0cf8b687c10093ae06417e498e252e563 (patch)
tree6b35a09be0beb6d87c8cf7e81d4f064a788e4aa7 /xlators/mgmt/glusterd/src/glusterd-rebalance.c
parent86fa1507a15eb9e1e4a8e1e83785b5a46eee9aa4 (diff)
Tier: "tier start force" command implementation
back port of : http://review.gluster.org/#/c/12983/ The start command doesnt restart the tier deamon if the deamon is running at one node. hence to bring up the tierd on the nodes where the deamon is down, the force command is implemented. It skips the check for tierd running. >Change-Id: I0037d3e5ecfe56637d0da201a97903c435d26436 >BUG: 1292112 >Signed-off-by: hari gowtham <hgowtham@redhat.com> Change-Id: Idaca442c1a41ded8bf555a6e34eed0ebb9ea4034 BUG: 1293698 Signed-off-by: hari <hgowtham@redhat.com> Reviewed-on: http://review.gluster.org/13069 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Dan Lambright <dlambrig@redhat.com> Tested-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-rebalance.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c111
1 files changed, 79 insertions, 32 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index ea443aaa05e..5f49e4b8752 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -270,7 +270,8 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr,
priv);
snprintf (logfile, PATH_MAX, "%s/%s-%s-%s.log",
DEFAULT_LOG_FILE_DIRECTORY, volinfo->volname,
- (cmd == GF_DEFRAG_CMD_START_TIER ? "tier":"rebalance"),
+ (cmd == GF_DEFRAG_CMD_START_TIER ?
+ "tier":"rebalance"),
uuid_utoa(MY_UUID));
} else {
@@ -605,6 +606,7 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
char *task_id_str = NULL;
dict_t *op_ctx = NULL;
xlator_t *this = 0;
+ int32_t is_force = 0;
this = THIS;
GF_ASSERT (this);
@@ -629,16 +631,20 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
}
switch (cmd) {
case GF_DEFRAG_CMD_START_TIER:
+ ret = dict_get_int32 (dict, "force", &is_force);
+ if (ret)
+ is_force = 0;
+
if (volinfo->type != GF_CLUSTER_TYPE_TIER) {
gf_asprintf (op_errstr, "volume %s is not a tier "
"volume.", volinfo->volname);
ret = -1;
goto out;
}
- if (glusterd_is_tier_daemon_running (volinfo)) {
+ if ((!is_force) && glusterd_is_tier_daemon_running (volinfo)) {
ret = gf_asprintf (op_errstr, "A Tier daemon is "
- "already running on volume %s",
- volname);
+ "already running on volume %s",
+ volname);
ret = -1;
goto out;
}
@@ -797,6 +803,7 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
dict_t *ctx = NULL;
xlator_t *this = NULL;
uint32_t commit_hash;
+ int32_t is_force = 0;
this = THIS;
GF_ASSERT (this);
@@ -860,39 +867,79 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
case GF_DEFRAG_CMD_START_LAYOUT_FIX:
case GF_DEFRAG_CMD_START_FORCE:
case GF_DEFRAG_CMD_START_TIER:
- /* Reset defrag status to 'NOT STARTED' whenever a
- * remove-brick/rebalance command is issued to remove
- * stale information from previous run.
- */
- volinfo->rebal.defrag_status = GF_DEFRAG_STATUS_NOT_STARTED;
- ret = dict_get_str (dict, GF_REBALANCE_TID_KEY, &task_id_str);
- if (ret) {
- gf_msg_debug (this->name, 0, "Missing rebalance "
- "id");
- ret = 0;
+
+ ret = dict_get_int32 (dict, "force", &is_force);
+ if (ret)
+ is_force = 0;
+ if (!is_force) {
+ /* Reset defrag status to 'NOT STARTED' whenever a
+ * remove-brick/rebalance command is issued to remove
+ * stale information from previous run.
+ */
+ volinfo->rebal.defrag_status =
+ GF_DEFRAG_STATUS_NOT_STARTED;
+
+ ret = dict_get_str (dict, GF_REBALANCE_TID_KEY,
+ &task_id_str);
+ if (ret) {
+ gf_msg_debug (this->name, 0, "Missing rebalance"
+ " id");
+ ret = 0;
+ } else {
+ gf_uuid_parse (task_id_str,
+ volinfo->rebal.rebalance_id);
+ volinfo->rebal.op = GD_OP_REBALANCE;
+ }
+ 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.
+ */
+ glusterd_store_perform_node_state_store
+ (volinfo);
+ break;
+ }
+ if (dict_get_uint32 (dict, "commit-hash", &commit_hash)
+ == 0) {
+ volinfo->rebal.commit_hash = commit_hash;
+ }
+ ret = glusterd_handle_defrag_start (volinfo, msg,
+ sizeof (msg),
+ cmd, NULL, GD_OP_REBALANCE);
+ break;
} else {
- gf_uuid_parse (task_id_str, volinfo->rebal.rebalance_id) ;
- volinfo->rebal.op = GD_OP_REBALANCE;
- }
- 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.
+ /* Reset defrag status to 'STARTED' so that the
+ * pid is checked and restarted accordingly.
+ * If the pid is not running it executes the
+ * "NOT_STARTED" case and restarts the process
*/
- glusterd_store_perform_node_state_store (volinfo);
+ volinfo->rebal.defrag_status = GF_DEFRAG_STATUS_STARTED;
+ volinfo->rebal.defrag_cmd = cmd;
+ volinfo->rebal.op = GD_OP_REBALANCE;
+
+ ret = dict_get_str (dict, GF_REBALANCE_TID_KEY,
+ &task_id_str);
+ if (ret) {
+ gf_msg_debug (this->name, 0, "Missing rebalance"
+ " id");
+ ret = 0;
+ } else {
+ gf_uuid_parse (task_id_str,
+ volinfo->rebal.rebalance_id);
+ volinfo->rebal.op = GD_OP_REBALANCE;
+ }
+ if (dict_get_uint32 (dict, "commit-hash", &commit_hash)
+ == 0) {
+ volinfo->rebal.commit_hash = commit_hash;
+ }
+ ret = glusterd_restart_rebalance_for_volume (volinfo);
break;
}
- if (dict_get_uint32 (dict, "commit-hash", &commit_hash) == 0) {
- volinfo->rebal.commit_hash = commit_hash;
- }
- ret = glusterd_handle_defrag_start (volinfo, msg, sizeof (msg),
- cmd, NULL, GD_OP_REBALANCE);
- break;
case GF_DEFRAG_CMD_STOP:
case GF_DEFRAG_CMD_STOP_DETACH_TIER:
/* Clear task-id only on explicitly stopping rebalance.