]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Always update the cursor position in AVL near-fit search. 45885/head
authorMark Nelson <mnelson@redhat.com>
Wed, 13 Apr 2022 00:53:56 +0000 (00:53 +0000)
committerNeha Ojha <nojha@redhat.com>
Wed, 13 Apr 2022 23:57:23 +0000 (23:57 +0000)
Signed-off-by: Mark Nelson <mnelson@redhat.com>
(cherry picked from commit 3bed53debfa2f9ec9d31021ce7eaf8b78f78f9e0)

src/os/bluestore/AvlAllocator.cc

index e7a9befef051b0a112717a130429dbc0f9f233e8..72bff28948af9c1b4d99185bb60556df9934cced 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) {