Merge pull request #43928 from josephsawaya/futurize-futurized-store

crimson: futurize FuturizedStore::create()

Reviewed-by: Samuel Just <sjust@redhat.com>
This commit is contained in:
Samuel Just 2021-11-15 12:17:33 -08:00 committed by GitHub
commit 16e152e161
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 18 deletions

View File

@ -10,20 +10,20 @@
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 {};

View 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;

View 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),

View 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();
});
}

View 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 &,