]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
use llrintl when converting double to micro
authorSage Weil <sage@redhat.com>
Thu, 31 Jul 2014 22:39:40 +0000 (15:39 -0700)
committerSage Weil <sage@redhat.com>
Fri, 1 Aug 2014 22:33:17 +0000 (15:33 -0700)
This avoids rounding error (noticeable on i386).

Backport: firefly
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 80911736bd61b6b88eac0974d24f21c15c5385a4)

Conflicts:
src/mon/OSDMonitor.cc

src/mon/OSDMonitor.cc
src/osd/HitSet.h

index eab5122cc1f33acf4544d8f3667dd2a7a8d34e1f..40cf6ccc6047c13a9e0bb449cf63c8254cdec69f 100644 (file)
@@ -3336,6 +3336,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))
@@ -3345,6 +3346,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 (var == "size") {
@@ -3528,7 +3530,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 * 1000000;
+    p.cache_target_dirty_ratio_micro = uf;
   } else if (var == "cache_target_full_ratio") {
     if (floaterr.length()) {
       ss << "error parsing float '" << val << "': " << floaterr;
@@ -3538,7 +3540,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 * 1000000;
+    p.cache_target_full_ratio_micro = uf;
   } else if (var == "cache_min_flush_age") {
     if (interr.length()) {
       ss << "error parsing int '" << val << "': " << interr;
index 391dd63ee8fa3794fab32d326e054cd4189aebb5..476678efe68bd2ee10a1f1e238c211e6cfe9c800 100644 (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 {