]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/cache: update extent states after resolving the linked tree
authorYingxin Cheng <yingxin.cheng@intel.com>
Tue, 17 Jun 2025 04:20:21 +0000 (12:20 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Tue, 17 Jun 2025 04:46:48 +0000 (12:46 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/cache.cc

index 070ad1414bf595c058e485705ad13facc71f339e..deb47dcac671d0ba657aefbb68d57934120a2cda 100644 (file)
@@ -913,7 +913,6 @@ void Cache::commit_replace_extent(
     add_to_dirty(next, &t_src);
   }
 
-  next->on_replace_prior();
   invalidate_extent(t, *prev);
 }
 
@@ -1300,13 +1299,9 @@ record_t Cache::prepare_record(
     i->prepare_commit();
 
     if (i->is_mutation_pending()) {
-      i->set_io_wait(CachedExtent::extent_state_t::DIRTY);
-      // extent with EXIST_MUTATION_PENDING doesn't have
-      // prior_instance field so skip these extents.
-      // the existing extents should be added into Cache
-      // during complete_commit to sync with gc transaction.
-      commit_replace_extent(t, i, i->prior_instance);
-    } // Note, else(is_exist_mutation_pending), add_extent() atomically
+      i->on_replace_prior();
+    } // else, is_exist_mutation_pending():
+      // - it doesn't have prior_instance to replace
 
     assert(i->get_version() > 0);
     auto final_crc = i->calc_crc32c();
@@ -1374,6 +1369,24 @@ record_t Cache::prepare_record(
     e->prepare_commit();
   });
 
+  /*
+   * We can only update extent states after the logical linked tree is
+   * resolved:
+   * - on_replace_prior()
+   * - prepare_commit()
+   */
+  for (auto &i: t.mutated_block_list) {
+    if (i->is_valid()) {
+      if (i->is_mutation_pending()) {
+        i->set_io_wait(CachedExtent::extent_state_t::DIRTY);
+        commit_replace_extent(t, i, i->prior_instance);
+      } // else, is_exist_mutation_pending():
+        // - it doesn't have prior_instance to replace
+        // - and add_extent() atomically below
+        // - set_io_wait(DIRTY) atomically below
+    }
+  }
+
   // Transaction is now a go, set up in-memory cache state
   // invalidate now invalid blocks
   io_stat_t retire_stat;