Skip to content

Commit a9ff4f5

Browse files
committed
test/crimson/seastore/test_omap_manager: faster check mappings
Signed-off-by: Chanyoung Park <[email protected]>
1 parent d16a12b commit a9ff4f5

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/test/crimson/seastore/test_omap_manager.cc

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,38 @@ struct omap_manager_test_t :
331331
EXPECT_EQ(omap_root.get_location(), L_ADDR_NULL);
332332
}
333333

334-
void check_mappings(omap_root_t &omap_root, Transaction &t) {
334+
bool check_mappings_fastpath(omap_root_t &omap_root, Transaction &t) {
335+
auto config = OMapManager::omap_list_config_t()
336+
.without_max()
337+
.with_inclusive(true, true);
338+
339+
std::optional<std::string> null_key = std::nullopt;
340+
auto [complete, omap_list] = with_trans_intr(t, [&, this](auto &t) {
341+
return omap_manager->omap_list(
342+
omap_root, t, null_key, null_key, config); /* from start to end */
343+
}).unsafe_get();
344+
345+
if (omap_list.size() != test_omap_mappings.size()) { return false; }
346+
return std::equal(test_omap_mappings.begin(),
347+
test_omap_mappings.end(),
348+
omap_list.begin(),
349+
[](const auto &a, const auto &b) {
350+
return a.first == b.first && a.second == b.second;
351+
});
352+
}
353+
354+
void check_mappings_slowpath(omap_root_t &omap_root, Transaction &t) {
335355
for (const auto &i: test_omap_mappings){
336356
get_value(omap_root, t, i.first);
337357
}
338358
}
339359

360+
void check_mappings(omap_root_t &omap_root, Transaction &t) {
361+
if (!check_mappings_fastpath(omap_root, t)) {
362+
check_mappings_slowpath(omap_root, t);
363+
}
364+
}
365+
340366
void check_mappings(omap_root_t &omap_root) {
341367
auto t = create_read_transaction();
342368
check_mappings(omap_root, *t);

0 commit comments

Comments
 (0)