diff options
author | Pranith Kumar K <pranithk@gluster.com> | 2012-11-06 12:19:47 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2012-11-23 23:13:39 -0800 |
commit | 76a4afec6e03d15cb442e819f6fe7b94d6f9f487 (patch) | |
tree | 2b98adca7a192a31e21e6b2d4965aaa80d16403b /xlators/cluster/dht | |
parent | 6dee0e3d99dd3423edc6ad2981733fac3ef8c67d (diff) |
libglusterfs: Implement float percentage
Change-Id: Ia7ea63471f0bbd74686873f5f6f183475880f1a0
BUG: 839595
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.org/4162
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/cluster/dht')
-rw-r--r-- | xlators/cluster/dht/src/dht-common.h | 4 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht.c | 6 | ||||
-rw-r--r-- | xlators/cluster/dht/src/nufa.c | 13 | ||||
-rw-r--r-- | xlators/cluster/dht/src/switch.c | 18 |
4 files changed, 21 insertions, 20 deletions
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index be4dea90cc1..0f2df514fb5 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -243,8 +243,8 @@ struct dht_conf { gf_boolean_t search_unhashed; int gen; dht_du_t *du_stats; - uint64_t min_free_disk; - uint32_t min_free_inodes; + double min_free_disk; + double min_free_inodes; char disk_unit; int32_t refresh_interval; gf_boolean_t unhashed_sticky_bit; diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c index 80d00c96b55..d7b1e9655e7 100644 --- a/xlators/cluster/dht/src/dht.c +++ b/xlators/cluster/dht/src/dht.c @@ -125,8 +125,8 @@ dht_priv_dump (xlator_t *this) gf_proc_dump_write("search_unhashed", "%d", conf->search_unhashed); gf_proc_dump_write("gen", "%d", conf->gen); - gf_proc_dump_write("min_free_disk", "%lu", conf->min_free_disk); - gf_proc_dump_write("min_free_inodes", "%lu", conf->min_free_inodes); + gf_proc_dump_write("min_free_disk", "%lf", conf->min_free_disk); + gf_proc_dump_write("min_free_inodes", "%lf", conf->min_free_inodes); gf_proc_dump_write("disk_unit", "%c", conf->disk_unit); gf_proc_dump_write("refresh_interval", "%d", conf->refresh_interval); gf_proc_dump_write("unhashed_sticky_bit", "%d", conf->unhashed_sticky_bit); @@ -326,7 +326,7 @@ reconfigure (xlator_t *this, dict_t *options) percent_or_size, out); /* option can be any one of percent or bytes */ conf->disk_unit = 0; - if (conf->min_free_disk < 100) + if (conf->min_free_disk < 100.0) conf->disk_unit = 'p'; GF_OPTION_RECONF ("min-free-inodes", conf->min_free_inodes, options, diff --git a/xlators/cluster/dht/src/nufa.c b/xlators/cluster/dht/src/nufa.c index 53c66aa45aa..a2a97ab3c76 100644 --- a/xlators/cluster/dht/src/nufa.c +++ b/xlators/cluster/dht/src/nufa.c @@ -502,7 +502,8 @@ init (xlator_t *this) int ret = -1; int i = 0; char my_hostname[256]; - 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, @@ -587,16 +588,16 @@ init (xlator_t *this) 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'; } } diff --git a/xlators/cluster/dht/src/switch.c b/xlators/cluster/dht/src/switch.c index 0542d7f9afc..2b4f97387bd 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'; } } |