]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd, osd: share SnapMapper with crimson
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 18 Nov 2022 19:15:27 +0000 (19:15 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 28 Feb 2023 16:22:04 +0000 (16:22 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/osd/SnapMapper.cc
src/osd/SnapMapper.h

index 45cc3a3c71af18d67bd7eadb624c8cea2eb7a0fb..802a5a7bc30668cbd74dac2523cc14e98adbb230 100644 (file)
@@ -17,6 +17,7 @@
 #include <fmt/printf.h>
 #include <fmt/ranges.h>
 
+#include "global/global_context.h"
 #include "osd/osd_types_fmt.h"
 #include "SnapMapReaderI.h"
 
@@ -78,6 +79,28 @@ const char *SnapMapper::PURGED_SNAP_PREFIX = "PSN_";
 
   */
 
+#ifdef WITH_SEASTAR
+int OSDriver::get_keys(
+  const std::set<std::string> &keys,
+  std::map<std::string, ceph::buffer::list> *out)
+{
+  return -ENOENT;
+}
+
+int OSDriver::get_next(
+  const std::string &key,
+  std::pair<std::string, ceph::buffer::list> *next)
+{
+  return -ENOENT;
+}
+
+int OSDriver::get_next_or_current(
+  const std::string &key,
+  std::pair<std::string, ceph::buffer::list> *next_or_current)
+{
+  return -ENOENT;
+}
+#else
 int OSDriver::get_keys(
   const std::set<std::string> &keys,
   std::map<std::string, ceph::buffer::list> *out)
@@ -124,6 +147,7 @@ int OSDriver::get_next_or_current(
     return -ENOENT;
   }
 }
+#endif // WITH_SEASTAR
 
 string SnapMapper::get_prefix(int64_t pool, snapid_t snap)
 {
@@ -801,6 +825,7 @@ bool SnapMapper::is_legacy_mapping(const string &to_test)
     LEGACY_MAPPING_PREFIX;
 }
 
+#ifndef WITH_SEASTAR
 /* Octopus modified the SnapMapper key format from
  *
  *  <LEGACY_MAPPING_PREFIX><snapid>_<shardid>_<hobject_t::to_str()>
@@ -833,7 +858,6 @@ std::string SnapMapper::convert_legacy_key(
     + "_" + object_suffix;
 }
 
-#ifndef WITH_SEASTAR
 int SnapMapper::convert_legacy(
   CephContext *cct,
   ObjectStore *store,
index 0c22b6e13c4a6852ff33cc83f3c5bb1a1eaf65f7..95c9a6bb8fe591e0ee589f99ea963902af5daeda 100644 (file)
 
 #include "common/hobject.h"
 #include "common/map_cacher.hpp"
+#ifdef WITH_SEASTAR
+#  include "crimson/os/futurized_store.h"
+#  include "crimson/os/futurized_collection.h"
+#endif
 #include "include/buffer.h"
 #include "include/encoding.h"
 #include "include/object.h"
 #include "osd/SnapMapReaderI.h"
 
 class OSDriver : public MapCacher::StoreDriver<std::string, ceph::buffer::list> {
-  ObjectStore *os;
-  ObjectStore::CollectionHandle ch;
+#ifdef WITH_SEASTAR
+  using ObjectStoreT = crimson::os::FuturizedStore;
+  using CollectionHandleT = ObjectStoreT::CollectionRef;
+#else
+  using ObjectStoreT = ObjectStore;
+  using CollectionHandleT = ObjectStoreT::CollectionHandle;
+#endif
+
+  ObjectStoreT *os;
+  CollectionHandleT ch;
   ghobject_t hoid;
 
 public:
@@ -39,11 +51,11 @@ public:
     friend class OSDriver;
     coll_t cid;
     ghobject_t hoid;
-    ObjectStore::Transaction *t;
+    ceph::os::Transaction *t;
     OSTransaction(
       const coll_t &cid,
       const ghobject_t &hoid,
-      ObjectStore::Transaction *t)
+      ceph::os::Transaction *t)
       : cid(cid), hoid(hoid), t(t) {}
   public:
     void set_keys(
@@ -61,13 +73,15 @@ public:
   };
 
   OSTransaction get_transaction(
-    ObjectStore::Transaction *t) const {
-    return OSTransaction(ch->cid, hoid, t);
+    ceph::os::Transaction *t) const {
+    return OSTransaction(ch->get_cid(), hoid, t);
   }
 
-  OSDriver(ObjectStore *os, const coll_t& cid, const ghobject_t &hoid) :
+#ifndef WITH_SEASTAR
+  OSDriver(ObjectStoreT *os, const coll_t& cid, const ghobject_t &hoid) :
     OSDriver(os, os->open_collection(cid), hoid) {}
-  OSDriver(ObjectStore *os, ObjectStore::CollectionHandle ch, const ghobject_t &hoid) :
+#endif
+  OSDriver(ObjectStoreT *os, CollectionHandleT ch, const ghobject_t &hoid) :
     os(os),
     ch(ch),
     hoid(hoid) {}