]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/.../lba_manager: convert alloc_extents_ret to use LBACursor
authorSamuel Just <sjust@redhat.com>
Fri, 10 Oct 2025 01:53:32 +0000 (01:53 +0000)
committerSamuel Just <sjust@redhat.com>
Mon, 5 Jan 2026 21:14:58 +0000 (13:14 -0800)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/seastore/lba/btree_lba_manager.cc
src/crimson/os/seastore/lba/btree_lba_manager.h
src/crimson/os/seastore/lba_manager.h
src/crimson/os/seastore/lba_mapping.h
src/crimson/os/seastore/transaction_manager.h
src/test/crimson/seastore/test_btree_lba_manager.cc

index 1f5353eafd8fcca21d5b52ea977a5047d52d912c..dffed25cac7b515e3ee9a0ffba67c8602d55bab6 100644 (file)
@@ -367,18 +367,15 @@ BtreeLBAManager::reserve_region(
 BtreeLBAManager::alloc_extents_ret
 BtreeLBAManager::alloc_extents(
   Transaction &t,
-  LBAMapping pos,
+  LBACursorRef cursor,
   std::vector<LogicalChildNodeRef> extents)
 {
   LOG_PREFIX(BtreeLBAManager::alloc_extents);
-  DEBUGT("{}", t, pos);
-  assert(pos.is_viewable());
+  DEBUGT("{}", t, *cursor);
   auto c = get_context(t);
   auto btree = co_await get_btree<LBABtree>(cache, c);
-  auto &cursor = pos.get_effective_cursor();
-  co_await cursor.refresh();
-  auto iter = btree.make_partial_iter(c, cursor);
-  std::vector<LBAMapping> ret;
+  auto iter = btree.make_partial_iter(c, *cursor);
+  std::vector<LBACursorRef> ret;
   for (auto eiter = extents.rbegin(); eiter != extents.rend(); ++eiter) {
     auto ext = *eiter;
     assert(ext->has_laddr());
@@ -401,7 +398,7 @@ BtreeLBAManager::alloc_extents(
       ext.get(),
       leaf_node.get_size() - 1 /*the size before the insert*/);
     TRACET("inserted {}", c.trans, *ext);
-    ret.emplace(ret.begin(), LBAMapping::create_direct(it.get_cursor(c)));
+    ret.emplace(ret.begin(), it.get_cursor(c));
     iter = it;
 #ifndef NDEBUG
     if (eiter != extents.rend()) {
index 349d876fee178cd6f652e514f5d2d70777e50bef..d330c8b85c25308a783c220cb9f86229e1b51558 100644 (file)
@@ -122,7 +122,7 @@ public:
 
   alloc_extents_ret alloc_extents(
     Transaction &t,
-    LBAMapping pos,
+    LBACursorRef pos,
     std::vector<LogicalChildNodeRef> ext) final;
 
   alloc_extent_ret alloc_extent(
@@ -187,11 +187,7 @@ public:
       cursors = co_await alloc_contiguous_mappings(
        t, hint, alloc_infos, alloc_policy_t::linear_search);
     }
-    std::vector<LBAMapping> ret;
-    for (auto &cursor : cursors) {
-      ret.emplace_back(LBAMapping::create_direct(std::move(cursor)));
-    }
-    co_return ret;
+    co_return std::vector<LBACursorRef>(cursors.begin(), cursors.end());
   }
 
   base_iertr::future<LBACursorRef> update_mapping_refcount(
index ddb5ee4f9a97c8c1919c7f456a0418a1a8d61e30..80d815dab92d26667b02f66fd8358695df85da71 100644 (file)
@@ -111,7 +111,7 @@ public:
     extent_ref_count_t refcount) = 0;
 
   using alloc_extents_ret = alloc_extent_iertr::future<
-    std::vector<LBAMapping>>;
+    std::vector<LBACursorRef>>;
   virtual alloc_extents_ret alloc_extents(
     Transaction &t,
     laddr_t hint,
@@ -124,7 +124,7 @@ public:
    */
   virtual alloc_extents_ret alloc_extents(
     Transaction &t,
-    LBAMapping pos,
+    LBACursorRef cursor,
     std::vector<LogicalChildNodeRef> ext) = 0;
 
   struct clone_mapping_ret_t {
index 7592f90b4f669073be4b133e52f81e9bba574ba1..d17da45910740dc0289e9bbd974c02317a5f49de 100644 (file)
@@ -207,6 +207,13 @@ private:
     return *direct_cursor;
   }
 
+  LBACursorRef get_effective_cursor_ref() {
+    if (is_indirect()) {
+      return indirect_cursor;
+    }
+    return direct_cursor;
+  }
+
   bool is_null() const {
     return !direct_cursor && !indirect_cursor;
   }
index c307c88e4f145c6d043b310f58ed441ad489a4c3..15aff3f3e31e589c6aa5d73b4a2671291d5328a8 100644 (file)
@@ -464,7 +464,7 @@ public:
       auto npos = co_await pos->refresh();
       co_await lba_manager->alloc_extents(
        t,
-       std::move(npos),
+       npos.get_effective_cursor_ref(),
        std::vector<LogicalChildNodeRef>(
          exts.begin(), exts.end()));
     } else {
index be870746b526117dd59f510eda36ee8968cc9c18..33abb1b43f4e887703aa62fb0a7d21c6118bc5ea 100644 (file)
@@ -565,16 +565,16 @@ struct btree_lba_manager_test : btree_test_base {
        });
       }).unsafe_get();
     for (auto &ret : rets) {
-      logger().debug("alloc'd: {}", ret);
-      EXPECT_EQ(len, ret.get_length());
-      auto [b, e] = get_overlap(t, ret.get_key(), len);
+      logger().debug("alloc'd: {}", *ret);
+      EXPECT_EQ(len, ret->get_length());
+      auto [b, e] = get_overlap(t, ret->get_laddr(), len);
       EXPECT_EQ(b, e);
       t.mappings.emplace(
        std::make_pair(
-         ret.get_key(),
+         ret->get_laddr(),
          test_extent_t{
-           ret.get_val(),
-           ret.get_length(),
+           ret->get_paddr(),
+           ret->get_length(),
            1
          }
        ));