From 76a4afec6e03d15cb442e819f6fe7b94d6f9f487 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Tue, 6 Nov 2012 12:19:47 +0530 Subject: libglusterfs: Implement float percentage Change-Id: Ia7ea63471f0bbd74686873f5f6f183475880f1a0 BUG: 839595 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/4162 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/cluster/dht/src/switch.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'xlators/cluster/dht/src/switch.c') diff --git a/xlators/cluster/dht/src/switch.c b/xlators/cluster/dht/src/switch.c index 0542d7f9a..2b4f97387 100644 --- a/xlators/cluster/dht/src/switch.c +++ b/xlators/cluster/dht/src/switch.c @@ -842,7 +842,8 @@ init (xlator_t *this) char *temp_str = NULL; int ret = -1; int i = 0; - uint32_t temp_free_disk = 0; + double temp_free_disk = 0; + uint64_t size = 0; if (!this->children) { gf_log (this->name, GF_LOG_CRITICAL, @@ -875,24 +876,23 @@ init (xlator_t *this) gf_string2boolean (temp_str, &conf->unhashed_sticky_bit); } - conf->min_free_disk = 10; + conf->min_free_disk = 10.0; conf->disk_unit = 'p'; if (dict_get_str (this->options, "min-free-disk", &temp_str) == 0) { - if (gf_string2percent (temp_str, - &temp_free_disk) == 0) { + if (gf_string2percent (temp_str, &temp_free_disk) == 0) { if (temp_free_disk > 100) { - gf_string2bytesize (temp_str, - &conf->min_free_disk); + gf_string2bytesize (temp_str, &size); + conf->min_free_disk = size; conf->disk_unit = 'b'; } else { - conf->min_free_disk = (uint64_t)temp_free_disk; + conf->min_free_disk = temp_free_disk; conf->disk_unit = 'p'; } } else { - gf_string2bytesize (temp_str, - &conf->min_free_disk); + gf_string2bytesize (temp_str, &size); + conf->min_free_disk = size; conf->disk_unit = 'b'; } } -- cgit