crimson/seastore: add replay test for extent map tree

Signed-off-by: chunmei-liu <chunmei.liu@intel.com>
This commit is contained in:
chunmei-liu 2020-10-27 17:01:37 -07:00
parent 2f1e889348
commit b684961be2
2 changed files with 74 additions and 60 deletions

View 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::split_children_ret
ExtMapInnerNode::make_split_children(ext_context_t ec) ExtMapInnerNode::make_split_children(ext_context_t ec)
{ {
logger().debug("{}: {}", "ExtMapInnerNode", __func__);
return extmap_alloc_2extents<ExtMapInnerNode>(ec, EXTMAP_BLOCK_SIZE) return extmap_alloc_2extents<ExtMapInnerNode>(ec, EXTMAP_BLOCK_SIZE)
.safe_then([this] (auto &&ext_pair) { .safe_then([this] (auto &&ext_pair) {
auto [left, right] = ext_pair; auto [left, right] = ext_pair;
@ -98,6 +99,7 @@ ExtMapInnerNode::make_split_children(ext_context_t ec)
ExtMapInnerNode::full_merge_ret ExtMapInnerNode::full_merge_ret
ExtMapInnerNode::make_full_merge(ext_context_t ec, ExtMapNodeRef right) ExtMapInnerNode::make_full_merge(ext_context_t ec, ExtMapNodeRef right)
{ {
logger().debug("{}: {}", "ExtMapInnerNode", __func__);
return extmap_alloc_extent<ExtMapInnerNode>(ec, EXTMAP_BLOCK_SIZE) return extmap_alloc_extent<ExtMapInnerNode>(ec, EXTMAP_BLOCK_SIZE)
.safe_then([this, right] (auto &&replacement) { .safe_then([this, right] (auto &&replacement) {
replacement->merge_from(*this, *right->cast<ExtMapInnerNode>()); 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_ret
ExtMapInnerNode::make_balanced(ext_context_t ec, ExtMapNodeRef _right, bool prefer_left) ExtMapInnerNode::make_balanced(ext_context_t ec, ExtMapNodeRef _right, bool prefer_left)
{ {
logger().debug("{}: {}", "ExtMapInnerNode", __func__);
ceph_assert(_right->get_type() == type); ceph_assert(_right->get_type() == type);
return extmap_alloc_2extents<ExtMapInnerNode>(ec, EXTMAP_BLOCK_SIZE) return extmap_alloc_2extents<ExtMapInnerNode>(ec, EXTMAP_BLOCK_SIZE)
.safe_then([this, _right, prefer_left] (auto &&replacement_pair){ .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, ExtMapInnerNode::split_entry(ext_context_t ec, objaddr_t lo,
internal_iterator_t iter, ExtMapNodeRef entry) internal_iterator_t iter, ExtMapNodeRef entry)
{ {
logger().debug("{}: {}", "ExtMapInnerNode", __func__);
if (!is_pending()) { if (!is_pending()) {
auto mut = ec.tm.get_mutable_extent(ec.t, this)->cast<ExtMapInnerNode>(); auto mut = ec.tm.get_mutable_extent(ec.t, this)->cast<ExtMapInnerNode>();
auto mut_iter = mut->iter_idx(iter->get_offset()); 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::split_children_ret
ExtMapLeafNode::make_split_children(ext_context_t ec) ExtMapLeafNode::make_split_children(ext_context_t ec)
{ {
logger().debug("{}: {}", "ExtMapLeafNode", __func__);
return extmap_alloc_2extents<ExtMapLeafNode>(ec, EXTMAP_BLOCK_SIZE) return extmap_alloc_2extents<ExtMapLeafNode>(ec, EXTMAP_BLOCK_SIZE)
.safe_then([this] (auto &&ext_pair) { .safe_then([this] (auto &&ext_pair) {
auto [left, right] = ext_pair; auto [left, right] = ext_pair;
@ -308,6 +313,7 @@ ExtMapLeafNode::make_split_children(ext_context_t ec)
ExtMapLeafNode::full_merge_ret ExtMapLeafNode::full_merge_ret
ExtMapLeafNode::make_full_merge(ext_context_t ec, ExtMapNodeRef right) ExtMapLeafNode::make_full_merge(ext_context_t ec, ExtMapNodeRef right)
{ {
logger().debug("{}: {}", "ExtMapLeafNode", __func__);
return extmap_alloc_extent<ExtMapLeafNode>(ec, EXTMAP_BLOCK_SIZE) return extmap_alloc_extent<ExtMapLeafNode>(ec, EXTMAP_BLOCK_SIZE)
.safe_then([this, right] (auto &&replacement) { .safe_then([this, right] (auto &&replacement) {
replacement->merge_from(*this, *right->cast<ExtMapLeafNode>()); 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_ret
ExtMapLeafNode::make_balanced(ext_context_t ec, ExtMapNodeRef _right, bool prefer_left) ExtMapLeafNode::make_balanced(ext_context_t ec, ExtMapNodeRef _right, bool prefer_left)
{ {
logger().debug("{}: {}", "ExtMapLeafNode", __func__);
ceph_assert(_right->get_type() == type); ceph_assert(_right->get_type() == type);
return extmap_alloc_2extents<ExtMapLeafNode>(ec, EXTMAP_BLOCK_SIZE) return extmap_alloc_2extents<ExtMapLeafNode>(ec, EXTMAP_BLOCK_SIZE)
.safe_then([this, _right, prefer_left] (auto &&replacement_pair) { .safe_then([this, _right, prefer_left] (auto &&replacement_pair) {

View File

@ -107,6 +107,18 @@ struct extentmap_manager_test_t :
check_mappings(extmap_root, *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) 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] { run_async([this] {
extmap_root_t extmap_root(0, L_ADDR_NULL); 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] { run_async([this] {
extmap_root_t extmap_root(0, L_ADDR_NULL); extmap_root_t extmap_root(0, L_ADDR_NULL);
@ -203,10 +215,13 @@ TEST_F(extentmap_manager_test_t, force_split_merge)
} }
auto t = tm->create_transaction(); auto t = tm->create_transaction();
int i = 0; 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) { if (i % 3 != 0) {
rm_extent(extmap_root, *t, lo, ext); rm_extent(extmap_root, *t, lo, ext);
} }
i++;
if (i % 10 == 0) { if (i % 10 == 0) {
logger().debug("submitting transaction i= {}", i); logger().debug("submitting transaction i= {}", i);
@ -218,14 +233,13 @@ TEST_F(extentmap_manager_test_t, force_split_merge)
check_mappings(extmap_root, *t); check_mappings(extmap_root, *t);
check_mappings(extmap_root); check_mappings(extmap_root);
} }
i++;
} }
logger().debug("finally submitting transaction "); logger().debug("finally submitting transaction ");
tm->submit_transaction(std::move(t)).unsafe_get(); 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] { run_async([this] {
extmap_root_t extmap_root(0, L_ADDR_NULL); 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(); auto t = tm->create_transaction();
extmap_root = extmap_manager->initialize_extmap(*t).unsafe_get0(); extmap_root = extmap_manager->initialize_extmap(*t).unsafe_get0();
tm->submit_transaction(std::move(t)).unsafe_get(); tm->submit_transaction(std::move(t)).unsafe_get();
replay();
} }
uint32_t len = 4096; uint32_t len = 4096;
uint32_t lo = 0; uint32_t lo = 0;
@ -242,39 +257,31 @@ TEST_F(extentmap_manager_test_t, force_split_balanced)
for (unsigned j = 0; j < 5; ++j) { for (unsigned j = 0; j < 5; ++j) {
[[maybe_unused]] auto addref = insert_extent(extmap_root, *t, lo, {lo, len}); [[maybe_unused]] auto addref = insert_extent(extmap_root, *t, lo, {lo, len});
lo += len; lo += len;
if ((i % 10 == 0) && (j == 3)) {
check_mappings(extmap_root, *t);
}
} }
logger().debug("submitting transaction"); logger().debug("submitting transaction");
tm->submit_transaction(std::move(t)).unsafe_get(); tm->submit_transaction(std::move(t)).unsafe_get();
if (i % 50 == 0) {
check_mappings(extmap_root);
}
} }
replay();
auto t = tm->create_transaction(); auto t = tm->create_transaction();
int i = 0; int i = 0;
for (const auto& [lo, ext]: test_ext_mappings) { for (auto iter = test_ext_mappings.begin(); iter != test_ext_mappings.end();) {
if (i < 100) { auto [lo, ext] = *iter;
++iter;
rm_extent(extmap_root, *t, lo, ext); rm_extent(extmap_root, *t, lo, ext);
} i++;
if (i % 10 == 0) { if (i % 10 == 0) {
logger().debug("submitting transaction i= {}", i); logger().debug("submitting transaction i= {}", i);
tm->submit_transaction(std::move(t)).unsafe_get(); tm->submit_transaction(std::move(t)).unsafe_get();
t = tm->create_transaction(); t = tm->create_transaction();
} }
if (i % 50 == 0) { if (i% 100 == 0){
logger().debug("check_mappings i= {}", i);
check_mappings(extmap_root, *t);
check_mappings(extmap_root); check_mappings(extmap_root);
} }
i++;
if (i == 100)
break;
} }
logger().debug("finally submitting transaction "); logger().debug("finally submitting transaction ");
tm->submit_transaction(std::move(t)).unsafe_get(); tm->submit_transaction(std::move(t)).unsafe_get();
replay();
check_mappings(extmap_root); check_mappings(extmap_root);
}); });
} }