From 98bd9830da7071eed71c95611da7ef8a5f1cf71e Mon Sep 17 00:00:00 2001 From: Susant Palai Date: Mon, 4 May 2015 16:43:02 +0530 Subject: dht/rebalance: Throttle rebalance Throttle value will be "normal" by default. For throttling down, a thread will be put in to sleep. And for throttling up, gf_defrag_process_dir will wake up the sleeping threads. Change-Id: I74d530e3effd6e60e6eec81ccc8ff65789fa9c13 Signed-off-by: Susant Palai Reviewed-on: http://review.gluster.org/10526 Reviewed-by: Raghavendra G Tested-by: Raghavendra G --- xlators/mgmt/glusterd/src/glusterd-volume-set.c | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'xlators/mgmt/glusterd') diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 699985c2718..02d59eddf5d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -73,6 +73,35 @@ out: return ret; } +static int +validate_defrag_throttle_option (glusterd_volinfo_t *volinfo, dict_t *dict, + char *key, char *value, char **op_errstr) +{ + char errstr[2048] = ""; + glusterd_conf_t *priv = NULL; + int ret = 0; + xlator_t *this = NULL; + + this = THIS; + GF_ASSERT (this); + + if (!strcasecmp (value, "lazy") || + !strcasecmp (value, "normal") || + !strcasecmp (value, "aggressive")) { + ret = 0; + } else { + ret = -1; + snprintf (errstr, sizeof (errstr), "%s should be " + "{lazy|normal|aggressive}", key); + gf_log (this->name, GF_LOG_ERROR, "%s", errstr); + *op_errstr = gf_strdup (errstr); + } + + gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + + return ret; +} + static int validate_quota (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, char *value, char **op_errstr) @@ -357,6 +386,13 @@ struct volopt_map_entry glusterd_volopt_map[] = { .op_version = GD_OP_VERSION_3_6_0, .flags = OPT_FLAG_CLIENT_OPT, }, + { .key = "cluster.rebal-throttle", + .voltype = "cluster/distribute", + .option = "rebal-throttle", + .op_version = GD_OP_VERSION_3_7_0, + .validate_fn = validate_defrag_throttle_option, + .flags = OPT_FLAG_CLIENT_OPT, + }, /* NUFA xlator options (Distribute special case) */ { .key = "cluster.nufa", .voltype = "cluster/distribute", -- cgit