]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/onode-staged-tree: implement delta encode/decode for erase ops
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 23 Apr 2021 03:00:34 +0000 (11:00 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Thu, 29 Apr 2021 08:03:37 +0000 (16:03 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_accessor.h
src/crimson/os/seastore/onode_manager/staged-fltree/node_layout_replayable.h
src/crimson/os/seastore/onode_manager/staged-fltree/node_types.h

index a3aa92c74490dbcdc2ff5162e86566d7a474953f..01a931e91439ec3127d1a88cec923b92b470838a 100644 (file)
@@ -84,6 +84,16 @@ class DeltaRecorderT final: public DeltaRecorder {
     ceph::encode(static_cast<node_offset_t>(node_offset), encoded);
   }
 
+  void encode_erase(
+      const position_t& erase_pos) {
+    ceph::encode(node_delta_op_t::ERASE, encoded);
+    erase_pos.encode(encoded);
+  }
+
+  void encode_make_tail() {
+    ceph::encode(node_delta_op_t::MAKE_TAIL, encoded);
+  }
+
   static DeltaRecorderURef create_for_encode(const ValueBuilder& v_builder) {
     return std::unique_ptr<DeltaRecorder>(new DeltaRecorderT(v_builder));
   }
@@ -159,6 +169,19 @@ class DeltaRecorderT final: public DeltaRecorder {
         layout_t::update_child_addr(node, new_addr, p_addr);
         break;
       }
+      case node_delta_op_t::ERASE: {
+        logger().debug("OTree::Extent::Replay: decoding ERASE ...");
+        auto erase_pos = position_t::decode(delta);
+        logger().debug("OTree::Extent::Replay: apply erase_pos({}) ...",
+                       erase_pos);
+        layout_t::erase(node, stage, erase_pos);
+        break;
+      }
+      case node_delta_op_t::MAKE_TAIL: {
+        logger().debug("OTree::Extent::Replay: decoded MAKE_TAIL, apply ...");
+        layout_t::make_tail(node, stage);
+        break;
+      }
       case node_delta_op_t::SUBOP_UPDATE_VALUE: {
         logger().debug("OTree::Extent::Replay: decoding SUBOP_UPDATE_VALUE ...");
         node_offset_t value_header_offset;
@@ -415,6 +438,40 @@ class NodeExtentAccessorT {
 #endif
   }
 
+  std::tuple<match_stage_t, position_t> erase_replayable(const position_t& pos) {
+    assert(extent->is_pending());
+    assert(state != nextent_state_t::READ_ONLY);
+    if (state == nextent_state_t::MUTATION_PENDING) {
+      recorder->encode_erase(pos);
+    }
+#ifndef NDEBUG
+    test_extent->prepare_replay(extent);
+    test_recorder->encode_erase(pos);
+#endif
+    auto ret = layout_t::erase(*mut, read(), pos);
+#ifndef NDEBUG
+    test_extent->replay_and_verify(extent);
+#endif
+    return ret;
+  }
+
+  position_t make_tail_replayable() {
+    assert(extent->is_pending());
+    assert(state != nextent_state_t::READ_ONLY);
+    if (state == nextent_state_t::MUTATION_PENDING) {
+      recorder->encode_make_tail();
+    }
+#ifndef NDEBUG
+    test_extent->prepare_replay(extent);
+    test_recorder->encode_make_tail();
+#endif
+    auto ret = layout_t::make_tail(*mut, read());
+#ifndef NDEBUG
+    test_extent->replay_and_verify(extent);
+#endif
+    return ret;
+  }
+
   std::pair<NodeExtentMutable&, ValueDeltaRecorder*>
   prepare_mutate_value_payload(context_t c) {
     prepare_mutate(c);
index 23497219a15430e5781e7124e7473bc931695818..795c1cce23da62c9bf3f4f0239e83e574b267015 100644 (file)
@@ -71,6 +71,22 @@ struct NodeLayoutReplayableT {
     assert(NODE_TYPE == node_type_t::INTERNAL);
     mut.copy_in_absolute(p_addr, new_addr);
   }
+
+  static std::tuple<match_stage_t, position_t> erase(
+      NodeExtentMutable& mut,
+      const node_stage_t& node_stage,
+      const position_t& _erase_pos) {
+    // TODO
+    ceph_abort("not implemented");
+  }
+
+  static position_t make_tail(
+      NodeExtentMutable& mut,
+      const node_stage_t& node_stage) {
+    assert(!node_stage.is_level_tail());
+    // TODO
+    ceph_abort("not implemented");
+  }
 };
 
 }
index 0877920f244fe6e607f9a957c4614ebc067dda1a..c5ee76b71bca8ec408db03240ee839d4e63ebe6a 100644 (file)
@@ -66,6 +66,8 @@ enum class node_delta_op_t : uint8_t {
   SPLIT,
   SPLIT_INSERT,
   UPDATE_CHILD_ADDR,
+  ERASE,
+  MAKE_TAIL,
   SUBOP_UPDATE_VALUE = 0xff,
 };