From 007133a6acd1394d5b285dfdc7410547a5ed99d0 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Wed, 21 Jul 2021 09:27:34 +0000 Subject: [PATCH] os: rework the factory of ObjectStore. The goals here are: 1. make deprecation of `FileStore` easier as creational dependencies are segmented into a variant of `create()` that could be cut off altogether with `FileStore`. 2. Allow crimson adapt `create()` without burdening it with `FileStore`'s dependencies. 3. Simplify the implementation as a bunch of preprocessor directives accumulated there over the time. Signed-off-by: Radoslaw Zarzynski --- src/os/ObjectStore.cc | 37 +++++++++++++++---------------------- src/os/ObjectStore.h | 6 ++++++ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/os/ObjectStore.cc b/src/os/ObjectStore.cc index 83288068199ce..75deb19662abc 100644 --- a/src/os/ObjectStore.cc +++ b/src/os/ObjectStore.cc @@ -33,46 +33,39 @@ using std::string; std::unique_ptr ObjectStore::create( CephContext *cct, const string& type, - const string& data, - const string& journal, - osflagbits_t flags) + const string& data) { #ifndef WITH_SEASTAR - if (type == "filestore") { - return std::make_unique(cct, data, journal, flags); - } if (type == "memstore") { return std::make_unique(cct, data); } #endif #if defined(WITH_BLUESTORE) - if (type == "bluestore") { + if (type == "bluestore" || type == "random") { return std::make_unique(cct, data); } -#ifndef WITH_SEASTAR - if (type == "random") { - if (rand() % 2) { - return std::make_unique(cct, data, journal, flags); - } else { - return std::make_unique(cct, data); - } - } #endif -#else + return nullptr; +} + #ifndef WITH_SEASTAR - if (type == "random") { +std::unique_ptr ObjectStore::create( + CephContext *cct, + const string& type, + const string& data, + const string& journal, + osflagbits_t flags) +{ + if (type == "filestore" || (type == "random" && rand() % 2)) { return std::make_unique(cct, data, journal, flags); } -#endif -#endif -#ifndef WITH_SEASTAR if (type == "kstore" && cct->check_experimental_feature_enabled("kstore")) { return std::make_unique(cct, data); } -#endif - return NULL; + return create(cct, type, data); } +#endif int ObjectStore::probe_block_device_fsid( CephContext *cct, diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 3b8d33706154e..d934d092919a2 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -78,12 +78,18 @@ public: * @param journal path (or other descriptor) for journal (optional) * @param flags which filestores should check if applicable */ +#ifndef WITH_SEASTAR static std::unique_ptr create( CephContext *cct, const std::string& type, const std::string& data, const std::string& journal, osflagbits_t flags = 0); +#endif + static std::unique_ptr create( + CephContext *cct, + const std::string& type, + const std::string& data); /** * probe a block device to learn the uuid of the owning OSD -- 2.39.5