Skip to content

Commit 4ad6f86

Browse files
committed
test/crimson/seastore/test_transaction_manager: add a UT case for
detecting invalid lba mappings Signed-off-by: Xuehan Xu <[email protected]>
1 parent 063e429 commit 4ad6f86

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/test/crimson/seastore/test_transaction_manager.cc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "crimson/os/seastore/segment_manager.h"
1515

1616
#include "test/crimson/seastore/test_block.h"
17+
#include "crimson/os/seastore/lba_manager/btree/lba_btree_node.h"
1718

1819
using namespace crimson;
1920
using namespace crimson::os;
@@ -2173,6 +2174,42 @@ TEST_P(tm_single_device_intergrity_check_test_t, remap_lazy_read)
21732174
});
21742175
}
21752176

2177+
TEST_P(tm_single_device_test_t, invalid_lba_mapping_detect)
2178+
{
2179+
run_async([this] {
2180+
using namespace crimson::os::seastore::lba_manager::btree;
2181+
{
2182+
auto t = create_transaction();
2183+
for (int i = 0; i < LEAF_NODE_CAPACITY; i++) {
2184+
auto extent = alloc_extent(
2185+
t,
2186+
i * 4096,
2187+
4096,
2188+
'a');
2189+
}
2190+
submit_transaction(std::move(t));
2191+
}
2192+
2193+
{
2194+
auto t = create_transaction();
2195+
auto pin = get_pin(t, (LEAF_NODE_CAPACITY - 1) * 4096);
2196+
assert(pin->is_parent_valid());
2197+
auto extent = alloc_extent(t, LEAF_NODE_CAPACITY * 4096, 4096, 'a');
2198+
assert(!pin->is_parent_valid());
2199+
pin = get_pin(t, LEAF_NODE_CAPACITY * 4096);
2200+
std::ignore = alloc_extent(t, (LEAF_NODE_CAPACITY + 1) * 4096, 4096, 'a');
2201+
assert(pin->is_parent_valid());
2202+
assert(pin->parent_modified());
2203+
pin->maybe_fix_pos();
2204+
auto v = pin->get_logical_extent(*t.t);
2205+
assert(v.has_child());
2206+
auto extent2 = v.get_child_fut().unsafe_get0();
2207+
assert(extent.get() == extent2.get());
2208+
submit_transaction(std::move(t));
2209+
}
2210+
});
2211+
}
2212+
21762213
TEST_P(tm_single_device_test_t, random_writes_concurrent)
21772214
{
21782215
test_random_writes_concurrent();

0 commit comments

Comments
 (0)