]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Synchronize AvlAllocator device_size and block_size with other Allocators. 38476/head
authorAdam Kupczyk <akupczyk@redhat.com>
Mon, 15 Feb 2021 13:17:25 +0000 (14:17 +0100)
committerKefu Chai <kchai@redhat.com>
Thu, 11 Mar 2021 04:04:19 +0000 (12:04 +0800)
Modify AvlAllocator to use device_size and block_size from Allocator.

Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
src/os/bluestore/AvlAllocator.cc
src/os/bluestore/AvlAllocator.h

index f6a11b4f9bebe88fc70e0205c6ff1a686eb34ce6..43e2387c5c196e8b7624b5893826d3f8e3597477 100644 (file)
@@ -230,7 +230,7 @@ int AvlAllocator::_allocate(
   ceph_assert(align != 0);
   uint64_t *cursor = &lbas[cbits(align) - 1];
 
-  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 switch to using the size
@@ -268,7 +268,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
@@ -299,8 +299,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(
@@ -314,8 +312,6 @@ AvlAllocator::AvlAllocator(CephContext* cct,
                           int64_t block_size,
                           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(
@@ -407,7 +403,7 @@ void AvlAllocator::dump(std::function<void(uint64_t offset, uint64_t length)> no
 void AvlAllocator::init_add_free(uint64_t offset, uint64_t length)
 {
   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
@@ -418,7 +414,7 @@ void AvlAllocator::init_add_free(uint64_t offset, uint64_t length)
 void AvlAllocator::init_rm_free(uint64_t offset, uint64_t length)
 {
   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 426db78ad39eaa21921a7ddfc41d633050643fee..a4b1b52cfe2cb7f7d3b850044efc791f5df65b82 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;
 
@@ -134,8 +127,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
 
   /*
@@ -226,7 +217,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;
     }