From: Radoslaw Zarzynski Date: Fri, 18 Nov 2022 19:15:27 +0000 (+0000) Subject: crimson/osd, osd: share SnapMapper with crimson X-Git-Tag: v18.1.0~260^2~34 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8c01fa651ed40a1fe2ba84d044b372fc6b9ab71c;p=ceph.git crimson/osd, osd: share SnapMapper with crimson Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/osd/SnapMapper.cc b/src/osd/SnapMapper.cc index 45cc3a3c71af..802a5a7bc306 100644 --- a/src/osd/SnapMapper.cc +++ b/src/osd/SnapMapper.cc @@ -17,6 +17,7 @@ #include #include +#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 &keys, + std::map *out) +{ + return -ENOENT; +} + +int OSDriver::get_next( + const std::string &key, + std::pair *next) +{ + return -ENOENT; +} + +int OSDriver::get_next_or_current( + const std::string &key, + std::pair *next_or_current) +{ + return -ENOENT; +} +#else int OSDriver::get_keys( const std::set &keys, std::map *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 * * __ @@ -833,7 +858,6 @@ std::string SnapMapper::convert_legacy_key( + "_" + object_suffix; } -#ifndef WITH_SEASTAR int SnapMapper::convert_legacy( CephContext *cct, ObjectStore *store, diff --git a/src/osd/SnapMapper.h b/src/osd/SnapMapper.h index 0c22b6e13c4a..95c9a6bb8fe5 100644 --- a/src/osd/SnapMapper.h +++ b/src/osd/SnapMapper.h @@ -22,6 +22,10 @@ #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" @@ -30,8 +34,16 @@ #include "osd/SnapMapReaderI.h" class OSDriver : public MapCacher::StoreDriver { - 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) {}