From bc99521aec1fb6d3b9ef7f56cb4aaeff8ff9a266 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Sat, 12 May 2018 00:26:49 +0300 Subject: [PATCH] os/bluestore: align BitMap allocator's init_rm_free/init_add_free parameters with min_alloc_size Signed-off-by: Igor Fedotov (cherry picked from commit 1b6a56e80066decf8c3727090a2cd51ba9ded9bc) --- src/os/bluestore/BitmapFastAllocator.cc | 12 ++++++++++-- src/os/bluestore/fastbmap_allocator_impl.h | 10 ++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/os/bluestore/BitmapFastAllocator.cc b/src/os/bluestore/BitmapFastAllocator.cc index 2733ccd060d43..35c752708fa34 100755 --- a/src/os/bluestore/BitmapFastAllocator.cc +++ b/src/os/bluestore/BitmapFastAllocator.cc @@ -53,13 +53,21 @@ void BitmapFastAllocator::init_add_free(uint64_t offset, uint64_t length) { ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length << std::dec << dendl; - _mark_free(offset, length); + + auto mas = get_min_alloc_size(); + uint64_t offs = ROUND_UP_TO(offset, mas); + uint64_t l = P2ALIGN(offset + length - offs, mas); + + _mark_free(offs, l); } void BitmapFastAllocator::init_rm_free(uint64_t offset, uint64_t length) { ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length << std::dec << dendl; - _mark_allocated(offset, length); + auto mas = get_min_alloc_size(); + uint64_t offs = ROUND_UP_TO(offset, mas); + uint64_t l = P2ALIGN(offset + length - offs, mas); + _mark_allocated(offs, l); } void BitmapFastAllocator::shutdown() diff --git a/src/os/bluestore/fastbmap_allocator_impl.h b/src/os/bluestore/fastbmap_allocator_impl.h index 72a4f16b81168..2611826c7a7fd 100755 --- a/src/os/bluestore/fastbmap_allocator_impl.h +++ b/src/os/bluestore/fastbmap_allocator_impl.h @@ -104,6 +104,12 @@ protected: inline bool _is_slot_fully_allocated(uint64_t idx) const { return l1[idx] == all_slot_clear; } +public: + inline uint64_t get_min_alloc_size() const + { + return l0_granularity; + } + }; template @@ -538,6 +544,10 @@ public: std::lock_guard l(lock); return available; } + inline uint64_t get_min_alloc_size() const + { + return l1.get_min_alloc_size(); + } protected: std::mutex lock; -- 2.39.5