]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: do not call _block_picker() again if already searched from start() 38148/head
authorjhonxue <jhonxue@tencent.com>
Wed, 18 Nov 2020 09:41:57 +0000 (17:41 +0800)
committerjhonxue <jhonxue@tencent.com>
Wed, 18 Nov 2020 09:41:57 +0000 (17:41 +0800)
Fixes: https://tracker.ceph.com/issues/48272
Signed-off-by: Xue Yantao <jhonxue@tencent.com>
src/os/bluestore/AvlAllocator.cc

index e9d0510798626b614b01982d977f6f6fe1a7ecc5..3a1f66f7f2bced35cfc4294afa5eeeaaa0ecee94 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;