From: Radoslaw Zarzynski Date: Tue, 26 Nov 2024 20:01:05 +0000 (+0000) Subject: osd, test: drop the pre-octopus keys conversion of SnapMapper X-Git-Tag: testing/wip-vshankar-testing-20250411.090237-debug~43^2~15 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9cd66c391d1cf8d19fcc973c68ab8c9d1c0e09f6;p=ceph-ci.git osd, test: drop the pre-octopus keys conversion of SnapMapper Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 406ad4dd02d..8e3057460e0 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -3898,14 +3898,9 @@ int OSD::init() if (superblock.compat_features.merge(initial)) { // Are we adding SNAPMAPPER2? if (diff.incompat.contains(CEPH_OSD_FEATURE_INCOMPAT_SNAPMAPPER2)) { - dout(1) << __func__ << " upgrade snap_mapper (first start as octopus)" - << dendl; - auto ch = service.meta_ch; - auto hoid = make_snapmapper_oid(); - unsigned max = cct->_conf->osd_target_transaction_size; - r = SnapMapper::convert_legacy(cct, store.get(), ch, hoid, max); - if (r < 0) - goto out; + derr << __func__ << " snap_mapper upgrade from pre-octopus" + << " is no longer supported" << dendl; + ceph_abort(); } // We need to persist the new compat_set before we // do anything else diff --git a/src/osd/SnapMapper.cc b/src/osd/SnapMapper.cc index 53abac11288..a429c0cd2cb 100644 --- a/src/osd/SnapMapper.cc +++ b/src/osd/SnapMapper.cc @@ -42,7 +42,6 @@ using result_t = Scrub::SnapMapReaderI::result_t; using code_t = Scrub::SnapMapReaderI::result_t::code_t; -const string SnapMapper::LEGACY_MAPPING_PREFIX = "MAP_"; const string SnapMapper::MAPPING_PREFIX = "SNA_"; const string SnapMapper::OBJECT_PREFIX = "OBJ_"; @@ -56,14 +55,6 @@ const char *SnapMapper::PURGED_SNAP_PREFIX = "PSN_"; can identify which reverse mappings exist for any given object (and, e.g., clean up on deletion). - "MAP_" - + ("%016x" % snapid) - + "_" - + (".%x" % shard_id) - + "_" - + hobject_t::to_str() ("%llx.%8x.%lx.name...." % pool, hash, snap) - -> SnapMapping::Mapping { snap, hoid } - "SNA_" + ("%lld" % poolid) + "_" @@ -1026,120 +1017,3 @@ void SnapMapper::Scrubber::run() mapit = ObjectMap::ObjectMapIterator(); } #endif // !WITH_CRIMSON - - -// ------------------------------------- -// legacy conversion/support - -string SnapMapper::get_legacy_prefix(snapid_t snap) -{ - ceph_assert(snap != CEPH_NOSNAP && snap != CEPH_SNAPDIR); - return fmt::sprintf("%s%.16X_", - LEGACY_MAPPING_PREFIX, - static_cast(snap)); -} - -string SnapMapper::to_legacy_raw_key( - const pair &in) -{ - return get_legacy_prefix(in.first) + shard_prefix + in.second.to_str(); -} - -bool SnapMapper::is_legacy_mapping(const string &to_test) -{ - return to_test.substr(0, LEGACY_MAPPING_PREFIX.size()) == - LEGACY_MAPPING_PREFIX; -} - -#ifndef WITH_CRIMSON -/* Octopus modified the SnapMapper key format from - * - * __ - * - * to - * - * ___ - * - * We can't reconstruct the new key format just from the value since the - * Mapping object contains an hobject rather than a ghobject. Instead, - * we exploit the fact that the new format is identical starting at . - * - * Note that the original version of this conversion introduced in 94ebe0ea - * had a crucial bug which essentially destroyed legacy keys by mapping - * them to - * - * __ - * - * without the object-unique suffix. - * See https://tracker.ceph.com/issues/56147 - */ -std::string SnapMapper::convert_legacy_key( - const std::string& old_key, - const ceph::buffer::list& value) -{ - auto old = from_raw(make_pair(old_key, value)); - std::string object_suffix = old_key.substr( - SnapMapper::LEGACY_MAPPING_PREFIX.length()); - return SnapMapper::MAPPING_PREFIX + std::to_string(old.second.pool) - + "_" + object_suffix; -} - -int SnapMapper::convert_legacy( - CephContext *cct, - ObjectStore *store, - ObjectStore::CollectionHandle& ch, - ghobject_t hoid, - unsigned max) -{ - uint64_t n = 0; - - ObjectMap::ObjectMapIterator iter = store->get_omap_iterator(ch, hoid); - if (!iter) { - return -EIO; - } - - auto start = ceph::mono_clock::now(); - - iter->upper_bound(SnapMapper::LEGACY_MAPPING_PREFIX); - map to_set; - while (iter->valid()) { - bool valid = SnapMapper::is_legacy_mapping(iter->key()); - if (valid) { - to_set.emplace( - convert_legacy_key(iter->key(), iter->value()), - iter->value()); - ++n; - iter->next(); - } - if (!valid || !iter->valid() || to_set.size() >= max) { - ObjectStore::Transaction t; - t.omap_setkeys(ch->cid, hoid, to_set); - int r = store->queue_transaction(ch, std::move(t)); - ceph_assert(r == 0); - to_set.clear(); - if (!valid) { - break; - } - dout(10) << __func__ << " converted " << n << " keys" << dendl; - } - } - - auto end = ceph::mono_clock::now(); - - dout(1) << __func__ << " converted " << n << " keys in " - << timespan_str(end - start) << dendl; - - // remove the old keys - { - ObjectStore::Transaction t; - string end = SnapMapper::LEGACY_MAPPING_PREFIX; - ++end[end.size()-1]; // turn _ to whatever comes after _ - t.omap_rmkeyrange(ch->cid, hoid, - SnapMapper::LEGACY_MAPPING_PREFIX, - end); - int r = store->queue_transaction(ch, std::move(t)); - ceph_assert(r == 0); - } - return 0; -} -#endif // !WITH_CRIMSON diff --git a/src/osd/SnapMapper.h b/src/osd/SnapMapper.h index 136d8a67902..455192abf1a 100644 --- a/src/osd/SnapMapper.h +++ b/src/osd/SnapMapper.h @@ -211,17 +211,6 @@ public: void run(); }; - - static std::string convert_legacy_key( - const std::string& old_key, - const bufferlist& value); - - static int convert_legacy( - CephContext *cct, - ObjectStore *store, - ObjectStore::CollectionHandle& ch, - ghobject_t hoid, - unsigned max); #endif static void record_purged_snaps( @@ -245,11 +234,6 @@ private: // functions. mutable MapCacher::MapCacher backend; - static std::string get_legacy_prefix(snapid_t snap); - std::string to_legacy_raw_key( - const std::pair &to_map); - static bool is_legacy_mapping(const std::string &to_test); - static std::string get_prefix(int64_t pool, snapid_t snap); std::string to_raw_key( const std::pair &to_map) const; diff --git a/src/test/test_snap_mapper.cc b/src/test/test_snap_mapper.cc index 7a9ac62defe..4f9214f1b53 100644 --- a/src/test/test_snap_mapper.cc +++ b/src/test/test_snap_mapper.cc @@ -536,11 +536,6 @@ public: return mapper->to_raw(to_map); } - std::string to_legacy_raw_key( - const std::pair &to_map) { - return mapper->to_legacy_raw_key(to_map); - } - template std::string to_object_key(Args&&... args) { return mapper->to_object_key(std::forward(args)...); @@ -1037,23 +1032,6 @@ TEST_F(SnapMapperTest, CheckMakePurgedSnapKeyFormat) { } } -TEST_F(SnapMapperTest, LegacyKeyConvertion) { - init(1); - auto obj = get_tester().random_hobject(); - snapid_t snapid = random() % 10; - auto snap_obj = make_pair(snapid, obj); - auto raw = get_tester().to_raw(snap_obj); - std::string old_key = get_tester().to_legacy_raw_key(snap_obj); - std::string converted_key = - SnapMapper::convert_legacy_key(old_key, raw.second); - std::string new_key = get_tester().to_raw_key(snap_obj); - if (converted_key != new_key) { - std::cout << "Converted: " << old_key << "\nTo: " << converted_key - << "\nNew key: " << new_key << std::endl; - } - ASSERT_EQ(converted_key, new_key); -} - /** * 'DirectMapper' provides simple, controlled, interface to the underlying * SnapMapper. @@ -1093,11 +1071,6 @@ public: return mapper->to_raw(to_map); } - std::string to_legacy_raw_key( - const std::pair &to_map) { - return mapper->to_legacy_raw_key(to_map); - } - std::string to_raw_key( const std::pair &to_map) { return mapper->to_raw_key(to_map);