diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2014-12-29 15:32:28 +0530 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-01-20 02:24:24 -0800 |
commit | 7510d8edf4e7bea50e0c1f041202f063a5d138af (patch) | |
tree | 77814773e915cedccbcb9149ff8c86ca704514fa /xlators/mgmt/glusterd/src/glusterd-volume-set.c | |
parent | 1ee8ce725f0e70f45419aa0e2f4d85db7223d766 (diff) |
mgmt/glusterd: Implement Volume heal enable/disable
For volumes with replicate, disperse xlators, self-heal daemon should do
healing. This patch provides enable/disable functionality for the xlators to be
part of self-heal-daemon. Replicate already had this functionality with
'gluster volume set cluster.self-heal-daemon on/off'. But this patch makes it
uniform for both types of volumes. Internally it still does 'volume set' based
on the volume type.
Change-Id: Ie0f3799b74c2afef9ac658ef3d50dce3e8072b29
BUG: 1177601
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/9358
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volume-set.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-set.c | 165 |
1 files changed, 50 insertions, 115 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 27f35238dab..1d015a94698 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -17,81 +17,13 @@ #include "glusterd-utils.h" static int -check_dict_key_value (dict_t *dict, char *key, char *value) -{ - glusterd_conf_t *priv = NULL; - int ret = 0; - xlator_t *this = NULL; - - this = THIS; - GF_ASSERT (this); - priv = this->private; - GF_ASSERT (priv); - - if (!dict) { - gf_log (this->name, GF_LOG_ERROR, "Received Empty Dict."); - ret = -1; - goto out; - } - - if (!key) { - gf_log (this->name, GF_LOG_ERROR, "Received Empty Key."); - ret = -1; - goto out; - } - - if (!value) { - gf_log (this->name, GF_LOG_ERROR, "Received Empty Value."); - ret = -1; - goto out; - } - -out: - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); - - return ret; -} - -static int -get_volname_volinfo (dict_t *dict, char **volname, glusterd_volinfo_t **volinfo) -{ - glusterd_conf_t *priv = NULL; - int ret = 0; - xlator_t *this = NULL; - - this = THIS; - GF_ASSERT (this); - priv = this->private; - GF_ASSERT (priv); - - ret = dict_get_str (dict, "volname", volname); - if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to get volume name"); - goto out; - } - - ret = glusterd_volinfo_find (*volname, volinfo); - if (ret) { - gf_log (this->name, GF_LOG_ERROR, "Unable to allocate memory"); - goto out; - } - -out: - gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); - - return ret; -} - -static int -validate_cache_max_min_size (dict_t *dict, char *key, char *value, - char **op_errstr) +validate_cache_max_min_size (glusterd_volinfo_t *volinfo, dict_t *dict, + char *key, char *value, char **op_errstr) { char *current_max_value = NULL; char *current_min_value = NULL; char errstr[2048] = ""; - char *volname = NULL; glusterd_conf_t *priv = NULL; - glusterd_volinfo_t *volinfo = NULL; int ret = 0; uint64_t max_value = 0; uint64_t min_value = 0; @@ -102,14 +34,6 @@ validate_cache_max_min_size (dict_t *dict, char *key, char *value, priv = this->private; GF_ASSERT (priv); - ret = check_dict_key_value (dict, key, value); - if (ret) - goto out; - - ret = get_volname_volinfo (dict, &volname, &volinfo); - if (ret) - goto out; - if ((!strcmp (key, "performance.cache-min-file-size")) || (!strcmp (key, "cache-min-file-size"))) { glusterd_volinfo_get (volinfo, @@ -150,13 +74,11 @@ out: } static int -validate_quota (dict_t *dict, char *key, char *value, - char **op_errstr) +validate_quota (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + char *value, char **op_errstr) { char errstr[2048] = ""; - char *volname = NULL; glusterd_conf_t *priv = NULL; - glusterd_volinfo_t *volinfo = NULL; int ret = 0; xlator_t *this = NULL; @@ -165,14 +87,6 @@ validate_quota (dict_t *dict, char *key, char *value, priv = this->private; GF_ASSERT (priv); - ret = check_dict_key_value (dict, key, value); - if (ret) - goto out; - - ret = get_volname_volinfo (dict, &volname, &volinfo); - if (ret) - goto out; - ret = glusterd_volinfo_get_boolean (volinfo, VKEY_FEATURES_QUOTA); if (ret == -1) { gf_log (this->name, GF_LOG_ERROR, @@ -197,7 +111,8 @@ out: } static int -validate_uss (dict_t *dict, char *key, char *value, char **op_errstr) +validate_uss (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + char *value, char **op_errstr) { char errstr[2048] = ""; int ret = 0; @@ -223,12 +138,11 @@ out: } static int -validate_stripe (dict_t *dict, char *key, char *value, char **op_errstr) +validate_stripe (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + char *value, char **op_errstr) { char errstr[2048] = ""; - char *volname = NULL; glusterd_conf_t *priv = NULL; - glusterd_volinfo_t *volinfo = NULL; int ret = 0; xlator_t *this = NULL; @@ -237,14 +151,6 @@ validate_stripe (dict_t *dict, char *key, char *value, char **op_errstr) priv = this->private; GF_ASSERT (priv); - ret = check_dict_key_value (dict, key, value); - if (ret) - goto out; - - ret = get_volname_volinfo (dict, &volname, &volinfo); - if (ret) - goto out; - if (volinfo->stripe_count == 1) { snprintf (errstr, sizeof (errstr), "Cannot set %s for a non-stripe volume.", key); @@ -261,13 +167,11 @@ out: } static int -validate_subvols_per_directory (dict_t *dict, char *key, char *value, - char **op_errstr) +validate_subvols_per_directory (glusterd_volinfo_t *volinfo, dict_t *dict, + char *key, char *value, char **op_errstr) { char errstr[2048] = ""; - char *volname = NULL; glusterd_conf_t *priv = NULL; - glusterd_volinfo_t *volinfo = NULL; int ret = 0; int subvols = 0; xlator_t *this = NULL; @@ -277,14 +181,6 @@ validate_subvols_per_directory (dict_t *dict, char *key, char *value, priv = this->private; GF_ASSERT (priv); - ret = check_dict_key_value (dict, key, value); - if (ret) - goto out; - - ret = get_volname_volinfo (dict, &volname, &volinfo); - if (ret) - goto out; - subvols = atoi(value); /* Checking if the subvols-per-directory exceed the total @@ -307,6 +203,36 @@ out: return ret; } +static int +validate_replica_heal_enable_disable (glusterd_volinfo_t *volinfo, dict_t *dict, + char *key, char *value, char **op_errstr) +{ + int ret = 0; + + if (!glusterd_is_volume_replicate (volinfo)) { + gf_asprintf (op_errstr, "Volume %s is not of replicate type", + volinfo->volname); + ret = -1; + } + + return ret; +} + +static int +validate_disperse_heal_enable_disable (glusterd_volinfo_t *volinfo, + dict_t *dict, char *key, char *value, + char **op_errstr) +{ + int ret = 0; + + if (volinfo->type != GF_CLUSTER_TYPE_DISPERSE) { + gf_asprintf (op_errstr, "Volume %s is not of disperse type", + volinfo->volname); + ret = -1; + } + + return ret; +} /* dispatch table for VOLUME SET * ----------------------------- @@ -511,7 +437,8 @@ struct volopt_map_entry glusterd_volopt_map[] = { { .key = "cluster.self-heal-daemon", .voltype = "cluster/replicate", .option = "!self-heal-daemon", - .op_version = 1 + .op_version = 1, + .validate_fn = validate_replica_heal_enable_disable }, { .key = "cluster.heal-timeout", .voltype = "cluster/replicate", @@ -1712,6 +1639,14 @@ struct volopt_map_entry glusterd_volopt_map[] = { .type = NO_DOC, .op_version = GD_OP_VERSION_3_7_0, }, + { .key = "cluster.disperse-self-heal-daemon", + .voltype = "cluster/disperse", + .value = "enable", + .type = NO_DOC, + .option = "self-heal-daemon", + .op_version = GD_OP_VERSION_3_7_0, + .validate_fn = validate_disperse_heal_enable_disable + }, { .key = NULL } }; |