]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common, osd: add sanity checks around osd_scrub_max_preemptions 36034/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 16 Jun 2020 02:08:32 +0000 (10:08 +0800)
committerNathan Cutler <ncutler@suse.com>
Fri, 10 Jul 2020 21:30:10 +0000 (23:30 +0200)
to limit maximum preempt_divisor we can use when backing off the
chunky-scrub range on preempting.

Otherwise large osd_scrub_max_preemptions values (i.e., >= 32)
would cause preempt_divisor overflow, hence the dreaded
“divide by zero error”.

Fixes: https://tracker.ceph.com/issues/46024
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
(cherry picked from commit ae05de3e9b2e9868216e5168e50dfcb5074684cb)

src/common/options.cc
src/osd/PG.cc

index db440588bd1a898073dff09f5421266e4bbec03b..f3c848579dd60a04a57fe10c014fd9b9131a3e8f 100644 (file)
@@ -3236,6 +3236,7 @@ std::vector<Option> get_global_options() {
 
     Option("osd_scrub_max_preemptions", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
     .set_default(5)
+    .set_min_max(0, 30)
     .set_description("Set the maximum number of times we will preempt a deep scrub due to a client operation before blocking client IO to complete the scrub"),
 
     Option("osd_deep_scrub_interval", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
index 0649e1c9e770d3e94a1ffab4203dcdf2da0b7cd3..0e4e78cc55b04b342b59fe44286e7c7098a5c9f1 100644 (file)
@@ -2716,6 +2716,7 @@ void PG::chunky_scrub(ThreadPool::TPHandle &handle)
           * left end of the range if we are a tier because they may legitimately
           * not exist (see _scrub).
           */
+          ceph_assert(scrubber.preempt_divisor > 0);
          int min = std::max<int64_t>(3, cct->_conf->osd_scrub_chunk_min /
                                      scrubber.preempt_divisor);
          int max = std::max<int64_t>(min, cct->_conf->osd_scrub_chunk_max /