summaryrefslogtreecommitdiffstats
path: root/src/os/bluestore/AvlAllocator.cc
diff options
context:
space:
mode:
authorIgor Fedotov <ifedotov@suse.com>2022-08-22 16:29:27 +0200
committerIgor Fedotov <igor.fedotov@croit.io>2022-12-19 09:08:46 +0100
commit3c922133eee7466ed2169d0ff5c83e94c3a03cff (patch)
tree3d59b05a9cafb3762ff2d56e1a803a2559b2e834 /src/os/bluestore/AvlAllocator.cc
parentMerge pull request #49292 from rhcs-dashboard/rbd-mirror-improvements (diff)
downloadceph-3c922133eee7466ed2169d0ff5c83e94c3a03cff.tar.xz
ceph-3c922133eee7466ed2169d0ff5c83e94c3a03cff.zip
os/bluestore: assert on improper releases in AvlAllocator
Let's assert on unexpected unit release before we damage internal data structures. Plus uniforms some logging output for avl/hybrid allocator with bitmap one to enable replay tool usage. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io>
Diffstat (limited to 'src/os/bluestore/AvlAllocator.cc')
-rw-r--r--src/os/bluestore/AvlAllocator.cc60
1 files changed, 43 insertions, 17 deletions
diff --git a/src/os/bluestore/AvlAllocator.cc b/src/os/bluestore/AvlAllocator.cc
index 4584bfae713..9d828ee313c 100644
--- a/src/os/bluestore/AvlAllocator.cc
+++ b/src/os/bluestore/AvlAllocator.cc
@@ -105,6 +105,16 @@ void AvlAllocator::_add_to_tree(uint64_t start, uint64_t size)
rs_before = std::prev(rs_after);
}
+ if ((rs_before != range_tree.end() && rs_before->end > start) ||
+ (rs_after != range_tree.end() && rs_after->start < end)) {
+ derr << __func__ << " inconsistent tree state " << std::hex
+ << " 0x" << start << "~" << end - start
+ << std::dec << dendl;
+ _dump();
+ }
+ ceph_assert(rs_before == range_tree.end() || rs_before->end <= start);
+ ceph_assert(rs_after == range_tree.end() || rs_after->start >= end);
+
bool merge_before = (rs_before != range_tree.end() && rs_before->end == start);
bool merge_after = (rs_after != range_tree.end() && rs_after->start == end);
@@ -169,6 +179,14 @@ void AvlAllocator::_remove_from_tree(uint64_t start, uint64_t size)
auto rs = range_tree.find(range_t{start, end}, range_tree.key_comp());
/* Make sure we completely overlap with someone */
+ if (rs == range_tree.end() ||
+ rs->start > start ||
+ rs->end < end) {
+ derr << __func__ << " inconsistent tree state " << std::hex
+ << " 0x" << rs->start << "~" << rs->end - rs->start
+ << std::dec << dendl;
+ _dump();
+ }
ceph_assert(rs != range_tree.end());
ceph_assert(rs->start <= start);
ceph_assert(rs->end >= end);
@@ -292,7 +310,9 @@ int AvlAllocator::_allocate(
if (start == -1ULL) {
return -ENOSPC;
}
-
+ dout(20) << __func__ << " allocated 0x" << std::hex
+ << start << "~" << size
+ << std::dec << dendl;
_remove_from_tree(start, size);
*offset = start;
@@ -306,9 +326,9 @@ void AvlAllocator::_release(const interval_set<uint64_t>& release_set)
const auto offset = p.get_start();
const auto length = p.get_len();
ceph_assert(offset + length <= uint64_t(device_size));
- ldout(cct, 10) << __func__ << std::hex
- << " offset 0x" << offset
- << " length 0x" << length
+ ldout(cct, 20) << __func__ << std::hex
+ << " 0x" << offset
+ << "~" << length
<< std::dec << dendl;
_add_to_tree(offset, length);
}
@@ -316,9 +336,9 @@ void AvlAllocator::_release(const interval_set<uint64_t>& release_set)
void AvlAllocator::_release(const PExtentVector& release_set) {
for (auto& e : release_set) {
- ldout(cct, 10) << __func__ << std::hex
- << " offset 0x" << e.offset
- << " length 0x" << e.length
+ ldout(cct, 20) << __func__ << std::hex
+ << " 0x" << e.offset
+ << "~" << e.length
<< std::dec << dendl;
_add_to_tree(e.offset, e.length);
}
@@ -346,14 +366,20 @@ AvlAllocator::AvlAllocator(CephContext* cct,
cct->_conf.get_val<Option::size_t>("bluestore_avl_alloc_ff_max_search_bytes")),
range_count_cap(max_mem / sizeof(range_seg_t)),
cct(cct)
-{}
+{
+ ldout(cct, 10) << __func__ << " 0x" << std::hex << get_capacity() << "/"
+ << get_block_size() << std::dec << dendl;
+}
AvlAllocator::AvlAllocator(CephContext* cct,
int64_t device_size,
int64_t block_size,
std::string_view name) :
AvlAllocator(cct, device_size, block_size, 0 /* max_mem */, name)
-{}
+{
+ ldout(cct, 10) << __func__ << " 0x" << std::hex << get_capacity() << "/"
+ << get_block_size() << std::dec << dendl;
+}
AvlAllocator::~AvlAllocator()
{
@@ -368,10 +394,10 @@ int64_t AvlAllocator::allocate(
PExtentVector* extents)
{
ldout(cct, 10) << __func__ << std::hex
- << " want 0x" << want
- << " unit 0x" << unit
- << " max_alloc_size 0x" << max_alloc_size
- << " hint 0x" << hint
+ << " 0x" << want
+ << "/" << unit
+ << "," << max_alloc_size
+ << "," << hint
<< std::dec << dendl;
ceph_assert(std::has_single_bit(unit));
ceph_assert(want % unit == 0);
@@ -450,8 +476,8 @@ void AvlAllocator::init_add_free(uint64_t offset, uint64_t length)
std::lock_guard l(lock);
ceph_assert(offset + length <= uint64_t(device_size));
ldout(cct, 10) << __func__ << std::hex
- << " offset 0x" << offset
- << " length 0x" << length
+ << " 0x" << offset
+ << "~" << length
<< std::dec << dendl;
_add_to_tree(offset, length);
}
@@ -463,8 +489,8 @@ void AvlAllocator::init_rm_free(uint64_t offset, uint64_t length)
std::lock_guard l(lock);
ceph_assert(offset + length <= uint64_t(device_size));
ldout(cct, 10) << __func__ << std::hex
- << " offset 0x" << offset
- << " length 0x" << length
+ << " 0x" << offset
+ << "~" << length
<< std::dec << dendl;
_remove_from_tree(offset, length);
}