Skip to content

Commit

Permalink
Merge pull request #53967 from Matan-B/wip-53232-reef
Browse files Browse the repository at this point in the history
reef: test/crimson/seastore/rbm: add sub-tests regarding RBM to the existing tests

Reviewed-by: Samuel Just <sjust@redhat.com>
  • Loading branch information
Matan-B committed Oct 17, 2023
2 parents bb3cff4 + c41cc1e commit 33ddfb3
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 69 deletions.
31 changes: 21 additions & 10 deletions src/crimson/os/seastore/object_data_handler.cc
Expand Up @@ -573,7 +573,8 @@ struct overwrite_plan_t {
overwrite_plan_t(laddr_t offset,
extent_len_t len,
const lba_pin_list_t& pins,
extent_len_t block_size) :
extent_len_t block_size,
Transaction& t) :
pin_begin(pins.front()->get_key()),
pin_end(pins.back()->get_key() + pins.back()->get_length()),
left_paddr(pins.front()->get_val()),
Expand All @@ -586,7 +587,7 @@ struct overwrite_plan_t {
right_operation(overwrite_operation_t::UNKNOWN),
block_size(block_size) {
validate();
evaluate_operations();
evaluate_operations(t);
assert(left_operation != overwrite_operation_t::UNKNOWN);
assert(right_operation != overwrite_operation_t::UNKNOWN);
}
Expand Down Expand Up @@ -614,19 +615,31 @@ struct overwrite_plan_t {
* original extent into at most three parts: origin-left, part-to-be-modified
* and origin-right.
*/
void evaluate_operations() {
void evaluate_operations(Transaction& t) {
auto actual_write_size = get_pins_size();
auto aligned_data_size = get_aligned_data_size();
auto left_ext_size = get_left_extent_size();
auto right_ext_size = get_right_extent_size();

auto can_merge = [](Transaction& t, paddr_t paddr) {
CachedExtentRef ext;
if (paddr.is_relative() || paddr.is_delayed()) {
return true;
} else if (t.get_extent(paddr, &ext) ==
Transaction::get_extent_ret::PRESENT) {
// FIXME: there is no need to lookup the cache if the pin can
// be associated with the extent state
if (ext->is_mutable()) {
return true;
}
}
return false;
};
if (left_paddr.is_zero()) {
actual_write_size -= left_ext_size;
left_ext_size = 0;
left_operation = overwrite_operation_t::OVERWRITE_ZERO;
// FIXME: left_paddr can be absolute and pending
} else if (left_paddr.is_relative() ||
left_paddr.is_delayed()) {
} else if (can_merge(t, left_paddr)) {
aligned_data_size += left_ext_size;
left_ext_size = 0;
left_operation = overwrite_operation_t::MERGE_EXISTING;
Expand All @@ -636,9 +649,7 @@ struct overwrite_plan_t {
actual_write_size -= right_ext_size;
right_ext_size = 0;
right_operation = overwrite_operation_t::OVERWRITE_ZERO;
// FIXME: right_paddr can be absolute and pending
} else if (right_paddr.is_relative() ||
right_paddr.is_delayed()) {
} else if (can_merge(t, right_paddr)) {
aligned_data_size += right_ext_size;
right_ext_size = 0;
right_operation = overwrite_operation_t::MERGE_EXISTING;
Expand Down Expand Up @@ -1108,7 +1119,7 @@ ObjectDataHandler::write_ret ObjectDataHandler::overwrite(
if (bl.has_value()) {
assert(bl->length() == len);
}
overwrite_plan_t overwrite_plan(offset, len, _pins, ctx.tm.get_block_size());
overwrite_plan_t overwrite_plan(offset, len, _pins, ctx.tm.get_block_size(), ctx.t);
return seastar::do_with(
std::move(_pins),
extent_to_write_list_t(),
Expand Down
13 changes: 11 additions & 2 deletions src/test/crimson/seastore/onode_tree/test_fltree_onode_manager.cc
Expand Up @@ -235,7 +235,7 @@ struct fltree_onode_manager_test_t
fltree_onode_manager_test_t() {}
};

TEST_F(fltree_onode_manager_test_t, 1_single)
TEST_P(fltree_onode_manager_test_t, 1_single)
{
run_async([this] {
uint64_t block_size = tm->get_block_size();
Expand Down Expand Up @@ -263,7 +263,7 @@ TEST_F(fltree_onode_manager_test_t, 1_single)
});
}

TEST_F(fltree_onode_manager_test_t, 2_synthetic)
TEST_P(fltree_onode_manager_test_t, 2_synthetic)
{
run_async([this] {
uint64_t block_size = tm->get_block_size();
Expand Down Expand Up @@ -315,3 +315,12 @@ TEST_F(fltree_onode_manager_test_t, 2_synthetic)
validate_list_onodes(pool);
});
}

INSTANTIATE_TEST_SUITE_P(
fltree_onode__manager_test,
fltree_onode_manager_test_t,
::testing::Values (
"segmented",
"circularbounded"
)
);
13 changes: 11 additions & 2 deletions src/test/crimson/seastore/onode_tree/test_staged_fltree.cc
Expand Up @@ -1572,7 +1572,7 @@ struct d_seastore_tm_test_t :
}
};

TEST_F(d_seastore_tm_test_t, 6_random_tree_insert_erase)
TEST_P(d_seastore_tm_test_t, 6_random_tree_insert_erase)
{
run_async([this] {
constexpr bool TEST_SEASTORE = true;
Expand Down Expand Up @@ -1662,7 +1662,7 @@ TEST_F(d_seastore_tm_test_t, 6_random_tree_insert_erase)
});
}

TEST_F(d_seastore_tm_test_t, 7_tree_insert_erase_eagain)
TEST_P(d_seastore_tm_test_t, 7_tree_insert_erase_eagain)
{
run_async([this] {
constexpr double EAGAIN_PROBABILITY = 0.1;
Expand Down Expand Up @@ -1781,3 +1781,12 @@ TEST_F(d_seastore_tm_test_t, 7_tree_insert_erase_eagain)
tree.reset();
});
}

INSTANTIATE_TEST_SUITE_P(
d_seastore_tm_test,
d_seastore_tm_test_t,
::testing::Values (
"segmented",
"circularbounded"
)
);
15 changes: 12 additions & 3 deletions src/test/crimson/seastore/test_collection_manager.cc
Expand Up @@ -100,7 +100,7 @@ struct collection_manager_test_t :
}
};

TEST_F(collection_manager_test_t, basic)
TEST_P(collection_manager_test_t, basic)
{
run_async([this] {
coll_root_t coll_root = get_root();
Expand Down Expand Up @@ -137,7 +137,7 @@ TEST_F(collection_manager_test_t, basic)
});
}

TEST_F(collection_manager_test_t, overflow)
TEST_P(collection_manager_test_t, overflow)
{
run_async([this] {
coll_root_t coll_root = get_root();
Expand All @@ -158,7 +158,7 @@ TEST_F(collection_manager_test_t, overflow)
});
}

TEST_F(collection_manager_test_t, update)
TEST_P(collection_manager_test_t, update)
{
run_async([this] {
coll_root_t coll_root = get_root();
Expand All @@ -184,3 +184,12 @@ TEST_F(collection_manager_test_t, update)
checking_mappings(coll_root);
});
}

INSTANTIATE_TEST_SUITE_P(
collection_manager_test,
collection_manager_test_t,
::testing::Values (
"segmented",
"circularbounded"
)
);
39 changes: 25 additions & 14 deletions src/test/crimson/seastore/test_object_data_handler.cc
Expand Up @@ -160,7 +160,7 @@ struct object_data_handler_test_t:
}
};

TEST_F(object_data_handler_test_t, single_write)
TEST_P(object_data_handler_test_t, single_write)
{
run_async([this] {
write(1<<20, 8<<10, 'c');
Expand All @@ -170,7 +170,7 @@ TEST_F(object_data_handler_test_t, single_write)
});
}

TEST_F(object_data_handler_test_t, multi_write)
TEST_P(object_data_handler_test_t, multi_write)
{
run_async([this] {
write((1<<20) - (4<<10), 4<<10, 'a');
Expand All @@ -185,7 +185,7 @@ TEST_F(object_data_handler_test_t, multi_write)
});
}

TEST_F(object_data_handler_test_t, write_hole)
TEST_P(object_data_handler_test_t, write_hole)
{
run_async([this] {
write((1<<20) - (4<<10), 4<<10, 'a');
Expand All @@ -200,7 +200,7 @@ TEST_F(object_data_handler_test_t, write_hole)
});
}

TEST_F(object_data_handler_test_t, overwrite_single)
TEST_P(object_data_handler_test_t, overwrite_single)
{
run_async([this] {
write((1<<20), 4<<10, 'a');
Expand All @@ -211,7 +211,7 @@ TEST_F(object_data_handler_test_t, overwrite_single)
});
}

TEST_F(object_data_handler_test_t, overwrite_double)
TEST_P(object_data_handler_test_t, overwrite_double)
{
run_async([this] {
write((1<<20), 4<<10, 'a');
Expand All @@ -229,7 +229,7 @@ TEST_F(object_data_handler_test_t, overwrite_double)
});
}

TEST_F(object_data_handler_test_t, overwrite_partial)
TEST_P(object_data_handler_test_t, overwrite_partial)
{
run_async([this] {
write((1<<20), 12<<10, 'a');
Expand All @@ -254,7 +254,7 @@ TEST_F(object_data_handler_test_t, overwrite_partial)
});
}

TEST_F(object_data_handler_test_t, unaligned_write)
TEST_P(object_data_handler_test_t, unaligned_write)
{
run_async([this] {
objaddr_t base = 1<<20;
Expand All @@ -271,7 +271,7 @@ TEST_F(object_data_handler_test_t, unaligned_write)
});
}

TEST_F(object_data_handler_test_t, unaligned_overwrite)
TEST_P(object_data_handler_test_t, unaligned_overwrite)
{
run_async([this] {
objaddr_t base = 1<<20;
Expand All @@ -292,7 +292,7 @@ TEST_F(object_data_handler_test_t, unaligned_overwrite)
});
}

TEST_F(object_data_handler_test_t, truncate)
TEST_P(object_data_handler_test_t, truncate)
{
run_async([this] {
objaddr_t base = 1<<20;
Expand All @@ -314,7 +314,7 @@ TEST_F(object_data_handler_test_t, truncate)
});
}

TEST_F(object_data_handler_test_t, no_split) {
TEST_P(object_data_handler_test_t, no_split) {
run_async([this] {
write(0, 8<<10, 'x');
write(0, 8<<10, 'a');
Expand All @@ -326,7 +326,7 @@ TEST_F(object_data_handler_test_t, no_split) {
});
}

TEST_F(object_data_handler_test_t, split_left) {
TEST_P(object_data_handler_test_t, split_left) {
run_async([this] {
write(0, 128<<10, 'x');

Expand All @@ -346,7 +346,7 @@ TEST_F(object_data_handler_test_t, split_left) {
});
}

TEST_F(object_data_handler_test_t, split_right) {
TEST_P(object_data_handler_test_t, split_right) {
run_async([this] {
write(0, 128<<10, 'x');
write(4<<10, 60<<10, 'a');
Expand All @@ -364,7 +364,7 @@ TEST_F(object_data_handler_test_t, split_right) {
read(0, 128<<10);
});
}
TEST_F(object_data_handler_test_t, split_left_right) {
TEST_P(object_data_handler_test_t, split_left_right) {
run_async([this] {
write(0, 128<<10, 'x');
write(48<<10, 32<<10, 'a');
Expand All @@ -381,7 +381,7 @@ TEST_F(object_data_handler_test_t, split_left_right) {
}
});
}
TEST_F(object_data_handler_test_t, multiple_split) {
TEST_P(object_data_handler_test_t, multiple_split) {
run_async([this] {
write(0, 128<<10, 'x');

Expand Down Expand Up @@ -415,3 +415,14 @@ TEST_F(object_data_handler_test_t, multiple_split) {
read(0, 128<<10);
});
}

INSTANTIATE_TEST_SUITE_P(
object_data_handler_test,
object_data_handler_test_t,
::testing::Values (
"segmented",
"circularbounded"
)
);


0 comments on commit 33ddfb3

Please sign in to comment.