mirror of
https://github.com/ceph/ceph
synced 2024-12-22 03:22:00 +00:00
crimson/seastore: add replay test for extent map tree
Signed-off-by: chunmei-liu <chunmei.liu@intel.com>
This commit is contained in:
parent
2f1e889348
commit
b684961be2
@ -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) {
|
||||
|
@ -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);
|
||||
@ -186,57 +198,6 @@ TEST_F(extentmap_manager_test_t, force_split_merge)
|
||||
uint32_t len = 4096;
|
||||
uint32_t lo = 0;
|
||||
for (unsigned i = 0; i < 80; i++) {
|
||||
auto t = tm->create_transaction();
|
||||
logger().debug("opened split_merge transaction");
|
||||
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);
|
||||
}
|
||||
}
|
||||
auto t = tm->create_transaction();
|
||||
int i = 0;
|
||||
for (const auto& [lo, ext]: test_ext_mappings) {
|
||||
if (i % 3 != 0) {
|
||||
rm_extent(extmap_root, *t, lo, ext);
|
||||
}
|
||||
|
||||
if (i % 10 == 0) {
|
||||
logger().debug("submitting transaction i= {}", i);
|
||||
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);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
logger().debug("finally submitting transaction ");
|
||||
tm->submit_transaction(std::move(t)).unsafe_get();
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(extentmap_manager_test_t, force_split_balanced)
|
||||
{
|
||||
run_async([this] {
|
||||
extmap_root_t extmap_root(0, L_ADDR_NULL);
|
||||
{
|
||||
auto t = tm->create_transaction();
|
||||
extmap_root = extmap_manager->initialize_extmap(*t).unsafe_get0();
|
||||
tm->submit_transaction(std::move(t)).unsafe_get();
|
||||
}
|
||||
uint32_t len = 4096;
|
||||
uint32_t lo = 0;
|
||||
for (unsigned i = 0; i < 50; i++) {
|
||||
auto t = tm->create_transaction();
|
||||
logger().debug("opened split_merge transaction");
|
||||
for (unsigned j = 0; j < 5; ++j) {
|
||||
@ -254,27 +215,73 @@ TEST_F(extentmap_manager_test_t, force_split_balanced)
|
||||
}
|
||||
auto t = tm->create_transaction();
|
||||
int i = 0;
|
||||
for (const auto& [lo, ext]: test_ext_mappings) {
|
||||
if (i < 100) {
|
||||
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);
|
||||
}
|
||||
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) {
|
||||
if (i % 100 == 0) {
|
||||
logger().debug("check_mappings i= {}", i);
|
||||
check_mappings(extmap_root, *t);
|
||||
check_mappings(extmap_root);
|
||||
}
|
||||
i++;
|
||||
if (i == 100)
|
||||
break;
|
||||
}
|
||||
logger().debug("finally submitting transaction ");
|
||||
tm->submit_transaction(std::move(t)).unsafe_get();
|
||||
});
|
||||
}
|
||||
|
||||
TEST_F(extentmap_manager_test_t, force_leafnode_split_merge_replay)
|
||||
{
|
||||
run_async([this] {
|
||||
extmap_root_t extmap_root(0, L_ADDR_NULL);
|
||||
{
|
||||
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;
|
||||
for (unsigned i = 0; i < 50; i++) {
|
||||
auto t = tm->create_transaction();
|
||||
logger().debug("opened split_merge transaction");
|
||||
for (unsigned j = 0; j < 5; ++j) {
|
||||
[[maybe_unused]] auto addref = insert_extent(extmap_root, *t, lo, {lo, len});
|
||||
lo += len;
|
||||
}
|
||||
logger().debug("submitting transaction");
|
||||
tm->submit_transaction(std::move(t)).unsafe_get();
|
||||
}
|
||||
replay();
|
||||
auto t = tm->create_transaction();
|
||||
int i = 0;
|
||||
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);
|
||||
tm->submit_transaction(std::move(t)).unsafe_get();
|
||||
t = tm->create_transaction();
|
||||
}
|
||||
if (i% 100 == 0){
|
||||
check_mappings(extmap_root);
|
||||
}
|
||||
}
|
||||
logger().debug("finally submitting transaction ");
|
||||
tm->submit_transaction(std::move(t)).unsafe_get();
|
||||
replay();
|
||||
check_mappings(extmap_root);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user