From: Sun Yuechi Date: Sat, 27 Jun 2026 07:23:51 +0000 (+0800) Subject: test/osd: cover clear_omap tombstoning of cached keys X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cd8532314ca38f2c925d1a7395481fcaa434c72a;p=ceph.git test/osd: cover clear_omap tombstoning of cached keys Add a regression test that processes an insert so the keys are cached in key_map, then processes a later clear_omap and asserts the cached keys are returned as tombstones. This would have caught the by-value bind in process_entries, where clear_omap mutated copies and left already-cached keys untouched. Signed-off-by: Sun Yuechi --- diff --git a/src/test/osd/test_ec_omap_journal.cc b/src/test/osd/test_ec_omap_journal.cc index 431acae72eb..58cb193c0cf 100644 --- a/src/test/osd/test_ec_omap_journal.cc +++ b/src/test/osd/test_ec_omap_journal.cc @@ -519,6 +519,32 @@ TEST(ecomapjournal, ClearOmap) { EXPECT_TRUE(ranges.at("") == std::nullopt); } +TEST(ecomapjournal, ClearOmapTombstonesCachedKeys) { + MockDoutPrefixProvider dpp; + ECOmapJournal journal(dpp); + const hobject_t hoid("obj_clear_cached", CEPH_NOSNAP, 1, 0, "nspace"); + + // Process an insert first so the keys land in the cached key_map. + journal.add_entry(hoid, create_insert_entry(eversion_t(1, 1), 1, 3)); + { + auto [updates, ranges] = journal.get_value_updates(hoid); + ASSERT_TRUE(updates.at(make_key(1)).value.has_value()); + ASSERT_TRUE(updates.at(make_key(2)).value.has_value()); + ASSERT_TRUE(updates.at(make_key(3)).value.has_value()); + } + + // A later clear_omap must mark the already-cached keys as tombstones. + journal.add_entry(hoid, ECOmapJournalEntry(eversion_t(1, 2), true, std::nullopt, {})); + + auto [updates, ranges] = journal.get_value_updates(hoid); + ASSERT_TRUE(updates.contains(make_key(1))); + ASSERT_TRUE(updates.contains(make_key(2))); + ASSERT_TRUE(updates.contains(make_key(3))); + EXPECT_FALSE(updates.at(make_key(1)).value.has_value()); + EXPECT_FALSE(updates.at(make_key(2)).value.has_value()); + EXPECT_FALSE(updates.at(make_key(3)).value.has_value()); +} + TEST(ecomapjournal, append_delete_clears_maps) { MockDoutPrefixProvider dpp;