From: Xuehan Xu Date: Sat, 30 May 2026 02:58:27 +0000 (+0800) Subject: crimson/os/seastore: invalidate the transaction if it has written X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fheads%2Fdev-lbc;p=ceph-ci.git crimson/os/seastore: invalidate the transaction if it has written lba/backref nodes to the disk when the rewrite transaction tries to merge those nodes' content Otherwise, the result of the merging won't be persisted to the disk Signed-off-by: Xuehan Xu --- diff --git a/src/crimson/os/seastore/cache.cc b/src/crimson/os/seastore/cache.cc index 8d724278f53..b57b6feed8f 100644 --- a/src/crimson/os/seastore/cache.cc +++ b/src/crimson/os/seastore/cache.cc @@ -1029,20 +1029,19 @@ void Cache::commit_replace_extent( } -void Cache::invalidate_extent( - Transaction& t, - CachedExtent& extent) +void Cache::invalidate_trans( + Transaction &t, + CachedExtent &extent, + bool backref_lba_written_only) { - if (!extent.may_conflict()) { - assert(extent.read_transactions.empty()); - extent.set_invalid(t); - return; - } - LOG_PREFIX(Cache::invalidate_extent); bool do_conflict_log = true; std::vector invalidated_trans; for (auto &&i: extent.read_transactions) { + if (likely(backref_lba_written_only && + !i.t->backref_lba_ool_written)) { + continue; + } if (!i.t->conflicted) { if (do_conflict_log) { SUBDEBUGT(seastore_t, "conflict begin -- {}", t, extent); @@ -1060,6 +1059,20 @@ void Cache::invalidate_extent( trans->retired_set.clear(); trans->views.clear(); } +} + +void Cache::invalidate_extent( + Transaction& t, + CachedExtent& extent) +{ + if (!extent.may_conflict()) { + assert(extent.read_transactions.empty()); + extent.set_invalid(t); + return; + } + + invalidate_trans(t, extent, false); + extent.set_invalid(t); } @@ -1443,6 +1456,9 @@ record_t Cache::prepare_record( if (should_use_no_conflict_publish(t.get_src(), i->get_type())) { i->new_committer(t); i->committer->block_trans(t); + if (is_lba_backref_node(i->get_type())) { + invalidate_trans(t, *i->prior_instance, true); + } } assert(i->is_exist_mutation_pending() || i->prior_instance); @@ -1724,6 +1740,9 @@ record_t Cache::prepare_record( assert(i->committer); auto &committer = *i->committer; committer.block_trans(t); + if (is_lba_backref_node(i->get_type())) { + invalidate_trans(t, *i->prior_instance, true); + } i->get_prior_instance()->set_io_wait( CachedExtent::extent_state_t::CLEAN, should_use_no_conflict_publish(t.get_src(), i->get_type())); } @@ -1759,6 +1778,9 @@ record_t Cache::prepare_record( i->get_prior_instance()->committer = i->committer; auto &committer = *i->committer; committer.block_trans(t); + if (is_lba_backref_node(i->get_type())) { + invalidate_trans(t, *i->prior_instance, true); + } i->get_prior_instance()->set_io_wait( CachedExtent::extent_state_t::CLEAN, true); } diff --git a/src/crimson/os/seastore/cache.h b/src/crimson/os/seastore/cache.h index e88157c4e45..1baca40efb3 100644 --- a/src/crimson/os/seastore/cache.h +++ b/src/crimson/os/seastore/cache.h @@ -1993,6 +1993,10 @@ private: void stage_visibility_handoff(Transaction& t, CachedExtentRef next, CachedExtentRef prev); + void invalidate_trans( + Transaction &t, + CachedExtent &extent, + bool backref_lba_written_only); /// Invalidate extent and mark affected transactions void invalidate_extent(Transaction& t, CachedExtent& extent); diff --git a/src/crimson/os/seastore/transaction.h b/src/crimson/os/seastore/transaction.h index 4abcf240c71..11c72c5dedf 100644 --- a/src/crimson/os/seastore/transaction.h +++ b/src/crimson/os/seastore/transaction.h @@ -552,6 +552,7 @@ public: rewrite_stats = {}; conflicted = false; blocked_by.clear(); + backref_lba_ool_written = false; assert(backref_entries.empty()); if (!has_reset) { has_reset = true; @@ -685,6 +686,7 @@ public: // when the rewrite transactions that modifies the extent are // committing. std::set blocked_by;; + bool backref_lba_ool_written = false; private: friend class Cache; diff --git a/src/crimson/os/seastore/transaction_manager.cc b/src/crimson/os/seastore/transaction_manager.cc index 97d8d15f779..7018721269d 100644 --- a/src/crimson/os/seastore/transaction_manager.cc +++ b/src/crimson/os/seastore/transaction_manager.cc @@ -733,6 +733,13 @@ TransactionManager::do_submit_transaction( auto num_extents = allocated_extents.size(); SUBTRACET(seastore_t, "process {} allocated extents", tref, num_extents); + if (epm->get_main_backend_type() == backend_type_t::RANDOM_BLOCK) { + tref.backref_lba_ool_written = true; + } + while (!tref.blocked_by.empty()) { + co_await trans_intr::make_interruptible(seastar::yield()); + } + co_await epm->write_preallocated_ool_extents(tref, allocated_extents); SUBTRACET(seastore_t, "entering prepare", tref); @@ -740,9 +747,6 @@ TransactionManager::do_submit_transaction( tref.get_handle().enter(write_pipeline.prepare) ); - while (!tref.blocked_by.empty()) { - co_await trans_intr::make_interruptible(seastar::yield()); - } if (trim_alloc_to && *trim_alloc_to != JOURNAL_SEQ_NULL) { SUBTRACET(seastore_t, "trim backref_bufs to {}", tref, *trim_alloc_to); cache->trim_backref_bufs(*trim_alloc_to);