From 3579408ef6012db60cb3e40b4e9ebd1adcb9716f Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 30 Sep 2025 10:52:45 -0700 Subject: [PATCH] crimson/.../transaction_manager: introduce resolve_cursor_to_mapping Signed-off-by: Samuel Just --- .../os/seastore/transaction_manager.cc | 37 +++++++++++++++++++ src/crimson/os/seastore/transaction_manager.h | 6 +++ 2 files changed, 43 insertions(+) diff --git a/src/crimson/os/seastore/transaction_manager.cc b/src/crimson/os/seastore/transaction_manager.cc index a5fde3ae47a6..e74c1b1c723a 100644 --- a/src/crimson/os/seastore/transaction_manager.cc +++ b/src/crimson/os/seastore/transaction_manager.cc @@ -424,6 +424,43 @@ TransactionManager::_remove( } } +using resolve_cursor_to_mapping_iertr = base_iertr; +resolve_cursor_to_mapping_iertr::future +TransactionManager::resolve_cursor_to_mapping( + Transaction &t, + LBACursorRef cursor) +{ + LOG_PREFIX(TransactionManager::resolve_cursor_to_mapping); + co_await cursor->refresh(); + if (cursor->is_end() || !cursor->is_indirect()) { + auto ret = co_await LBAMapping::create_direct(cursor).refresh(); + DEBUGT("{} -> {}", t, *cursor, ret); + co_return ret; + } + + assert(cursor->get_refcount() == EXTENT_DEFAULT_REF_COUNT); + assert(cursor->get_checksum() == 0); + + auto direct_cursors = co_await lba_manager->get_cursors( + t, + cursor->get_intermediate_key(), + cursor->get_length() + ); + + ceph_assert(direct_cursors.size() == 1); + auto& direct_cursor = direct_cursors.front(); + auto intermediate_key = cursor->get_intermediate_key(); + assert(!direct_cursor->is_indirect()); + assert(direct_cursor->get_laddr() <= intermediate_key); + assert(direct_cursor->get_laddr() + direct_cursor->get_length() + >= intermediate_key + cursor->get_length()); + auto ret = co_await LBAMapping::create_indirect( + std::move(direct_cursor), + cursor).refresh(); + DEBUGT("{} -> {}", t, *cursor, ret); + co_return ret; +} + TransactionManager::refs_ret TransactionManager::remove( Transaction &t, std::vector offsets) diff --git a/src/crimson/os/seastore/transaction_manager.h b/src/crimson/os/seastore/transaction_manager.h index 3fdf27f9ac04..8c07a9242600 100644 --- a/src/crimson/os/seastore/transaction_manager.h +++ b/src/crimson/os/seastore/transaction_manager.h @@ -1159,6 +1159,12 @@ private: return cache->can_drop_backref(); } + using resolve_cursor_to_mapping_iertr = base_iertr; + resolve_cursor_to_mapping_iertr::future + resolve_cursor_to_mapping( + Transaction &t, + LBACursorRef cursor); + using LBALeafNode = lba::LBALeafNode; struct unlinked_child_t { LBAMapping mapping; -- 2.47.3