]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/seastore: add replay test for extent map tree 37829/head
authorchunmei-liu <chunmei.liu@intel.com>
Wed, 28 Oct 2020 00:01:37 +0000 (17:01 -0700)
committerchunmei-liu <chunmei.liu@intel.com>
Mon, 2 Nov 2020 19:52:43 +0000 (11:52 -0800)
Signed-off-by: chunmei-liu <chunmei.liu@intel.com>
src/crimson/os/seastore/extentmap_manager/btree/extentmap_btree_node_impl.cc
src/test/crimson/seastore/test_extmap_manager.cc

index 80a5f5a1301436bf8557eecd9440122048453527..7bf8680a532965966ceadb32a27a6de4dd11b549 100644 (file)
@@ -86,6 +86,7 @@ ExtMapInnerNode::rm_lextent(ext_context_t ec, objaddr_t lo, lext_map_val_t val)
 ExtMapInnerNode::split_children_ret
 ExtMapInnerNode::make_split_children(ext_context_t ec)
 {
+  logger().debug("{}: {}", "ExtMapInnerNode", __func__);
   return extmap_alloc_2extents<ExtMapInnerNode>(ec, EXTMAP_BLOCK_SIZE)
     .safe_then([this] (auto &&ext_pair) {
       auto [left, right] = ext_pair;
@@ -98,6 +99,7 @@ ExtMapInnerNode::make_split_children(ext_context_t ec)
 ExtMapInnerNode::full_merge_ret
 ExtMapInnerNode::make_full_merge(ext_context_t ec, ExtMapNodeRef right)
 {
+  logger().debug("{}: {}", "ExtMapInnerNode", __func__);
   return extmap_alloc_extent<ExtMapInnerNode>(ec, EXTMAP_BLOCK_SIZE)
     .safe_then([this, right] (auto &&replacement) {
       replacement->merge_from(*this, *right->cast<ExtMapInnerNode>());
@@ -110,6 +112,7 @@ ExtMapInnerNode::make_full_merge(ext_context_t ec, ExtMapNodeRef right)
 ExtMapInnerNode::make_balanced_ret
 ExtMapInnerNode::make_balanced(ext_context_t ec, ExtMapNodeRef _right, bool prefer_left)
 {
+  logger().debug("{}: {}", "ExtMapInnerNode", __func__);
   ceph_assert(_right->get_type() == type);
   return extmap_alloc_2extents<ExtMapInnerNode>(ec, EXTMAP_BLOCK_SIZE)
     .safe_then([this,  _right, prefer_left] (auto &&replacement_pair){
@@ -127,6 +130,7 @@ ExtMapInnerNode::split_entry_ret
 ExtMapInnerNode::split_entry(ext_context_t ec, objaddr_t lo,
                             internal_iterator_t iter, ExtMapNodeRef entry)
 {
+  logger().debug("{}: {}", "ExtMapInnerNode", __func__);
   if (!is_pending()) {
     auto mut = ec.tm.get_mutable_extent(ec.t, this)->cast<ExtMapInnerNode>();
     auto mut_iter = mut->iter_idx(iter->get_offset());
@@ -296,6 +300,7 @@ ExtMapLeafNode::rm_lextent(ext_context_t ec, objaddr_t lo, lext_map_val_t val)
 ExtMapLeafNode::split_children_ret
 ExtMapLeafNode::make_split_children(ext_context_t ec)
 {
+  logger().debug("{}: {}", "ExtMapLeafNode", __func__);
   return extmap_alloc_2extents<ExtMapLeafNode>(ec, EXTMAP_BLOCK_SIZE)
     .safe_then([this] (auto &&ext_pair) {
       auto [left, right] = ext_pair;
@@ -308,6 +313,7 @@ ExtMapLeafNode::make_split_children(ext_context_t ec)
 ExtMapLeafNode::full_merge_ret
 ExtMapLeafNode::make_full_merge(ext_context_t ec, ExtMapNodeRef right)
 {
+  logger().debug("{}: {}", "ExtMapLeafNode", __func__);
   return extmap_alloc_extent<ExtMapLeafNode>(ec, EXTMAP_BLOCK_SIZE)
     .safe_then([this, right] (auto &&replacement) {
       replacement->merge_from(*this, *right->cast<ExtMapLeafNode>());
@@ -319,6 +325,7 @@ ExtMapLeafNode::make_full_merge(ext_context_t ec, ExtMapNodeRef right)
 ExtMapLeafNode::make_balanced_ret
 ExtMapLeafNode::make_balanced(ext_context_t ec, ExtMapNodeRef _right, bool prefer_left)
 {
+  logger().debug("{}: {}", "ExtMapLeafNode", __func__);
   ceph_assert(_right->get_type() == type);
   return extmap_alloc_2extents<ExtMapLeafNode>(ec, EXTMAP_BLOCK_SIZE)
     .safe_then([this, _right, prefer_left] (auto &&replacement_pair) {
index bdee91bbe766718edc366484d9fb314b46024b6b..ca299e28a211421bd7d2e819d2e28cd2b1d58c87 100644 (file)
@@ -107,6 +107,18 @@ struct extentmap_manager_test_t :
     check_mappings(extmap_root, *t);
   }
 
+  void replay() {
+    logger().debug("{}: begin", __func__);
+    tm->close().unsafe_get();
+    destroy();
+    static_cast<segment_manager::EphemeralSegmentManager*>(&*segment_manager)->remount();
+    init();
+    tm->mount().unsafe_get();
+    extmap_manager = extentmap_manager::create_extentmap_manager(*tm);
+    logger().debug("{}: end", __func__);
+  }
+
+
 };
 
 TEST_F(extentmap_manager_test_t, basic)
@@ -145,7 +157,7 @@ TEST_F(extentmap_manager_test_t, basic)
   });
 }
 
-TEST_F(extentmap_manager_test_t, force_split)
+TEST_F(extentmap_manager_test_t, force_leafnode_split)
 {
   run_async([this] {
     extmap_root_t extmap_root(0, L_ADDR_NULL);
@@ -174,7 +186,7 @@ TEST_F(extentmap_manager_test_t, force_split)
 
 }
 
-TEST_F(extentmap_manager_test_t, force_split_merge)
+TEST_F(extentmap_manager_test_t, force_leafnode_split_merge)
 {
   run_async([this] {
     extmap_root_t extmap_root(0, L_ADDR_NULL);
@@ -191,41 +203,43 @@ TEST_F(extentmap_manager_test_t, force_split_merge)
       for (unsigned j = 0; j < 5; ++j) {
         [[maybe_unused]] auto addref = insert_extent(extmap_root, *t, lo, {lo, len});
         lo += len;
-       if ((i % 10 == 0) && (j == 3)) {
-         check_mappings(extmap_root, *t);
-       }
+        if ((i % 10 == 0) && (j == 3)) {
+          check_mappings(extmap_root, *t);
+        }
       }
       logger().debug("submitting transaction");
       tm->submit_transaction(std::move(t)).unsafe_get();
       if (i % 50 == 0) {
-       check_mappings(extmap_root);
+        check_mappings(extmap_root);
       }
     }
     auto t = tm->create_transaction();
     int i = 0;
-    for (const auto& [lo, ext]: test_ext_mappings) {
+    for (auto iter = test_ext_mappings.begin(); iter != test_ext_mappings.end();) {
+      auto [lo, ext] = *iter;
+      ++iter;
       if (i % 3 != 0) {
-       rm_extent(extmap_root, *t, lo, ext);
+        rm_extent(extmap_root, *t, lo, ext);
       }
+      i++;
 
       if (i % 10 == 0) {
         logger().debug("submitting transaction i= {}", i);
-       tm->submit_transaction(std::move(t)).unsafe_get();
-       t = tm->create_transaction();
+        tm->submit_transaction(std::move(t)).unsafe_get();
+        t = tm->create_transaction();
       }
       if (i % 100 == 0) {
         logger().debug("check_mappings  i= {}", i);
-       check_mappings(extmap_root, *t);
-       check_mappings(extmap_root);
+        check_mappings(extmap_root, *t);
+        check_mappings(extmap_root);
       }
-      i++;
     }
     logger().debug("finally submitting transaction ");
     tm->submit_transaction(std::move(t)).unsafe_get();
   });
 }
 
-TEST_F(extentmap_manager_test_t, force_split_balanced)
+TEST_F(extentmap_manager_test_t, force_leafnode_split_merge_replay)
 {
   run_async([this] {
     extmap_root_t extmap_root(0, L_ADDR_NULL);
@@ -233,6 +247,7 @@ TEST_F(extentmap_manager_test_t, force_split_balanced)
       auto t = tm->create_transaction();
       extmap_root = extmap_manager->initialize_extmap(*t).unsafe_get0();
       tm->submit_transaction(std::move(t)).unsafe_get();
+      replay();
     }
     uint32_t len = 4096;
     uint32_t lo = 0;
@@ -242,39 +257,31 @@ TEST_F(extentmap_manager_test_t, force_split_balanced)
       for (unsigned j = 0; j < 5; ++j) {
         [[maybe_unused]] auto addref = insert_extent(extmap_root, *t, lo, {lo, len});
         lo += len;
-        if ((i % 10 == 0) && (j == 3)) {
-          check_mappings(extmap_root, *t);
-        }
       }
       logger().debug("submitting transaction");
       tm->submit_transaction(std::move(t)).unsafe_get();
-      if (i % 50 == 0) {
-        check_mappings(extmap_root);
-      }
     }
+    replay();
     auto t = tm->create_transaction();
     int i = 0;
-    for (const auto& [lo, ext]: test_ext_mappings) {
-      if (i < 100) {
-        rm_extent(extmap_root, *t, lo, ext);
-      }
+    for (auto iter = test_ext_mappings.begin(); iter != test_ext_mappings.end();) {
+      auto [lo, ext] = *iter;
+      ++iter;
+      rm_extent(extmap_root, *t, lo, ext);
+      i++;
 
       if (i % 10 == 0) {
-       logger().debug("submitting transaction i= {}", i);
+        logger().debug("submitting transaction i= {}", i);
         tm->submit_transaction(std::move(t)).unsafe_get();
         t = tm->create_transaction();
       }
-      if (i % 50 == 0) {
-        logger().debug("check_mappings  i= {}", i);
-        check_mappings(extmap_root, *t);
+      if (i% 100 == 0){
         check_mappings(extmap_root);
       }
-      i++;
-      if (i == 100)
-       break;
     }
     logger().debug("finally submitting transaction ");
     tm->submit_transaction(std::move(t)).unsafe_get();
+    replay();
     check_mappings(extmap_root);
   });
 }