From: jhonxue Date: Wed, 18 Nov 2020 09:41:57 +0000 (+0800) Subject: os/bluestore: do not call _block_picker() again if already searched from start() X-Git-Tag: v16.1.0~516^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fd5ca26e4a23d6c8992ab5927ce85ade958e251f;p=ceph.git 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 --- diff --git a/src/os/bluestore/AvlAllocator.cc b/src/os/bluestore/AvlAllocator.cc index e9d051079862..3a1f66f7f2bc 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;