Skip to content

Commit

Permalink
test/crimson/seastore/test_object_data_handler: always access object
Browse files Browse the repository at this point in the history
data based on offsets relative to the start of the object data base

Signed-off-by: Xuehan Xu <[email protected]>
  • Loading branch information
xxhdx1985126 committed Nov 11, 2024
1 parent b6bdebe commit 1627e38
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/test/crimson/seastore/test_object_data_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,20 @@ struct object_data_handler_test_t:
objaddr_t offset,
extent_len_t length) {
auto ret = with_trans_intr(t, [&](auto &t) {
return tm->get_pins(t, laddr_t::from_byte_offset(offset), length);
auto &layout = onode->get_layout();
auto odata = layout.object_data.get();
auto obase = odata.get_reserved_data_base();
return tm->get_pins(t, (obase + offset).checked_to_laddr(), length);
}).unsafe_get();
return ret;
}
std::list<LBAMappingRef> get_mappings(objaddr_t offset, extent_len_t length) {
auto t = create_mutate_transaction();
auto ret = with_trans_intr(*t, [&](auto &t) {
return tm->get_pins(t, laddr_t::from_byte_offset(offset), length);
auto &layout = onode->get_layout();
auto odata = layout.object_data.get();
auto obase = odata.get_reserved_data_base();
return tm->get_pins(t, (obase + offset).checked_to_laddr(), length);
}).unsafe_get();
return ret;
}
Expand Down Expand Up @@ -253,12 +259,16 @@ struct object_data_handler_test_t:

ObjectDataBlockRef get_extent(
Transaction &t,
laddr_t addr,
loffset_t addr,
extent_len_t len) {
auto &layout = onode->get_layout();
auto odata = layout.object_data.get();
auto obase = odata.get_reserved_data_base();
auto ext = with_trans_intr(t, [&](auto& trans) {
return tm->read_extent<ObjectDataBlock>(trans, addr, len);
}).unsafe_get();
EXPECT_EQ(addr, ext->get_laddr());
return tm->read_extent<ObjectDataBlock>(
trans, (obase + addr).checked_to_laddr(), len);
}).unsafe_get();
EXPECT_EQ((obase + addr).checked_to_laddr(), ext->get_laddr());
return ext;
}

Expand Down Expand Up @@ -798,7 +808,7 @@ TEST_P(object_data_handler_test_t, overwrite_then_read_within_transaction) {
auto pins = get_mappings(*t, base, len);
assert(pins.size() == 1);
auto pin1 = remap_pin(*t, std::move(pins.front()), 4096, 8192);
auto ext = get_extent(*t, laddr_t::from_byte_offset(base + 4096), 4096 * 2);
auto ext = get_extent(*t, base + 4096, 4096 * 2);
ASSERT_TRUE(ext->is_exist_clean());
write(*t, base + 4096, 4096, 'y');
ASSERT_TRUE(ext->is_exist_mutation_pending());
Expand Down

0 comments on commit 1627e38

Please sign in to comment.