Merge pull request #2182 from ceph/wip-round

use llrintl when converting double to micro

Reviewed-by: Greg Farnum <greg@inktank.com>
This commit is contained in:
Gregory Farnum 2014-08-01 08:11:08 -04:00
commit fc2d18bb1e
2 changed files with 5 additions and 3 deletions

View File

@ -3507,6 +3507,7 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
string interr, floaterr;
int64_t n = 0;
double f = 0;
int64_t uf = 0; // micro-f
if (!cmd_getval(g_ceph_context, cmdmap, "val", val)) {
// wasn't a string; maybe an older mon forwarded json with an int?
if (!cmd_getval(g_ceph_context, cmdmap, "val", n))
@ -3516,6 +3517,7 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
n = strict_strtoll(val.c_str(), 10, &interr);
// or a float
f = strict_strtod(val.c_str(), &floaterr);
uf = llrintl(f * (double)1000000.0);
}
if (!p.is_tier() &&
@ -3710,7 +3712,7 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
ss << "value must be in the range 0..1";
return -ERANGE;
}
p.cache_target_dirty_ratio_micro = f * (double)1000000.0;
p.cache_target_dirty_ratio_micro = uf;
} else if (var == "cache_target_full_ratio") {
if (floaterr.length()) {
ss << "error parsing float '" << val << "': " << floaterr;
@ -3720,7 +3722,7 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
ss << "value must be in the range 0..1";
return -ERANGE;
}
p.cache_target_full_ratio_micro = f * (double)1000000.0;
p.cache_target_full_ratio_micro = uf;
} else if (var == "cache_min_flush_age") {
if (interr.length()) {
ss << "error parsing int '" << val << "': " << interr;

View File

@ -369,7 +369,7 @@ public:
return (double)fpp_micro / 1000000.0;
}
void set_fpp(double f) {
fpp_micro = (unsigned)(f * 1000000.0);
fpp_micro = (unsigned)(llrintl(f * (double)1000000.0));
}
void encode(bufferlist& bl) const {