]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson: futurize FuturizedStore::create()
authorJoseph Sawaya <jsawaya@redhat.com>
Mon, 15 Nov 2021 15:02:23 +0000 (15:02 +0000)
committerJoseph Sawaya <jsawaya@redhat.com>
Mon, 15 Nov 2021 15:17:13 +0000 (15:17 +0000)
This commit changes the FuturizedStore::create() function to return a
seastar::future containing its original return value.

Signed-off-by: Joseph Sawaya <jsawaya@redhat.com>
src/crimson/os/futurized_store.cc
src/crimson/os/futurized_store.h
src/crimson/osd/main.cc
src/crimson/tools/store_nbd/fs_driver.cc
src/crimson/tools/store_nbd/fs_driver.h

index 3d959be044726fc8d120e408962dada6054a01a4..864510b631b943f93ece571a506888cac364dde2 100644 (file)
 
 namespace crimson::os {
 
-std::unique_ptr<FuturizedStore>
+seastar::future<std::unique_ptr<FuturizedStore>>
 FuturizedStore::create(const std::string& type,
                        const std::string& data,
                        const ConfigValues& values)
 {
   if (type == "cyanstore") {
-    return std::make_unique<crimson::os::CyanStore>(data);
+    return seastar::make_ready_future<std::unique_ptr<FuturizedStore>>(std::make_unique<crimson::os::CyanStore>(data));
   } else if (type == "seastore") {
-    return crimson::os::seastore::make_seastore(data, values);
+    return seastar::make_ready_future<std::unique_ptr<FuturizedStore>>(crimson::os::seastore::make_seastore(data, values));
   } else {
 #ifdef WITH_BLUESTORE
     // use AlienStore as a fallback. It adapts e.g. BlueStore.
-    return std::make_unique<crimson::os::AlienStore>(
-      type, data, values);
+    return seastar::make_ready_future<std::unique_ptr<FuturizedStore>>(std::make_unique<crimson::os::AlienStore>(
+      type, data, values));
 #else
     ceph_abort_msgf("unsupported objectstore type: %s", type.c_str());
     return {};
index 02e891254ac03964d1a82ba3b85e1a1e41296e57..d25c09484508a010f0cc264d41b820fed543b0b4 100644 (file)
@@ -51,7 +51,7 @@ public:
   };
   using OmapIteratorRef = boost::intrusive_ptr<OmapIterator>;
 
-  static std::unique_ptr<FuturizedStore> create(const std::string& type,
+  static seastar::future<std::unique_ptr<FuturizedStore>> create(const std::string& type,
                                                 const std::string& data,
                                                 const ConfigValues& values);
   FuturizedStore() = default;
index 3742e313af7cf8e4ab8ef38b55520c237837263f..8df8b4568dcc3df641d01b2dc8630f817f3da332 100644 (file)
@@ -314,7 +314,7 @@ int main(int argc, char* argv[])
           auto store = crimson::os::FuturizedStore::create(
             local_conf().get_val<std::string>("osd_objectstore"),
             local_conf().get_val<std::string>("osd_data"),
-            local_conf().get_config_values());
+            local_conf().get_config_values()).get();
 
           osd.start_single(whoami, nonce,
                            std::ref(*store),
index c2834dcc6e52b16d714e04154f7b95da0bc1d9e1..ee0d4f6a05f8454565e2cf5c9765ba750faf168a 100644 (file)
@@ -179,10 +179,12 @@ seastar::future<bufferlist> FSDriver::read(
 
 seastar::future<> FSDriver::mkfs()
 {
-  init();
-  assert(fs);
-  return fs->start(
+  return init(    
   ).then([this] {
+    assert(fs);
+  }).then([this] {
+    return fs->start();
+  }).then([this] {
     uuid_d uuid;
     uuid.generate_random();
     return fs->mkfs(uuid).handle_error(
@@ -196,8 +198,9 @@ seastar::future<> FSDriver::mkfs()
   }).then([this] {
     return fs->stop();
   }).then([this] {
-    init();
-    return fs->start();
+    return init().then([this] {
+      return fs->start();
+    });
   }).then([this] {
     return fs->mount(
     ).handle_error(
@@ -239,8 +242,9 @@ seastar::future<> FSDriver::mount()
   return (
     config.mkfs ? mkfs() : seastar::now()
   ).then([this] {
-    init();
-    return fs->start();
+    return init().then([this] {
+      return fs->start();
+    });
   }).then([this] {
     return fs->mount(
     ).handle_error(
@@ -299,11 +303,15 @@ seastar::future<> FSDriver::close()
   });
 }
 
-void FSDriver::init()
+seastar::future<> FSDriver::init()
 {
   fs.reset();
-  fs = FuturizedStore::create(
+  return FuturizedStore::create(
     config.get_fs_type(),
     *config.path,
-    crimson::common::local_conf().get_config_values());
+    crimson::common::local_conf().get_config_values()
+  ).then([this] (auto store_ptr) {
+      fs = std::move(store_ptr);
+      return seastar::now();
+  });
 }
index 800dff47944f96d002771764c7a212c3aa31b50f..87af3dd129b5063139b4201201231f5e60063c18 100644 (file)
@@ -55,7 +55,7 @@ private:
   offset_mapping_t map_offset(off_t offset);
 
   seastar::future<> mkfs();
-  void init();
+  seastar::future<> init();
 
   friend void populate_log(
     ceph::os::Transaction &,