Skip to content

Commit b6bdebe

Browse files
committed
test/crimson/seastore/test_transaction_manager: take RootMetaBlock into
account Signed-off-by: Xuehan Xu <[email protected]>
1 parent 8911b29 commit b6bdebe

File tree

2 files changed

+58
-52
lines changed

2 files changed

+58
-52
lines changed

src/crimson/os/seastore/random_block_manager/block_rb_manager.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ BlockRBManager::write_ertr::future<> BlockRBManager::write(
188188
void BlockRBManager::prefill_fragmented_device()
189189
{
190190
LOG_PREFIX(BlockRBManager::prefill_fragmented_device);
191-
// the first 2 blocks must be allocated to lba root
191+
// the first 3 blocks must be allocated to lba root
192192
// and backref root during mkfs
193-
for (size_t block = get_block_size() * 2;
194-
block <= get_size() - get_block_size() * 2;
193+
for (size_t block = get_block_size() * 3;
194+
block <= get_size() - get_block_size() * 3;
195195
block += get_block_size() * 2) {
196196
DEBUG("marking {}~{} used",
197197
get_start_rbm_addr() + block,

src/test/crimson/seastore/test_transaction_manager.cc

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ namespace {
2626
}
2727
}
2828

29+
laddr_t get_laddr_hint(uint64_t offset) {
30+
return laddr_t::from_byte_offset(RootMetaBlock::SIZE + offset);
31+
}
32+
2933
struct test_extent_record_t {
3034
test_extent_desc_t desc;
3135
unsigned refcount = 0;
@@ -67,8 +71,9 @@ struct transaction_manager_test_t :
6771
}
6872

6973
laddr_t get_random_laddr(size_t block_size, size_t limit) {
70-
return laddr_t::from_byte_offset(block_size *
71-
std::uniform_int_distribution<>(0, (limit / block_size) - 1)(gen));
74+
auto offset = block_size *
75+
std::uniform_int_distribution<>(0, (limit / block_size) - 1)(gen);
76+
return get_laddr_hint(offset);
7277
}
7378

7479
char get_random_contents() {
@@ -719,7 +724,7 @@ struct transaction_manager_test_t :
719724
[this, &overlay](auto &t) {
720725
return lba_manager->scan_mappings(
721726
t,
722-
L_ADDR_MIN,
727+
get_laddr_hint(0),
723728
L_ADDR_MAX,
724729
[iter=overlay.begin(), &overlay](auto l, auto p, auto len) mutable {
725730
EXPECT_NE(iter, overlay.end());
@@ -830,9 +835,9 @@ struct transaction_manager_test_t :
830835
auto t = create_transaction();
831836
auto extent = alloc_extent(
832837
t,
833-
laddr_t::from_byte_offset(i * BSIZE),
838+
get_laddr_hint(i * BSIZE),
834839
BSIZE);
835-
ASSERT_EQ(laddr_t::from_byte_offset(i * BSIZE), extent->get_laddr());
840+
ASSERT_EQ(get_laddr_hint(i * BSIZE), extent->get_laddr());
836841
submit_transaction(std::move(t));
837842
}
838843

@@ -844,7 +849,7 @@ struct transaction_manager_test_t :
844849
boost::make_counting_iterator(0lu),
845850
boost::make_counting_iterator(BLOCKS),
846851
[this, &t](auto i) {
847-
return tm->read_extent<TestBlock>(t, laddr_t::from_byte_offset(i * BSIZE), BSIZE
852+
return tm->read_extent<TestBlock>(t, get_laddr_hint(i * BSIZE), BSIZE
848853
).si_then([](auto) {
849854
return seastar::now();
850855
});
@@ -870,9 +875,9 @@ struct transaction_manager_test_t :
870875
auto t = create_transaction();
871876
auto extent = alloc_extent(
872877
t,
873-
laddr_t::from_byte_offset(i * BSIZE),
878+
get_laddr_hint(i * BSIZE),
874879
BSIZE);
875-
ASSERT_EQ(laddr_t::from_byte_offset(i * BSIZE), extent->get_laddr());
880+
ASSERT_EQ(get_laddr_hint(i * BSIZE), extent->get_laddr());
876881
if (try_submit_transaction(std::move(t)))
877882
break;
878883
}
@@ -973,6 +978,7 @@ struct transaction_manager_test_t :
973978
extent_types_t::ROOT,
974979
extent_types_t::LADDR_INTERNAL,
975980
extent_types_t::LADDR_LEAF,
981+
extent_types_t::ROOT_META,
976982
extent_types_t::OMAP_INNER,
977983
extent_types_t::OMAP_LEAF,
978984
extent_types_t::ONODE_BLOCK_STAGED,
@@ -1346,9 +1352,9 @@ struct transaction_manager_test_t :
13461352
void test_remap_pin() {
13471353
run_async([this] {
13481354
disable_max_extent_size();
1349-
laddr_t l_offset = laddr_t::from_byte_offset(32 << 10);
1355+
laddr_t l_offset = get_laddr_hint(32 << 10);
13501356
size_t l_len = 32 << 10;
1351-
laddr_t r_offset = laddr_t::from_byte_offset(64 << 10);
1357+
laddr_t r_offset = get_laddr_hint(64 << 10);
13521358
size_t r_len = 32 << 10;
13531359
{
13541360
auto t = create_transaction();
@@ -1400,12 +1406,12 @@ struct transaction_manager_test_t :
14001406
void test_clone_and_remap_pin() {
14011407
run_async([this] {
14021408
disable_max_extent_size();
1403-
laddr_t l_offset = laddr_t::from_byte_offset(32 << 10);
1409+
laddr_t l_offset = get_laddr_hint(32 << 10);
14041410
size_t l_len = 32 << 10;
1405-
laddr_t r_offset = laddr_t::from_byte_offset(64 << 10);
1411+
laddr_t r_offset = get_laddr_hint(64 << 10);
14061412
size_t r_len = 32 << 10;
1407-
laddr_t l_clone_offset = laddr_t::from_byte_offset(96 << 10);
1408-
laddr_t r_clone_offset = laddr_t::from_byte_offset(128 << 10);
1413+
laddr_t l_clone_offset = get_laddr_hint(96 << 10);
1414+
laddr_t r_clone_offset = get_laddr_hint(128 << 10);
14091415
{
14101416
auto t = create_transaction();
14111417
auto lext = alloc_extent(t, l_offset, l_len);
@@ -1455,11 +1461,11 @@ struct transaction_manager_test_t :
14551461
void test_overwrite_pin() {
14561462
run_async([this] {
14571463
disable_max_extent_size();
1458-
laddr_t m_offset = laddr_t::from_byte_offset(8 << 10);
1464+
laddr_t m_offset = get_laddr_hint(8 << 10);
14591465
size_t m_len = 56 << 10;
1460-
laddr_t l_offset = laddr_t::from_byte_offset(64 << 10);
1466+
laddr_t l_offset = get_laddr_hint(64 << 10);
14611467
size_t l_len = 64 << 10;
1462-
laddr_t r_offset = laddr_t::from_byte_offset(128 << 10);
1468+
laddr_t r_offset = get_laddr_hint(128 << 10);
14631469
size_t r_len = 64 << 10;
14641470
{
14651471
auto t = create_transaction();
@@ -1538,7 +1544,7 @@ struct transaction_manager_test_t :
15381544
run_async([this] {
15391545
disable_max_extent_size();
15401546
constexpr unsigned REMAP_NUM = 32;
1541-
constexpr laddr_t offset = L_ADDR_MIN;
1547+
laddr_t offset = get_laddr_hint(0);
15421548
constexpr size_t length = 256 << 10;
15431549
{
15441550
auto t = create_transaction();
@@ -1575,7 +1581,7 @@ struct transaction_manager_test_t :
15751581
if (off == 0 || off >= 255) {
15761582
continue;
15771583
}
1578-
auto new_off = laddr_t::from_byte_offset(off << 10)
1584+
auto new_off = get_laddr_hint(off << 10)
15791585
.get_byte_distance<extent_len_t>(last_pin->get_key());
15801586
auto new_len = last_pin->get_length() - new_off;
15811587
//always remap right extent at new split_point
@@ -1621,7 +1627,7 @@ struct transaction_manager_test_t :
16211627
run_async([this] {
16221628
disable_max_extent_size();
16231629
constexpr unsigned REMAP_NUM = 32;
1624-
constexpr laddr_t offset = L_ADDR_MIN;
1630+
laddr_t offset = get_laddr_hint(0);
16251631
constexpr size_t length = 256 << 10;
16261632
{
16271633
auto t = create_transaction();
@@ -1661,12 +1667,12 @@ struct transaction_manager_test_t :
16611667
ASSERT_TRUE(!split_points.empty());
16621668
while(!split_points.empty()) {
16631669
// new overwrite area: start_off ~ end_off
1664-
auto start_off = split_points.front();
1670+
auto start_off = split_points.front() + 4 /*RootMetaBlock*/;
16651671
split_points.pop_front();
1666-
auto end_off = split_points.front();
1672+
auto end_off = split_points.front() + 4 /*RootMetaBlock*/;
16671673
split_points.pop_front();
16681674
ASSERT_TRUE(start_off <= end_off);
1669-
if ((laddr_t::from_byte_offset(end_off << 10) == pin0->get_key() + pin0->get_length())
1675+
if ((get_laddr_hint(end_off << 10) == pin0->get_key() + pin0->get_length())
16701676
|| (start_off == end_off)) {
16711677
if (split_points.empty() && empty_transaction) {
16721678
early_exit++;
@@ -1675,7 +1681,7 @@ struct transaction_manager_test_t :
16751681
continue;
16761682
}
16771683
empty_transaction = false;
1678-
auto new_off = laddr_t::from_byte_offset(start_off << 10)
1684+
auto new_off = get_laddr_hint(start_off << 10)
16791685
.get_byte_distance<extent_len_t>(last_rpin->get_key());
16801686
auto new_len = (end_off - start_off) << 10;
16811687
bufferlist bl;
@@ -1768,7 +1774,7 @@ struct tm_random_block_device_test_t :
17681774
TEST_P(tm_random_block_device_test_t, scatter_allocation)
17691775
{
17701776
run_async([this] {
1771-
laddr_t ADDR = laddr_t::from_byte_offset(0xFF * 4096);
1777+
laddr_t ADDR = get_laddr_hint(0xFF * 4096);
17721778
epm->prefill_fragmented_devices();
17731779
auto t = create_transaction();
17741780
for (int i = 0; i < 1991; i++) {
@@ -1786,7 +1792,7 @@ TEST_P(tm_single_device_test_t, basic)
17861792
{
17871793
constexpr size_t SIZE = 4096;
17881794
run_async([this] {
1789-
laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE);
1795+
laddr_t ADDR = get_laddr_hint(0xFF * SIZE);
17901796
{
17911797
auto t = create_transaction();
17921798
auto extent = alloc_extent(
@@ -1807,7 +1813,7 @@ TEST_P(tm_single_device_test_t, mutate)
18071813
{
18081814
constexpr size_t SIZE = 4096;
18091815
run_async([this] {
1810-
laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE);
1816+
laddr_t ADDR = get_laddr_hint(0xFF * SIZE);
18111817
{
18121818
auto t = create_transaction();
18131819
auto extent = alloc_extent(
@@ -1845,8 +1851,8 @@ TEST_P(tm_single_device_test_t, allocate_lba_conflict)
18451851
{
18461852
constexpr size_t SIZE = 4096;
18471853
run_async([this] {
1848-
laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE);
1849-
laddr_t ADDR2 = laddr_t::from_byte_offset(0xFE * SIZE);
1854+
laddr_t ADDR = get_laddr_hint(0xFF * SIZE);
1855+
laddr_t ADDR2 = get_laddr_hint(0xFE * SIZE);
18501856
auto t = create_transaction();
18511857
auto t2 = create_transaction();
18521858

@@ -1883,15 +1889,15 @@ TEST_P(tm_single_device_test_t, mutate_lba_conflict)
18831889
for (unsigned i = 0; i < 300; ++i) {
18841890
auto extent = alloc_extent(
18851891
t,
1886-
laddr_t::from_byte_offset(i * SIZE),
1892+
get_laddr_hint(i * SIZE),
18871893
SIZE);
18881894
}
18891895
check_mappings(t);
18901896
submit_transaction(std::move(t));
18911897
check();
18921898
}
18931899

1894-
laddr_t ADDR = laddr_t::from_byte_offset(150 * SIZE);
1900+
laddr_t ADDR = get_laddr_hint(150 * SIZE);
18951901
{
18961902
auto t = create_transaction();
18971903
auto t2 = create_transaction();
@@ -1917,15 +1923,15 @@ TEST_P(tm_single_device_test_t, concurrent_mutate_lba_no_conflict)
19171923
{
19181924
constexpr size_t SIZE = 4096;
19191925
constexpr size_t NUM = 500;
1920-
laddr_t addr = L_ADDR_MIN;
1921-
laddr_t addr2 = laddr_t::from_byte_offset(SIZE * (NUM - 1));
1926+
laddr_t addr = get_laddr_hint(0);
1927+
laddr_t addr2 = get_laddr_hint(SIZE * (NUM - 1));
19221928
run_async([this, addr, addr2] {
19231929
{
19241930
auto t = create_transaction();
19251931
for (unsigned i = 0; i < NUM; ++i) {
19261932
auto extent = alloc_extent(
19271933
t,
1928-
laddr_t::from_byte_offset(i * SIZE),
1934+
get_laddr_hint(i * SIZE),
19291935
SIZE);
19301936
}
19311937
submit_transaction(std::move(t));
@@ -1949,7 +1955,7 @@ TEST_P(tm_single_device_test_t, create_remove_same_transaction)
19491955
{
19501956
constexpr size_t SIZE = 4096;
19511957
run_async([this] {
1952-
laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE);
1958+
laddr_t ADDR = get_laddr_hint(0xFF * SIZE);
19531959
{
19541960
auto t = create_transaction();
19551961
auto extent = alloc_extent(
@@ -1985,7 +1991,7 @@ TEST_P(tm_single_device_test_t, split_merge_read_same_transaction)
19851991
for (unsigned i = 0; i < 300; ++i) {
19861992
auto extent = alloc_extent(
19871993
t,
1988-
laddr_t::from_byte_offset(i * SIZE),
1994+
get_laddr_hint(i * SIZE),
19891995
SIZE);
19901996
}
19911997
check_mappings(t);
@@ -1997,7 +2003,7 @@ TEST_P(tm_single_device_test_t, split_merge_read_same_transaction)
19972003
for (unsigned i = 0; i < 240; ++i) {
19982004
dec_ref(
19992005
t,
2000-
laddr_t::from_byte_offset(i * SIZE));
2006+
get_laddr_hint(i * SIZE));
20012007
}
20022008
check_mappings(t);
20032009
submit_transaction(std::move(t));
@@ -2010,7 +2016,7 @@ TEST_P(tm_single_device_test_t, inc_dec_ref)
20102016
{
20112017
constexpr size_t SIZE = 4096;
20122018
run_async([this] {
2013-
laddr_t ADDR = laddr_t::from_byte_offset(0xFF * SIZE);
2019+
laddr_t ADDR = get_laddr_hint(0xFF * SIZE);
20142020
{
20152021
auto t = create_transaction();
20162022
auto extent = alloc_extent(
@@ -2061,10 +2067,10 @@ TEST_P(tm_single_device_test_t, cause_lba_split)
20612067
auto t = create_transaction();
20622068
auto extent = alloc_extent(
20632069
t,
2064-
laddr_t::from_byte_offset(i * SIZE),
2070+
get_laddr_hint(i * SIZE),
20652071
SIZE,
20662072
(char)(i & 0xFF));
2067-
ASSERT_EQ(laddr_t::from_byte_offset(i * SIZE), extent->get_laddr());
2073+
ASSERT_EQ(get_laddr_hint(i * SIZE), extent->get_laddr());
20682074
submit_transaction(std::move(t));
20692075
}
20702076
check();
@@ -2082,9 +2088,9 @@ TEST_P(tm_single_device_test_t, random_writes)
20822088
auto t = create_transaction();
20832089
auto extent = alloc_extent(
20842090
t,
2085-
laddr_t::from_byte_offset(i * BSIZE),
2091+
get_laddr_hint(i * BSIZE),
20862092
BSIZE);
2087-
ASSERT_EQ(laddr_t::from_byte_offset(i * BSIZE), extent->get_laddr());
2093+
ASSERT_EQ(get_laddr_hint(i * BSIZE), extent->get_laddr());
20882094
submit_transaction(std::move(t));
20892095
}
20902096

@@ -2100,7 +2106,7 @@ TEST_P(tm_single_device_test_t, random_writes)
21002106
// pad out transaction
21012107
auto paddings = alloc_extents(
21022108
t,
2103-
laddr_t::from_byte_offset(TOTAL + (k * PADDING_SIZE)),
2109+
get_laddr_hint(TOTAL + (k * PADDING_SIZE)),
21042110
PADDING_SIZE);
21052111
for (auto &padding : paddings) {
21062112
dec_ref(t, padding->get_laddr());
@@ -2133,7 +2139,7 @@ TEST_P(tm_single_device_test_t, find_hole_assert_trigger)
21332139

21342140
TEST_P(tm_single_device_intergrity_check_test_t, remap_lazy_read)
21352141
{
2136-
constexpr laddr_t offset = L_ADDR_MIN;
2142+
laddr_t offset = get_laddr_hint(0);
21372143
constexpr size_t length = 256 << 10;
21382144
run_async([this, offset] {
21392145
disable_max_extent_size();
@@ -2186,7 +2192,7 @@ TEST_P(tm_single_device_test_t, invalid_lba_mapping_detect)
21862192
for (int i = 0; i < LEAF_NODE_CAPACITY; i++) {
21872193
auto extent = alloc_extent(
21882194
t,
2189-
laddr_t::from_byte_offset(i * 4096),
2195+
get_laddr_hint(i * 4096),
21902196
4096,
21912197
'a');
21922198
}
@@ -2195,12 +2201,12 @@ TEST_P(tm_single_device_test_t, invalid_lba_mapping_detect)
21952201

21962202
{
21972203
auto t = create_transaction();
2198-
auto pin = get_pin(t, laddr_t::from_byte_offset((LEAF_NODE_CAPACITY - 1) * 4096));
2204+
auto pin = get_pin(t, get_laddr_hint((LEAF_NODE_CAPACITY - 1) * 4096));
21992205
assert(pin->is_parent_viewable());
2200-
auto extent = alloc_extent(t, laddr_t::from_byte_offset(LEAF_NODE_CAPACITY * 4096), 4096, 'a');
2206+
auto extent = alloc_extent(t, get_laddr_hint(LEAF_NODE_CAPACITY * 4096), 4096, 'a');
22012207
assert(!pin->is_parent_viewable());
2202-
pin = get_pin(t, laddr_t::from_byte_offset(LEAF_NODE_CAPACITY * 4096));
2203-
std::ignore = alloc_extent(t, laddr_t::from_byte_offset((LEAF_NODE_CAPACITY + 1) * 4096), 4096, 'a');
2208+
pin = get_pin(t, get_laddr_hint(LEAF_NODE_CAPACITY * 4096));
2209+
std::ignore = alloc_extent(t, get_laddr_hint((LEAF_NODE_CAPACITY + 1) * 4096), 4096, 'a');
22042210
assert(pin->is_parent_viewable());
22052211
assert(pin->parent_modified());
22062212
pin->maybe_fix_pos();

0 commit comments

Comments
 (0)