]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common, osd: add sanity checks around osd_scrub_max_preemptions 37470/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 16 Jun 2020 02:08:32 +0000 (10:08 +0800)
committerNathan Cutler <ncutler@suse.com>
Tue, 29 Sep 2020 16:27:03 +0000 (18:27 +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)

Conflicts:
src/osd/PG.cc
- git got confused about where the change was/is

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

index a9baa317aa9aee3a78d1e5e1fc5c713fe0bd58ea..54c2c516a940e05fd218d3e5b79064bbf6ce254b 100644 (file)
@@ -3600,6 +3600,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 76bbbeb1d6cf65b99eb122b77fc170a0eab363bc..132fec0685079d8b309f5e961830769dc06b48af 100644 (file)
@@ -5445,6 +5445,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 /