diff options
-rwxr-xr-x | tests/basic/tier/tier_lookup_heal.t | 3 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rebalance.c | 13 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 45 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 7 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 4 |
5 files changed, 58 insertions, 14 deletions
diff --git a/tests/basic/tier/tier_lookup_heal.t b/tests/basic/tier/tier_lookup_heal.t index 2b778f749f9..625b6b747ae 100755 --- a/tests/basic/tier/tier_lookup_heal.t +++ b/tests/basic/tier/tier_lookup_heal.t @@ -63,10 +63,11 @@ TEST [ $ENTRY_COUNT -eq 2 ] # Heat-up the file uuidgen > file1 -TEST $CLI volume rebalance $V0 tier start sleep 5 #Check if the file is promoted EXPECT_WITHIN $PROMOTE_TIMEOUT "0" file_on_fast_tier file1 +cd; + cleanup diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index 0ec1d69a0c1..ef003c2bb8d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -135,7 +135,8 @@ __glusterd_defrag_notify (struct rpc_clnt *rpc, void *mydata, UNLOCK (&defrag->lock); if (!gf_is_service_running (pidfile, NULL)) { - if (volinfo->rebal.defrag_status == + if (volinfo->type != GF_CLUSTER_TYPE_TIER && + volinfo->rebal.defrag_status == GF_DEFRAG_STATUS_STARTED) { volinfo->rebal.defrag_status = GF_DEFRAG_STATUS_FAILED; @@ -198,9 +199,6 @@ glusterd_handle_defrag_start (glusterd_volinfo_t *volinfo, char *op_errstr, GF_ASSERT (volinfo); GF_ASSERT (op_errstr); - if ((cmd == GF_OP_CMD_DETACH_START) && - (volinfo->rebal.defrag_status == GF_DEFRAG_STATUS_STARTED)) - return 0; ret = glusterd_defrag_start_validate (volinfo, op_errstr, len, op); if (ret) @@ -607,6 +605,13 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr) ret = -1; goto out; } + if (glusterd_is_tier_daemon_running (volinfo)) { + ret = gf_asprintf (op_errstr, "A Tier daemon is " + "already running on volume %s", + volname); + ret = -1; + goto out; + } case GF_DEFRAG_CMD_START: case GF_DEFRAG_CMD_START_LAYOUT_FIX: /* Check if the connected clients are all of version diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 48216f61989..1dcc3d3de50 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -5432,11 +5432,32 @@ out: return ret; } +gf_boolean_t +glusterd_is_tier_daemon_running (glusterd_volinfo_t *volinfo) +{ + if (volinfo->type != GF_CLUSTER_TYPE_TIER) + return _gf_false; + + if (volinfo->rebal.defrag && + volinfo->rebal.defrag_cmd == GF_DEFRAG_CMD_START_TIER) { + return _gf_true; + } + + return _gf_false; + +} + + int glusterd_is_defrag_on (glusterd_volinfo_t *volinfo) { - /* Defrag is never enabled for tiered volumes. */ - if (volinfo->type == GF_CLUSTER_TYPE_TIER) + /* + * Do not need to consider tier daemon as a rebalance + * daemon and with current design rebalance is not supported + * on a tiered volume. + */ + + if (glusterd_is_tier_daemon_running (volinfo)) return 0; return (volinfo->rebal.defrag != NULL); @@ -6759,21 +6780,27 @@ glusterd_volume_defrag_restart (glusterd_volinfo_t *volinfo, char *op_errstr, return ret; } +void +glusterd_restart_rebalance_for_volume (glusterd_volinfo_t *volinfo) +{ + + char op_errstr[PATH_MAX]; + if (!volinfo->rebal.defrag_cmd) + return; + if (!gd_should_i_start_rebalance (volinfo)) + return; + glusterd_volume_defrag_restart (volinfo, op_errstr, PATH_MAX, + volinfo->rebal.defrag_cmd, NULL); +} int glusterd_restart_rebalance (glusterd_conf_t *conf) { glusterd_volinfo_t *volinfo = NULL; int ret = 0; - char op_errstr[256]; cds_list_for_each_entry (volinfo, &conf->volumes, vol_list) { - if (!volinfo->rebal.defrag_cmd) - continue; - if (!gd_should_i_start_rebalance (volinfo)) - continue; - glusterd_volume_defrag_restart (volinfo, op_errstr, 256, - volinfo->rebal.defrag_cmd, NULL); + glusterd_restart_rebalance_for_volume (volinfo); } return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index 7741087ff74..7bba897629d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -220,6 +220,10 @@ glusterd_brick_stop (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo, gf_boolean_t del_brick); +gf_boolean_t +glusterd_is_tier_daemon_running (glusterd_volinfo_t *volinfo); + + int glusterd_is_defrag_on (glusterd_volinfo_t *volinfo); @@ -357,6 +361,9 @@ glusterd_get_trusted_client_filepath (char *filepath, int glusterd_restart_rebalance (glusterd_conf_t *conf); +void +glusterd_restart_rebalance_for_volume (glusterd_volinfo_t *volinfo); + 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 13daceb42ad..a13ddcaff18 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -2425,6 +2425,10 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr) goto out; } + if (volinfo->type == GF_CLUSTER_TYPE_TIER) { + glusterd_restart_rebalance_for_volume (volinfo); + } + ret = glusterd_svcs_manager (volinfo); out: |