]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common, osd: add sanity checks around osd_scrub_max_preemptions 35580/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 16 Jun 2020 02:08:32 +0000 (10:08 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Thu, 18 Jun 2020 00:45:25 +0000 (08:45 +0800)
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>
src/common/options.cc
src/osd/PG.cc

index 495dc5273c136ffc552476d6ab76fa925ee2a4ff..6e0430375ed8e24a2c02c336c7f1a022d794a8b0 100644 (file)
@@ -3257,6 +3257,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 cd3081d202ea4f39a4603fc32f2db975db5fbdd2..607833ee15f8f9b379ec7c5230a2b74cbc0df044 100644 (file)
@@ -2730,6 +2730,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 /