]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastrore/omap_manager: initialize rewritten omap nodes when 64355/head
authorXuehan Xu <xuxuehan@qianxin.com>
Sat, 5 Jul 2025 12:46:16 +0000 (20:46 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Tue, 8 Jul 2025 02:42:04 +0000 (10:42 +0800)
preparing commit if the prior are seen by users after the nodes are
rewritten

Fixes: https://tracker.ceph.com/issues/71976
Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.h

index f1cbc2c3bdfc5074283e536ba754f93e1217371d..08585c4e7f980b0fe5790d310152e61cefc457f9 100644 (file)
@@ -70,9 +70,14 @@ struct OMapInnerNode
   void do_on_rewrite(Transaction &t, LogicalCachedExtent &extent) final {
     auto &ext = static_cast<OMapInnerNode&>(extent);
     this->parent_node_t::on_rewrite(t, ext);
-    auto &other = static_cast<OMapInnerNode&>(extent);
-    this->init_range(other.get_begin(), other.get_end());
     this->sync_children_capacity();
+    // During rewriting, an omap node may not be seen by users yet.
+    // If it becomes seen upon commiting, we need to fix the rewritting
+    // extent in prepare_commit().
+    if (likely(is_seen_by_users())) {
+      assert(ext.is_seen_by_users());
+      init_range(ext.get_begin(), ext.get_end());
+    }
   }
 
   void prepare_commit() final {
@@ -82,7 +87,10 @@ struct OMapInnerNode
       if (!prior.is_seen_by_users()) {
        return;
       }
+      // Here the prior that becomes seen after do_on_rewrite(),
+      // we need to initialize the rewritting extent accordingly.
       set_seen_by_users();
+      init_range(prior.get_begin(), prior.get_end());
     }
     this->parent_node_t::prepare_commit();
     if (is_rewrite()) {
@@ -306,8 +314,14 @@ struct OMapLeafNode
   using child_node_t = ChildNode<OMapInnerNode, OMapLeafNode, std::string>;
 
   void do_on_rewrite(Transaction &t, LogicalCachedExtent &extent) final {
-    auto &other = static_cast<OMapLeafNode&>(extent);
-    this->init_range(other.get_begin(), other.get_end());
+    // During rewriting, an omap node may not be seen by users yet.
+    // If it becomes seen upon commiting, we need to fix the rewritting
+    // extent in prepare_commit().
+    if (likely(is_seen_by_users())) {
+      auto &ext = static_cast<OMapLeafNode&>(*get_prior_instance());
+      assert(ext.is_seen_by_users());
+      init_range(ext.get_begin(), ext.get_end());
+    }
   }
 
   void on_invalidated(Transaction &t) final {
@@ -321,7 +335,10 @@ struct OMapLeafNode
       if (!prior.is_seen_by_users()) {
        return;
       }
+      // Here the prior that becomes seen after do_on_rewrite(),
+      // we need to initialize the rewritting extent accordingly.
       set_seen_by_users();
+      init_range(prior.get_begin(), prior.get_end());
     }
     if (is_rewrite()) {
       auto &prior = *get_prior_instance()->template cast<OMapLeafNode>();