|
14 | 14 | #include "crimson/os/seastore/segment_manager.h" |
15 | 15 |
|
16 | 16 | #include "test/crimson/seastore/test_block.h" |
| 17 | +#include "crimson/os/seastore/lba_manager/btree/lba_btree_node.h" |
17 | 18 |
|
18 | 19 | using namespace crimson; |
19 | 20 | using namespace crimson::os; |
@@ -2173,6 +2174,42 @@ TEST_P(tm_single_device_intergrity_check_test_t, remap_lazy_read) |
2173 | 2174 | }); |
2174 | 2175 | } |
2175 | 2176 |
|
| 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 | + |
2176 | 2213 | TEST_P(tm_single_device_test_t, random_writes_concurrent) |
2177 | 2214 | { |
2178 | 2215 | test_random_writes_concurrent(); |
|
0 commit comments