]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.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>
Tue, 10 Mar 2026 17:11:33 +0000 (10:11 -0700)
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 7457ee2e5dff596eb35950ec8bf38820a4d4deb7..d633918567aad24d171a1539be6700380d005f67 100644 (file)
@@ -370,18 +370,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(
     auto &[it, inserted] = p;
     ceph_assert(inserted);
     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 4886ae5536abad4a194096e6837af4bf64d5bf8c..3642ed46f658f5d41d4cdd9b436986b665eff1ab 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 fd0e5a7881dc47c87c9682c078c4045385c08380..159c5508a44bec3dbbf4ca610488b9ea56bb3ab9 100644 (file)
@@ -114,7 +114,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,
@@ -127,7 +127,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 4e6ade4aea9cdf9a8ccb48a3143871d09c50059f..fbfa10ac8bdda35abd10ca9837be39cd4f7b6772 100644 (file)
@@ -218,6 +218,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 02a55fd4b94e0d074747270db40c47c8a7e61bd5..16b2e26911cf8031ca201044a4840bd80d12003f 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 a037a855889dbeff6e77b575f34e3040c3e1a23f..72ceefc85b8e501098e1e6ac8a4682d0ab80df66 100644 (file)
@@ -562,16 +562,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
          }
        ));