From: Adam Kupczyk Date: Mon, 15 Feb 2021 13:17:25 +0000 (+0100) Subject: os/bluestore: Synchronize AvlAllocator device_size and block_size with other Allocators. X-Git-Tag: v16.2.14~68^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9fa7f5ed8f5d3bd8b565e62e55e7d5caa245313f;p=ceph.git os/bluestore: Synchronize AvlAllocator device_size and block_size with other Allocators. Modify AvlAllocator to use device_size and block_size from Allocator. Signed-off-by: Adam Kupczyk (cherry picked from commit 28ea3c514c32a8f67b9e09c169f65e06bfc6eef9) Conflicts: src/os/bluestore/AvlAllocator.cc --- diff --git a/src/os/bluestore/AvlAllocator.cc b/src/os/bluestore/AvlAllocator.cc index 9152c0e32a8f..9a5fbf33ebb5 100644 --- a/src/os/bluestore/AvlAllocator.cc +++ b/src/os/bluestore/AvlAllocator.cc @@ -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& 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("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("bluestore_avl_alloc_bf_threshold")), + range_size_alloc_free_pct( + cct->_conf.get_val("bluestore_avl_alloc_bf_free_pct")), + max_search_count( + cct->_conf.get_val("bluestore_avl_alloc_ff_max_search_count")), + max_search_bytes( + cct->_conf.get_val("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 diff --git a/src/os/bluestore/AvlAllocator.h b/src/os/bluestore/AvlAllocator.h index f47ee5be003e..d1c1da257c4e 100644 --- a/src/os/bluestore/AvlAllocator.h +++ b/src/os/bluestore/AvlAllocator.h @@ -82,13 +82,6 @@ public: int64_t hint, PExtentVector *extents) override; void release(const interval_set& 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>; 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; }