]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: do not call _block_picker() again if already searched from start()
authorjhonxue <jhonxue@tencent.com>
Wed, 18 Nov 2020 09:41:57 +0000 (17:41 +0800)
committerMauricio Faria de Oliveira <mfo@canonical.com>
Wed, 10 Nov 2021 15:07:56 +0000 (12:07 -0300)
Fixes: https://tracker.ceph.com/issues/48272
Signed-off-by: Xue Yantao <jhonxue@tencent.com>
(cherry picked from commit fd5ca26e4a23d6c8992ab5927ce85ade958e251f)
Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
src/os/bluestore/AvlAllocator.cc

index b66ea33fce8e873597fadac416656e83be1a7e7c..9b148b6810d9d8dc5bad3ea467eb256f427ac4fa 100644 (file)
@@ -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;