]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Always update the cursor position in AVL near-fit search. 45884/head
authorMark Nelson <mnelson@redhat.com>
Wed, 13 Apr 2022 00:53:56 +0000 (00:53 +0000)
committerMark Nelson <mnelson@redhat.com>
Wed, 13 Apr 2022 00:53:56 +0000 (00:53 +0000)
Signed-off-by: Mark Nelson <mnelson@redhat.com>
src/os/bluestore/AvlAllocator.cc

index 242fcac8111288286630f695e4d49e526a9e2f85..3ab12c0a9339366001bf27fc1fdcdfcac1b29219 100644 (file)
@@ -39,8 +39,8 @@ uint64_t AvlAllocator::_pick_block_after(uint64_t *cursor,
   auto rs_start = range_tree.lower_bound(range_t{*cursor, size}, compare);
   for (auto rs = rs_start; rs != range_tree.end(); ++rs) {
     uint64_t offset = p2roundup(rs->start, align);
+    *cursor = offset + size;
     if (offset + size <= rs->end) {
-      *cursor = offset + size;
       return offset;
     }
     if (max_search_count > 0 && ++search_count > max_search_count) {
@@ -51,6 +51,7 @@ uint64_t AvlAllocator::_pick_block_after(uint64_t *cursor,
       return -1ULL;
     }
   }
+
   if (*cursor == 0) {
     // If we already started from beginning, don't bother with searching from beginning
     return -1ULL;
@@ -58,8 +59,8 @@ uint64_t AvlAllocator::_pick_block_after(uint64_t *cursor,
   // If we reached end, start from beginning till cursor.
   for (auto rs = range_tree.begin(); rs != rs_start; ++rs) {
     uint64_t offset = p2roundup(rs->start, align);
+    *cursor = offset + size;
     if (offset + size <= rs->end) {
-      *cursor = offset + size;
       return offset;
     }
     if (max_search_count > 0 && ++search_count > max_search_count) {