]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd, test: drop the pre-octopus keys conversion of SnapMapper
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 26 Nov 2024 20:01:05 +0000 (20:01 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 4 Apr 2025 18:21:54 +0000 (18:21 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/osd/OSD.cc
src/osd/SnapMapper.cc
src/osd/SnapMapper.h
src/test/test_snap_mapper.cc

index 406ad4dd02dccc838dec3a14eff5e9db2665c25f..8e3057460e0a450641b117097ff6ce35b85b20fc 100644 (file)
@@ -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
index 53abac1128865332d40a95da20115ce395a312bb..a429c0cd2cb68b4e600b19ed63c9301706702b05 100644 (file)
@@ -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<uint64_t>(snap));
-}
-
-string SnapMapper::to_legacy_raw_key(
-  const pair<snapid_t, hobject_t> &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
- *
- *  <LEGACY_MAPPING_PREFIX><snapid>_<shardid>_<hobject_t::to_str()>
- *
- * to
- *
- *  <MAPPING_PREFIX><pool>_<snapid>_<shardid>_<hobject_t::to_str()>
- *
- * 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 <snapid>.
- *
- * Note that the original version of this conversion introduced in 94ebe0ea
- * had a crucial bug which essentially destroyed legacy keys by mapping
- * them to
- *
- *  <MAPPING_PREFIX><poolid>_<snapid>_
- *
- * 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<string,ceph::buffer::list> 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
index 136d8a679026faaede528aca9c1c075fbc4796d2..455192abf1aabf71094c932be1d82f9b85dcf622 100644 (file)
@@ -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<std::string, ceph::buffer::list> backend;
 
-  static std::string get_legacy_prefix(snapid_t snap);
-  std::string to_legacy_raw_key(
-    const std::pair<snapid_t, hobject_t> &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<snapid_t, hobject_t> &to_map) const;
index 7a9ac62defe68cc0313bb7d632809930b154c71a..4f9214f1b532f028cfe1b548b9a70523376c3f23 100644 (file)
@@ -536,11 +536,6 @@ public:
     return mapper->to_raw(to_map);
   }
 
-  std::string to_legacy_raw_key(
-    const std::pair<snapid_t, hobject_t> &to_map) {
-    return mapper->to_legacy_raw_key(to_map);
-  }
-
   template <typename... Args>
   std::string to_object_key(Args&&... args) {
     return mapper->to_object_key(std::forward<Args>(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<snapid_t, hobject_t> &to_map) {
-    return mapper->to_legacy_raw_key(to_map);
-  }
-
   std::string to_raw_key(
     const std::pair<snapid_t, hobject_t> &to_map) {
     return mapper->to_raw_key(to_map);