summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2015-09-08 13:04:45 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-10-12 04:57:06 -0700
commit0ef62933649392051e73fe01c028e41baddec489 (patch)
treeebdee384df69a04ebc061dfebc5aece1a870c8f4 /xlators/mgmt/glusterd/src/glusterd-volume-ops.c
parentd4bd690adae7ce69594c3322d0d7a8e3cb4f7303 (diff)
tier/shd: make shd commands compatible with tiering
tiering volfiles may contain afr and disperse together or multiple time based on configuration. And the informations for those configurations are stored in tier_info. So most of the volgen code generation need to be changed to make compatible with it. Change-Id: I563d1ca6f281f59090ebd470b7fda1cc4b1b7e1d BUG: 1261276 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: http://review.gluster.org/12135 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volume-ops.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c90
1 files changed, 78 insertions, 12 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index a07d7612576..b00539d4efa 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -669,14 +669,73 @@ out:
return ret;
}
-
int
glusterd_handle_cli_delete_volume (rpcsvc_request_t *req)
{
return glusterd_big_locked_handler (req,
__glusterd_handle_cli_delete_volume);
}
+static char*
+_get_shd_key (int type)
+{
+ char *key = NULL;
+
+ switch (type) {
+ case GF_CLUSTER_TYPE_REPLICATE:
+ case GF_CLUSTER_TYPE_STRIPE_REPLICATE:
+ key = "cluster.self-heal-daemon";
+ break;
+ case GF_CLUSTER_TYPE_DISPERSE:
+ key = "cluster.disperse-self-heal-daemon";
+ break;
+ default:
+ key = NULL;
+ break;
+ }
+ return key;
+}
+static int
+glusterd_handle_shd_option_for_tier (glusterd_volinfo_t *volinfo,
+ char *value, dict_t *dict)
+{
+ int count = 0;
+ char dict_key[1024] = {0, };
+ char *key = NULL;
+ int ret = 0;
+
+ key = _get_shd_key (volinfo->tier_info.cold_type);
+ if (key) {
+ count++;
+ snprintf (dict_key, sizeof (dict_key), "key%d", count);
+ ret = dict_set_str (dict, dict_key, key);
+ if (ret)
+ goto out;
+ snprintf (dict_key, sizeof (dict_key), "value%d", count);
+ ret = dict_set_str (dict, dict_key, value);
+ if (ret)
+ goto out;
+ }
+
+ key = _get_shd_key (volinfo->tier_info.hot_type);
+ if (key) {
+ count++;
+ snprintf (dict_key, sizeof (dict_key), "key%d", count);
+ ret = dict_set_str (dict, dict_key, key);
+ if (ret)
+ goto out;
+ snprintf (dict_key, sizeof (dict_key), "value%d", count);
+ ret = dict_set_str (dict, dict_key, value);
+ if (ret)
+ goto out;
+ }
+
+ ret = dict_set_int32 (dict, "count", count);
+ if (ret)
+ goto out;
+out:
+ return ret;
+}
static int
glusterd_handle_heal_enable_disable (rpcsvc_request_t *req, dict_t *dict,
glusterd_volinfo_t *volinfo)
@@ -699,23 +758,31 @@ glusterd_handle_heal_enable_disable (rpcsvc_request_t *req, dict_t *dict,
goto out;
}
- key = volgen_get_shd_key (volinfo);
+ if (heal_op == GF_SHD_OP_HEAL_ENABLE) {
+ value = "enable";
+ } else if (heal_op == GF_SHD_OP_HEAL_DISABLE) {
+ value = "disable";
+ }
+
+ /* Convert this command to volume-set command based on volume type */
+ if (volinfo->type == GF_CLUSTER_TYPE_TIER) {
+ ret = glusterd_handle_shd_option_for_tier (volinfo, value,
+ dict);
+ if (!ret)
+ goto set_volume;
+ goto out;
+ }
+
+ key = volgen_get_shd_key (volinfo->type);
if (!key) {
ret = -1;
goto out;
}
- /* Convert this command to volume-set command based on volume type */
ret = dict_set_str (dict, "key1", key);
if (ret)
goto out;
- if (heal_op == GF_SHD_OP_HEAL_ENABLE) {
- value = "enable";
- } else if (heal_op == GF_SHD_OP_HEAL_DISABLE) {
- value = "disable";
- }
-
ret = dict_set_str (dict, "value1", value);
if (ret)
goto out;
@@ -724,6 +791,7 @@ glusterd_handle_heal_enable_disable (rpcsvc_request_t *req, dict_t *dict,
if (ret)
goto out;
+set_volume:
ret = glusterd_op_begin_synctask (req, GD_OP_SET_VOLUME, dict);
out:
@@ -1822,9 +1890,7 @@ glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr)
ret = 0;
goto out;
}
-
- enabled = dict_get_str_boolean (opt_dict, volgen_get_shd_key (volinfo),
- 1);
+ enabled = is_self_heal_enabled (volinfo, opt_dict);
if (!enabled) {
ret = -1;
snprintf (msg, sizeof (msg), "Self-heal-daemon is "