]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSD::ScrubJob: correctly handle small osd_scrub_interval_randomize_ratio 7147/head
authorSamuel Just <sjust@redhat.com>
Tue, 5 Jan 2016 23:23:01 +0000 (15:23 -0800)
committerSamuel Just <sjust@redhat.com>
Wed, 6 Jan 2016 00:31:12 +0000 (16:31 -0800)
utime_t &operator+=(utime_t, double) exists, let's just use that and
not muck about with converting the double to an int.

Fixes: 14247
Signed-off-by: Samuel Just <sjust@redhat.com>
src/osd/OSD.cc

index f89bd828cebd5ce700b53c24a5358e6585e26d0f..99115486b93600a09f69a74b5c30ccd7d68acabd 100644 (file)
@@ -6088,10 +6088,9 @@ OSDService::ScrubJob::ScrubJob(const spg_t& pg, const utime_t& timestamp,
       pool_scrub_max_interval : g_conf->osd_scrub_max_interval;
 
     sched_time += scrub_min_interval;
-    if (g_conf->osd_scrub_interval_randomize_ratio > 0) {
-      sched_time += rand() % (int)(scrub_min_interval *
-                                  g_conf->osd_scrub_interval_randomize_ratio);
-    }
+    double r = rand() / RAND_MAX;
+    sched_time +=
+      scrub_min_interval * g_conf->osd_scrub_interval_randomize_ratio * r;
     deadline += scrub_max_interval;
   }
 }