From e5f7ff249d82100479b09a0333837c405ee72db9 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 21 Sep 2021 23:01:06 +0000 Subject: [PATCH] crimson/osd, crimson/os: errorate the FuturizedStore::mkfs() paths. Signed-off-by: Radoslaw Zarzynski --- src/crimson/os/alienstore/alien_store.cc | 12 ++++++++---- src/crimson/os/alienstore/alien_store.h | 2 +- src/crimson/os/cyanstore/cyan_store.cc | 19 +++++++++++-------- src/crimson/os/cyanstore/cyan_store.h | 2 +- src/crimson/os/futurized_store.h | 3 ++- src/crimson/os/seastore/seastore.cc | 2 +- src/crimson/os/seastore/seastore.h | 2 +- src/crimson/osd/osd.cc | 8 +++++++- .../onode_tree/test_fltree_onode_manager.cc | 4 ++-- .../seastore/transaction_manager_test_state.h | 6 +++--- 10 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index c9dd14501d8a4..870f6aa422e5a 100644 --- a/src/crimson/os/alienstore/alien_store.cc +++ b/src/crimson/os/alienstore/alien_store.cc @@ -150,16 +150,20 @@ seastar::future<> AlienStore::umount() }); } -seastar::future<> AlienStore::mkfs(uuid_d osd_fsid) +AlienStore::mkfs_ertr::future<> AlienStore::mkfs(uuid_d osd_fsid) { logger().debug("{}", __func__); store->set_fsid(osd_fsid); assert(tp); return tp->submit([this] { return store->mkfs(); - }).then([] (int r) { - assert(r == 0); - return seastar::now(); + }).then([] (int r) -> mkfs_ertr::future<> { + if (r != 0) { + return crimson::stateful_ec{ + std::error_code(-r, std::generic_category()) }; + } else { + return mkfs_ertr::now(); + } }); } diff --git a/src/crimson/os/alienstore/alien_store.h b/src/crimson/os/alienstore/alien_store.h index 5f96d0658e399..b0ab87e254e68 100644 --- a/src/crimson/os/alienstore/alien_store.h +++ b/src/crimson/os/alienstore/alien_store.h @@ -49,7 +49,7 @@ public: seastar::future<> mount() final; seastar::future<> umount() final; - seastar::future<> mkfs(uuid_d new_osd_fsid) final; + mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) final; read_errorator::future read(CollectionRef c, const ghobject_t& oid, uint64_t offset, diff --git a/src/crimson/os/cyanstore/cyan_store.cc b/src/crimson/os/cyanstore/cyan_store.cc index fdf24d9060791..0f5efc1f7e7e9 100644 --- a/src/crimson/os/cyanstore/cyan_store.cc +++ b/src/crimson/os/cyanstore/cyan_store.cc @@ -101,9 +101,9 @@ private: }; }; -seastar::future<> CyanStore::mkfs(uuid_d new_osd_fsid) +CyanStore::mkfs_ertr::future<> CyanStore::mkfs(uuid_d new_osd_fsid) { - return read_meta("fsid").then([=](auto&& ret) { + return read_meta("fsid").then([=](auto&& ret) -> mkfs_ertr::future<> { auto& [r, fsid_str] = ret; if (r == -ENOENT) { if (new_osd_fsid.is_zero()) { @@ -113,25 +113,28 @@ seastar::future<> CyanStore::mkfs(uuid_d new_osd_fsid) } return write_meta("fsid", fmt::format("{}", osd_fsid)); } else if (r < 0) { - throw std::runtime_error("read_meta"); + static const char msg[]{"read_meta"}; + return crimson::stateful_ec{ singleton_ec() }; } else { logger().info("mkfs already has fsid {}", fsid_str); if (!osd_fsid.parse(fsid_str.c_str())) { - throw std::runtime_error("failed to parse fsid"); + static const char msg[]{"failed to parse fsid"}; + return crimson::stateful_ec{ singleton_ec() }; } else if (osd_fsid != new_osd_fsid) { logger().error("on-disk fsid {} != provided {}", osd_fsid, new_osd_fsid); - throw std::runtime_error("unmatched osd_fsid"); + static const char msg[]{"unmatched osd_fsid"}; + return crimson::stateful_ec{ singleton_ec() }; } else { - return seastar::now(); + return mkfs_ertr::now(); } } - }).then([this]{ + }).safe_then([this]{ std::string fn = path + "/collections"; ceph::bufferlist bl; std::set collections; ceph::encode(collections, bl); return crimson::write_file(std::move(bl), fn); - }).then([this] { + }).safe_then([this] { return write_meta("type", "memstore"); }); } diff --git a/src/crimson/os/cyanstore/cyan_store.h b/src/crimson/os/cyanstore/cyan_store.h index 8c182d0dd8afe..d4881202c600b 100644 --- a/src/crimson/os/cyanstore/cyan_store.h +++ b/src/crimson/os/cyanstore/cyan_store.h @@ -71,7 +71,7 @@ public: seastar::future<> mount() final; seastar::future<> umount() final; - seastar::future<> mkfs(uuid_d new_osd_fsid) final; + mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) final; seastar::future stat() const final; seastar::future stat( CollectionRef c, diff --git a/src/crimson/os/futurized_store.h b/src/crimson/os/futurized_store.h index 435b11067f4da..b4dced9dc87cd 100644 --- a/src/crimson/os/futurized_store.h +++ b/src/crimson/os/futurized_store.h @@ -68,7 +68,8 @@ public: virtual seastar::future<> mount() = 0; virtual seastar::future<> umount() = 0; - virtual seastar::future<> mkfs(uuid_d new_osd_fsid) = 0; + using mkfs_ertr = crimson::errorator; + virtual mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) = 0; virtual seastar::future stat() const = 0; using CollectionRef = boost::intrusive_ptr; diff --git a/src/crimson/os/seastore/seastore.cc b/src/crimson/os/seastore/seastore.cc index 1b3f166c0ed56..b15b5138e31ee 100644 --- a/src/crimson/os/seastore/seastore.cc +++ b/src/crimson/os/seastore/seastore.cc @@ -108,7 +108,7 @@ seastar::future<> SeaStore::umount() ); } -seastar::future<> SeaStore::mkfs(uuid_d new_osd_fsid) +SeaStore::mkfs_ertr::future<> SeaStore::mkfs(uuid_d new_osd_fsid) { return segment_manager->mkfs( seastore_meta_t{new_osd_fsid} diff --git a/src/crimson/os/seastore/seastore.h b/src/crimson/os/seastore/seastore.h index 471328c8a3a21..d9eacf418986e 100644 --- a/src/crimson/os/seastore/seastore.h +++ b/src/crimson/os/seastore/seastore.h @@ -52,7 +52,7 @@ public: seastar::future<> mount() final; seastar::future<> umount() final; - seastar::future<> mkfs(uuid_d new_osd_fsid) final; + mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) final; seastar::future stat() const final; read_errorator::future read( diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 7f82fa26205e2..ea5c46bf1f407 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -152,7 +152,13 @@ CompatSet get_osd_initial_compat_set() seastar::future<> OSD::mkfs(uuid_d osd_uuid, uuid_d cluster_fsid) { return store.start().then([this, osd_uuid] { - return store.mkfs(osd_uuid); + return store.mkfs(osd_uuid).handle_error( + crimson::stateful_ec::handle([] (const auto& ec) { + logger().error("error creating empty object store in {}: ({}) {}", + local_conf().get_val("osd_data"), + ec.value(), ec.message()); + std::exit(EXIT_FAILURE); + })); }).then([this] { return store.mount(); }).then([cluster_fsid, this] { diff --git a/src/test/crimson/seastore/onode_tree/test_fltree_onode_manager.cc b/src/test/crimson/seastore/onode_tree/test_fltree_onode_manager.cc index b52a79e29a787..baf5bb29bb15a 100644 --- a/src/test/crimson/seastore/onode_tree/test_fltree_onode_manager.cc +++ b/src/test/crimson/seastore/onode_tree/test_fltree_onode_manager.cc @@ -79,9 +79,9 @@ struct fltree_onode_manager_test_t TMTestState::_destroy(); } - virtual seastar::future<> _mkfs() final { + virtual FuturizedStore::mkfs_ertr::future<> _mkfs() final { return TMTestState::_mkfs( - ).then([this] { + ).safe_then([this] { return tm->mount( ).safe_then([this] { return repeat_eagain([this] { diff --git a/src/test/crimson/seastore/transaction_manager_test_state.h b/src/test/crimson/seastore/transaction_manager_test_state.h index 04c7a11c87e55..56aaac2ad9dfb 100644 --- a/src/test/crimson/seastore/transaction_manager_test_state.h +++ b/src/test/crimson/seastore/transaction_manager_test_state.h @@ -36,7 +36,7 @@ protected: } virtual seastar::future<> _teardown() = 0; - virtual seastar::future<> _mkfs() = 0; + virtual FuturizedStore::mkfs_ertr::future<> _mkfs() = 0; virtual seastar::future<> _mount() = 0; void restart() { @@ -153,7 +153,7 @@ protected: }); } - virtual seastar::future<> _mkfs() { + virtual FuturizedStore::mkfs_ertr::future<> _mkfs() { return tm->mkfs( ).handle_error( crimson::ct_error::assert_all{"Error in teardown"} @@ -253,7 +253,7 @@ protected: return seastore->mount(); } - virtual seastar::future<> _mkfs() { + virtual FuturizedStore::mkfs_ertr::future<> _mkfs() { return seastore->mkfs(uuid_d{}); } }; -- 2.39.5