]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os: rework the factory of ObjectStore.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 21 Jul 2021 09:27:34 +0000 (09:27 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 21 Jul 2021 13:11:16 +0000 (13:11 +0000)
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 <rzarzyns@redhat.com>
src/os/ObjectStore.cc
src/os/ObjectStore.h

index 83288068199ce75f899fe6b1a4727efff70e7861..75deb19662abc87e6b45e862510f46142f8d40c1 100644 (file)
@@ -33,46 +33,39 @@ using std::string;
 std::unique_ptr<ObjectStore> 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<FileStore>(cct, data, journal, flags);
-  }
   if (type == "memstore") {
     return std::make_unique<MemStore>(cct, data);
   }
 #endif
 #if defined(WITH_BLUESTORE)
-  if (type == "bluestore") {
+  if (type == "bluestore" || type == "random") {
     return std::make_unique<BlueStore>(cct, data);
   }
-#ifndef WITH_SEASTAR
-  if (type == "random") {
-    if (rand() % 2) {
-      return std::make_unique<FileStore>(cct, data, journal, flags);
-    } else {
-      return std::make_unique<BlueStore>(cct, data);
-    }
-  }
 #endif
-#else
+  return nullptr;
+}
+
 #ifndef WITH_SEASTAR
-  if (type == "random") {
+std::unique_ptr<ObjectStore> 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<FileStore>(cct, data, journal, flags);
   }
-#endif
-#endif
-#ifndef WITH_SEASTAR
   if (type == "kstore" &&
       cct->check_experimental_feature_enabled("kstore")) {
     return std::make_unique<KStore>(cct, data);
   }
-#endif
-  return NULL;
+  return create(cct, type, data);
 }
+#endif
 
 int ObjectStore::probe_block_device_fsid(
   CephContext *cct,
index 3b8d33706154edad22bf0f4f57f410454a765ddb..d934d092919a27fb423221e7604b88c8f7a16369 100644 (file)
@@ -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<ObjectStore> create(
     CephContext *cct,
     const std::string& type,
     const std::string& data,
     const std::string& journal,
     osflagbits_t flags = 0);
+#endif
+  static std::unique_ptr<ObjectStore> create(
+    CephContext *cct,
+    const std::string& type,
+    const std::string& data);
 
   /**
    * probe a block device to learn the uuid of the owning OSD