]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Synchronize AvlAllocator device_size and block_size with other Allocators.
authorAdam Kupczyk <akupczyk@redhat.com>
Mon, 15 Feb 2021 13:17:25 +0000 (14:17 +0100)
committerIgor Fedotov <igor.fedotov@croit.io>
Wed, 1 Mar 2023 10:16:37 +0000 (13:16 +0300)
Modify AvlAllocator to use device_size and block_size from Allocator.

Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
(cherry picked from commit 28ea3c514c32a8f67b9e09c169f65e06bfc6eef9)

 Conflicts:
src/os/bluestore/AvlAllocator.cc
 <trivial, due to misordered backports>

src/os/bluestore/AvlAllocator.cc
src/os/bluestore/AvlAllocator.h

index 9152c0e32a8f57cf1677aea341c7dea07080587a..9a5fbf33ebb5aaf6b72d47c2c10391244332240e 100644 (file)
@@ -254,7 +254,7 @@ int AvlAllocator::_allocate(
     force_range_size_alloc = true;
   }
 
-  const int free_pct = num_free * 100 / num_total;
+  const int free_pct = num_free * 100 / device_size;
   uint64_t start = 0;
   // If we're running low on space, find a range by size by looking up in the size
   // sorted tree (best-fit), instead of searching in the area pointed by cursor
@@ -304,7 +304,7 @@ void AvlAllocator::_release(const interval_set<uint64_t>& release_set)
   for (auto p = release_set.begin(); p != release_set.end(); ++p) {
     const auto offset = p.get_start();
     const auto length = p.get_len();
-    ceph_assert(offset + length <= uint64_t(num_total));
+    ceph_assert(offset + length <= uint64_t(device_size));
     ldout(cct, 10) << __func__ << std::hex
       << " offset 0x" << offset
       << " length 0x" << length
@@ -335,8 +335,6 @@ AvlAllocator::AvlAllocator(CephContext* cct,
                            uint64_t max_mem,
                            const std::string& name) :
   Allocator(name, device_size, block_size),
-  num_total(device_size),
-  block_size(block_size),
   range_size_alloc_threshold(
     cct->_conf.get_val<uint64_t>("bluestore_avl_alloc_bf_threshold")),
   range_size_alloc_free_pct(
@@ -353,7 +351,16 @@ AvlAllocator::AvlAllocator(CephContext* cct,
                           int64_t device_size,
                           int64_t block_size,
                           const std::string& name) :
-  AvlAllocator(cct, device_size, block_size, 0 /* max_mem */, name)
+  Allocator(name, device_size, block_size),
+  range_size_alloc_threshold(
+    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")),
+  max_search_count(
+    cct->_conf.get_val<uint64_t>("bluestore_avl_alloc_ff_max_search_count")),
+  max_search_bytes(
+    cct->_conf.get_val<Option::size_t>("bluestore_avl_alloc_ff_max_search_bytes")),
+  cct(cct)
 {}
 
 AvlAllocator::~AvlAllocator()
@@ -449,7 +456,7 @@ void AvlAllocator::init_add_free(uint64_t offset, uint64_t length)
   if (!length)
     return;
   std::lock_guard l(lock);
-  ceph_assert(offset + length <= uint64_t(num_total));
+  ceph_assert(offset + length <= uint64_t(device_size));
   ldout(cct, 10) << __func__ << std::hex
                  << " offset 0x" << offset
                  << " length 0x" << length
@@ -462,7 +469,7 @@ void AvlAllocator::init_rm_free(uint64_t offset, uint64_t length)
   if (!length)
     return;
   std::lock_guard l(lock);
-  ceph_assert(offset + length <= uint64_t(num_total));
+  ceph_assert(offset + length <= uint64_t(device_size));
   ldout(cct, 10) << __func__ << std::hex
                  << " offset 0x" << offset
                  << " length 0x" << length
index f47ee5be003e44a31d5f8b44fe9b9978d0a5fac3..d1c1da257c4e033786ccd09d3661d025718ca0b0 100644 (file)
@@ -82,13 +82,6 @@ public:
     int64_t  hint,
     PExtentVector *extents) override;
   void release(const interval_set<uint64_t>& release_set) override;
-  int64_t get_capacity() const {
-    return num_total;
-  }
-
-  uint64_t get_block_size() const {
-    return block_size;
-  }
   uint64_t get_free() override;
   double get_fragmentation() override;
 
@@ -141,8 +134,6 @@ private:
       boost::intrusive::constant_time_size<true>>;
   range_size_tree_t range_size_tree;
 
-  const int64_t num_total;   ///< device size
-  const uint64_t block_size; ///< block size
   uint64_t num_free = 0;     ///< total bytes in freelist
 
   /*
@@ -244,7 +235,7 @@ protected:
   std::mutex lock;
 
   double _get_fragmentation() const {
-    auto free_blocks = p2align(num_free, block_size) / block_size;
+    auto free_blocks = p2align(num_free, (uint64_t)block_size) / block_size;
     if (free_blocks <= 1) {
       return .0;
     }