From 6fe9dea75b714b935c4f7d5f2867453c67f2e416 Mon Sep 17 00:00:00 2001 From: Joseph Sawaya Date: Mon, 15 Nov 2021 15:02:23 +0000 Subject: [PATCH] crimson: futurize FuturizedStore::create() This commit changes the FuturizedStore::create() function to return a seastar::future containing its original return value. Signed-off-by: Joseph Sawaya --- src/crimson/os/futurized_store.cc | 10 ++++----- src/crimson/os/futurized_store.h | 2 +- src/crimson/osd/main.cc | 2 +- src/crimson/tools/store_nbd/fs_driver.cc | 28 +++++++++++++++--------- src/crimson/tools/store_nbd/fs_driver.h | 2 +- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/crimson/os/futurized_store.cc b/src/crimson/os/futurized_store.cc index 3d959be0447..864510b631b 100644 --- a/src/crimson/os/futurized_store.cc +++ b/src/crimson/os/futurized_store.cc @@ -10,20 +10,20 @@ namespace crimson::os { -std::unique_ptr +seastar::future> FuturizedStore::create(const std::string& type, const std::string& data, const ConfigValues& values) { if (type == "cyanstore") { - return std::make_unique(data); + return seastar::make_ready_future>(std::make_unique(data)); } else if (type == "seastore") { - return crimson::os::seastore::make_seastore(data, values); + return seastar::make_ready_future>(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( - type, data, values); + return seastar::make_ready_future>(std::make_unique( + type, data, values)); #else ceph_abort_msgf("unsupported objectstore type: %s", type.c_str()); return {}; diff --git a/src/crimson/os/futurized_store.h b/src/crimson/os/futurized_store.h index 02e891254ac..d25c0948450 100644 --- a/src/crimson/os/futurized_store.h +++ b/src/crimson/os/futurized_store.h @@ -51,7 +51,7 @@ public: }; using OmapIteratorRef = boost::intrusive_ptr; - static std::unique_ptr create(const std::string& type, + static seastar::future> create(const std::string& type, const std::string& data, const ConfigValues& values); FuturizedStore() = default; diff --git a/src/crimson/osd/main.cc b/src/crimson/osd/main.cc index 3742e313af7..8df8b4568dc 100644 --- a/src/crimson/osd/main.cc +++ b/src/crimson/osd/main.cc @@ -314,7 +314,7 @@ int main(int argc, char* argv[]) auto store = crimson::os::FuturizedStore::create( local_conf().get_val("osd_objectstore"), local_conf().get_val("osd_data"), - local_conf().get_config_values()); + local_conf().get_config_values()).get(); osd.start_single(whoami, nonce, std::ref(*store), diff --git a/src/crimson/tools/store_nbd/fs_driver.cc b/src/crimson/tools/store_nbd/fs_driver.cc index c2834dcc6e5..ee0d4f6a05f 100644 --- a/src/crimson/tools/store_nbd/fs_driver.cc +++ b/src/crimson/tools/store_nbd/fs_driver.cc @@ -179,10 +179,12 @@ seastar::future 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(); + }); } diff --git a/src/crimson/tools/store_nbd/fs_driver.h b/src/crimson/tools/store_nbd/fs_driver.h index 800dff47944..87af3dd129b 100644 --- a/src/crimson/tools/store_nbd/fs_driver.h +++ b/src/crimson/tools/store_nbd/fs_driver.h @@ -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 &, -- 2.39.5