From 04a72476789d06c0e55b73f953ff1ad68739ebd4 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: I4892ab14982a1ff305aeb2d8bbd33c79d6877b69 BUG: 1219579 Signed-off-by: Susant Palai Reviewed-on: http://review.gluster.org/10526 Reviewed-by: Raghavendra G Tested-by: Raghavendra G Reviewed-on: http://review.gluster.org/10629 Reviewed-by: Vijay Bellur Tested-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-volume-set.c | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'xlators/mgmt/glusterd/src/glusterd-volume-set.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 9f751c90f3d..b5e65f00a0b 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