]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore: allow concurrent rewrite transactions
authorXuehan Xu <xuxuehan@qianxin.com>
Sat, 23 May 2026 04:05:06 +0000 (12:05 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Mon, 25 May 2026 03:06:53 +0000 (11:06 +0800)
Since promote/demote background processes can run concurrently with
trimming and cleaning, there maybe more than one sources that block
client transactions from submitting. We need to allow such cases.

Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/os/seastore/cached_extent.cc
src/crimson/os/seastore/transaction.h
src/crimson/os/seastore/transaction_manager.cc

index 4394480b5734943c65d600435e305b27f0f16295..8ce636a580ad7fc66b963a46cac69394315c757b 100644 (file)
@@ -594,7 +594,7 @@ void ExtentCommitter::block_trans(Transaction &t) {
   for (auto &item : prior.read_transactions) {
     TRACET("blocking trans {} for rewriting {}",
       t, item.t->get_trans_id(), *item.ref);
-    item.t->need_wait_visibility = true;
+    item.t->blocked_by.insert(t.get_trans_id());
   }
 }
 
@@ -604,7 +604,7 @@ void ExtentCommitter::unblock_trans(Transaction &t) {
   for (auto &item : prior.read_transactions) {
     TRACET("unblocking trans {} for rewriting {}",
       t, item.t->get_trans_id(), *item.ref);
-    item.t->need_wait_visibility = false;
+    item.t->blocked_by.erase(t.get_trans_id());
   }
 }
 
index 1e77b3acc727827b0025c3d5a1997b8fc5162836..4abcf240c71a9d406500f83e6d92af7ff90ec386 100644 (file)
@@ -551,7 +551,7 @@ public:
     ool_write_stats = {};
     rewrite_stats = {};
     conflicted = false;
-    need_wait_visibility = false;
+    blocked_by.clear();
     assert(backref_entries.empty());
     if (!has_reset) {
       has_reset = true;
@@ -679,7 +679,12 @@ public:
 
   btree_cursor_stats_t cursor_stats;
 
- bool need_wait_visibility = false;
+  // XXX: To allow multiple rewrite transactions to block the same
+  // transaction, we can't simply use a counter. Because a client
+  // transaction may be add to the read_transactions of an extent
+  // when the rewrite transactions that modifies the extent are
+  // committing.
+  std::set<transaction_id_t> blocked_by;;
 
 private:
   friend class Cache;
index 83fa50d75454b029f63e4ece7064d5efb570c444..97d8d15f779d3403d80dfab5702fe14e41d701d0 100644 (file)
@@ -740,7 +740,7 @@ TransactionManager::do_submit_transaction(
     tref.get_handle().enter(write_pipeline.prepare)
   );
 
-  while (tref.need_wait_visibility) {
+  while (!tref.blocked_by.empty()) {
     co_await trans_intr::make_interruptible(seastar::yield());
   }
   if (trim_alloc_to && *trim_alloc_to != JOURNAL_SEQ_NULL) {
@@ -991,7 +991,6 @@ TransactionManager::rewrite_extent_ret TransactionManager::rewrite_extent(
            rewrite_gen_printer_t{target_generation},
            sea_time_point_printer_t{modify_time},
            *extent);
-    ceph_assert(!extent->is_pending_io());
   }
 
   assert(extent->is_valid() && !extent->is_initial_pending());