]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: add boundary for cache-autotune related settings 25604/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 6 Dec 2018 10:15:55 +0000 (18:15 +0800)
committerNathan Cutler <ncutler@suse.com>
Tue, 18 Dec 2018 11:25:17 +0000 (12:25 +0100)
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>
(cherry picked from commit c2c9245ee63cb135020061d90822745d91bb962d)

src/common/options.cc
src/os/bluestore/BlueStore.cc

index c4946a1adb1b473514e0a788044ef83fde640d81..aa5c82e8d17ce9579a9f775e9648484a1c729f8f 100644 (file)
@@ -3172,6 +3172,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 ebdae26caef88e7da920ce41119c77338d67f6b5..3a3e9901647da678520c9ba83bd003c90bdd3222 100644 (file)
@@ -3433,8 +3433,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;