From 3f76fe277ec0a826bf3052134ad877ee65ce9e79 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 1 Jul 2011 04:40:05 +0000 Subject: cluster/distribute: bring in directory-spread-count option global spread count option is given through volume file Signed-off-by: Amar Tumballi Signed-off-by: Anand Avati BUG: 2257 (enhance distribute to control the spread count (ie, control the hashing range)) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2257 --- xlators/cluster/dht/src/dht.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'xlators/cluster/dht/src/dht.c') diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c index 3abba0dfe4..42f0c0d75e 100644 --- a/xlators/cluster/dht/src/dht.c +++ b/xlators/cluster/dht/src/dht.c @@ -290,6 +290,7 @@ reconfigure (xlator_t *this, dict_t *options) gf_boolean_t search_unhashed; uint32_t temp_free_disk = 0; int ret = -1; + uint32_t dir_spread = 0; GF_VALIDATE_OR_GOTO ("dht", this, out); GF_VALIDATE_OR_GOTO ("dht", options, out); @@ -340,6 +341,22 @@ reconfigure (xlator_t *this, dict_t *options) " min-free-disk reconfigured to %s", temp_str); } + + if (dict_get_str (options, "directory-layout-spread", &temp_str) == 0) { + ret = gf_string2uint32 (temp_str, &dir_spread); + if (ret || + (dir_spread > conf->subvolume_cnt) || + (dir_spread < 1)) { + gf_log (this->name, GF_LOG_ERROR, + "wrong 'directory-layout-spread' option given " + "(%s). setting to earlier value (%d)", + temp_str, conf->dir_spread_cnt); + ret = -1; + goto out; + } + conf->dir_spread_cnt = dir_spread; + } + ret = 0; out: return ret; @@ -433,6 +450,21 @@ init (xlator_t *this) } } + conf->dir_spread_cnt = conf->subvolume_cnt; + if (dict_get_str (this->options, "directory-layout-spread", + &temp_str) == 0) { + ret = gf_string2uint32 (temp_str, &conf->dir_spread_cnt); + if (ret || + (conf->dir_spread_cnt > conf->subvolume_cnt) || + (conf->dir_spread_cnt < 1)) { + gf_log (this->name, GF_LOG_WARNING, + "wrong 'directory-layout-spread' option given " + "(%s). setting it to subvolume count", + temp_str); + conf->dir_spread_cnt = conf->subvolume_cnt; + } + } + conf->assert_no_child_down = 0; ret = dict_get_str_boolean (this->options, "assert-no-child-down", 0); @@ -574,5 +606,8 @@ struct volume_options options[] = { { .key = {"assert-no-child-down"}, .type = GF_OPTION_TYPE_BOOL }, + { .key = {"directory-layout-spread"}, + .type = GF_OPTION_TYPE_INT, + }, { .key = {NULL} }, }; -- cgit