From 259c23168c83bf42a11b4cde1b118caa52e75cfd Mon Sep 17 00:00:00 2001 From: jhonxue Date: Wed, 18 Nov 2020 17:41:57 +0800 Subject: [PATCH] os/bluestore: do not call _block_picker() again if already searched from start() Fixes: https://tracker.ceph.com/issues/48272 Signed-off-by: Xue Yantao (cherry picked from commit fd5ca26e4a23d6c8992ab5927ce85ade958e251f) Signed-off-by: Mauricio Faria de Oliveira --- src/os/bluestore/AvlAllocator.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/os/bluestore/AvlAllocator.cc b/src/os/bluestore/AvlAllocator.cc index b66ea33fce8e8..9b148b6810d9d 100644 --- a/src/os/bluestore/AvlAllocator.cc +++ b/src/os/bluestore/AvlAllocator.cc @@ -36,8 +36,8 @@ uint64_t AvlAllocator::_block_picker(const Tree& t, uint64_t align) { const auto compare = t.key_comp(); - for (auto rs = t.lower_bound(range_t{*cursor, size}, compare); - rs != t.end(); ++rs) { + auto rs_start = t.lower_bound(range_t{*cursor, size}, compare); + for (auto rs = rs_start; rs != t.end(); ++rs) { uint64_t offset = p2roundup(rs->start, align); if (offset + size <= rs->end) { *cursor = offset + size; @@ -48,7 +48,7 @@ uint64_t AvlAllocator::_block_picker(const Tree& t, * If we know we've searched the whole tree (*cursor == 0), give up. * Otherwise, reset the cursor to the beginning and try again. */ - if (*cursor == 0) { + if (*cursor == 0 || rs_start == t.begin()) { return -1ULL; } *cursor = 0; -- 2.39.5