]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: configure hybrid allocator threshold to fallback.
authorIgor Fedotov <ifedotov@suse.com>
Fri, 14 Feb 2020 14:26:17 +0000 (17:26 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Sat, 25 Jul 2020 10:55:22 +0000 (13:55 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(cherry picked from commit b682d9a8e8d3f41d55ad10d2fb3deca8edf8540a)

 Conflicts:
src/common/options.cc
 trivial

src/common/options.cc
src/os/bluestore/Allocator.cc
src/os/bluestore/AvlAllocator.cc
src/os/bluestore/AvlAllocator.h
src/os/bluestore/HybridAllocator.h
src/test/objectstore/hybrid_allocator_test.cc

index f3b91c73bb1102a7eff76907f75f68d99c396d51..c861f8241bc966eb954b7b34237238b51118a915 100644 (file)
@@ -4968,6 +4968,10 @@ std::vector<Option> get_global_options() {
     .set_default(4)
     .set_description(""),
 
+    Option("bluestore_hybrid_alloc_mem_cap", Option::TYPE_UINT, Option::LEVEL_DEV)
+    .set_default(64_M)
+    .set_description("Maximum RAM hybrid allocator should use before enabling bitmap supplement"),
+
     // -----------------------------------------
     // kstore
 
index 8a638bdf81a37b216628d8585d2ca87551b50348..0ac9a15a7419e48867bf6299aac33a54421ac821 100644 (file)
@@ -130,7 +130,9 @@ Allocator *Allocator::create(CephContext* cct, string type,
   } else if (type == "avl") {
     return new AvlAllocator(cct, size, block_size, name);
   } else if (type == "hybrid") {
-    return new HybridAllocator(cct, size, block_size, 1024 /*FIXME*/, name);
+    return new HybridAllocator(cct, size, block_size,
+      cct->_conf.get_val<uint64_t>("bluestore_hybrid_alloc_mem_cap"),
+      name);
   }
   if (alloc == nullptr) {
     lderr(cct) << "Allocator::" << __func__ << " unknown alloc type "
index 4e2d0915f21d0b0b32b9f4091d8fb49cefa187c6..e9d0510798626b614b01982d977f6f6fe1a7ecc5 100755 (executable)
@@ -287,7 +287,7 @@ void AvlAllocator::_shutdown()
 AvlAllocator::AvlAllocator(CephContext* cct,
                            int64_t device_size,
                            int64_t block_size,
-                           uint64_t max_entries,
+                           uint64_t max_mem,
                            const std::string& name) :
   Allocator(name),
   num_total(device_size),
@@ -296,7 +296,7 @@ AvlAllocator::AvlAllocator(CephContext* cct,
     cct->_conf.get_val<uint64_t>("bluestore_avl_alloc_bf_threshold")),
   range_size_alloc_free_pct(
     cct->_conf.get_val<uint64_t>("bluestore_avl_alloc_bf_free_pct")),
-  range_count_cap(max_entries),
+  range_count_cap(max_mem / sizeof(range_seg_t)),
   cct(cct)
 {}
 
index 770d7e6459538d5e2cdbd98aeb33665026aff6f4..b49957a28f90846927d3a3bd26578733deada7a9 100755 (executable)
@@ -64,7 +64,7 @@ protected:
   * (when entry count >= max_entries)
   */
   AvlAllocator(CephContext* cct, int64_t device_size, int64_t block_size,
-    uint64_t max_entries,
+    uint64_t max_mem,
     const std::string& name);
 
 public:
index 1c821f69c3b88fc8b83641378045924a8419bdaf..7eadad03401fbea42ff499a735ad6d9802d6f36a 100644 (file)
@@ -12,9 +12,9 @@ class HybridAllocator : public AvlAllocator {
   BitmapAllocator* bmap_alloc = nullptr;
 public:
   HybridAllocator(CephContext* cct, int64_t device_size, int64_t _block_size,
-                  uint64_t max_entries,
+                  uint64_t max_mem,
                  const std::string& name) :
-      AvlAllocator(cct, device_size, _block_size, max_entries, name) {
+      AvlAllocator(cct, device_size, _block_size, max_mem, name) {
   }
   int64_t allocate(
     uint64_t want,
index c21957ef88d8dd43ba1e6688e5f0825cdfe9eb83..5643d47d9b7983f57f1c851836107258d186bf58 100755 (executable)
@@ -34,7 +34,8 @@ TEST(HybridAllocator, basic)
   {
     uint64_t block_size = 0x1000;
     uint64_t capacity = 0x10000 * _1m; // = 64GB
-    TestHybridAllocator ha(g_ceph_context, capacity, block_size, 4, "test_hybrid_allocator");
+    TestHybridAllocator ha(g_ceph_context, capacity, block_size,
+      4 * sizeof(range_seg_t), "test_hybrid_allocator");
 
     ASSERT_EQ(0, ha.get_free());
     ASSERT_EQ(0, ha.get_avl_free());