]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: add boundary for cache-autotune related settings
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 6 Dec 2018 10:15:55 +0000 (18:15 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Tue, 11 Dec 2018 01:50:08 +0000 (09:50 +0800)
E.g., because user configures something wrong or we don't expected.

Fixes: http://tracker.ceph.com/issues/37507
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/common/options.cc
src/os/bluestore/BlueStore.cc

index 2ed6e83f71b0ffcdd252b960ca4cbdc581ed473b..30cf2c61a6f84ce62eb98cc1762149f46e864b19 100644 (file)
@@ -3736,6 +3736,7 @@ std::vector<Option> get_global_options() {
 
     Option("osd_memory_expected_fragmentation", Option::TYPE_FLOAT, Option::LEVEL_DEV)
     .set_default(0.15)
+    .set_min_max(0.0, 1.0)
     .add_see_also("bluestore_cache_autotune")
     .set_description("When tcmalloc and cache autotuning is enabled, estimate the percent of memory fragmentation."),
 
index 47d9ff94c67b00c6c88b2d71e6c03ee73a4f4120..13890e24412e437917468349e1b3a528be55d43e 100644 (file)
@@ -3563,8 +3563,12 @@ void BlueStore::MempoolThread::_tune_cache_size(bool interval_stats)
   uint64_t target = store->osd_memory_target;
   uint64_t base = store->osd_memory_base;
   double fragmentation = store->osd_memory_expected_fragmentation;
-  uint64_t cache_max = ((1.0 - fragmentation) * target) - base;
   uint64_t cache_min = store->osd_memory_cache_min;
+  uint64_t cache_max = cache_min;
+  uint64_t limited_target = (1.0 - fragmentation) * target;
+  if (limited_target > base + cache_min) {
+    cache_max = limited_target - base;
+  }
 
   size_t heap_size = 0;
   size_t unmapped = 0;