From: Radoslaw Zarzynski Date: Tue, 19 Oct 2021 20:02:57 +0000 (+0000) Subject: crimson: errorate the FuturizedStore::mount() paths. X-Git-Tag: v17.1.0~643^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=677bce0e97c7fafd127039bf8ba3dd3718a5c5fa;p=ceph.git crimson: errorate the FuturizedStore::mount() paths. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index 43ff8d354154e..09df2e6f70450 100644 --- a/src/crimson/os/alienstore/alien_store.cc +++ b/src/crimson/os/alienstore/alien_store.cc @@ -126,15 +126,19 @@ seastar::future<> AlienStore::stop() AlienStore::~AlienStore() = default; -seastar::future<> AlienStore::mount() +AlienStore::mount_ertr::future<> AlienStore::mount() { logger().debug("{}", __func__); assert(tp); return tp->submit([this] { return store->mount(); - }).then([] (int r) { - assert(r == 0); - return seastar::now(); + }).then([] (const int r) -> mount_ertr::future<> { + if (r != 0) { + return crimson::stateful_ec{ + std::error_code(-r, std::generic_category()) }; + } else { + return mount_ertr::now(); + } }); } diff --git a/src/crimson/os/alienstore/alien_store.h b/src/crimson/os/alienstore/alien_store.h index b0ab87e254e68..0557dae77c28d 100644 --- a/src/crimson/os/alienstore/alien_store.h +++ b/src/crimson/os/alienstore/alien_store.h @@ -46,7 +46,7 @@ public: seastar::future<> start() final; seastar::future<> stop() final; - seastar::future<> mount() final; + mount_ertr::future<> mount() final; seastar::future<> umount() final; mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) final; diff --git a/src/crimson/os/cyanstore/cyan_store.cc b/src/crimson/os/cyanstore/cyan_store.cc index f261366759491..9122a56c0b005 100644 --- a/src/crimson/os/cyanstore/cyan_store.cc +++ b/src/crimson/os/cyanstore/cyan_store.cc @@ -53,13 +53,14 @@ private: }; }; -seastar::future<> CyanStore::mount() +CyanStore::mount_ertr::future<> CyanStore::mount() { + static const char read_file_errmsg[]{"read_file"}; ceph::bufferlist bl; std::string fn = path + "/collections"; std::string err; if (int r = bl.read_file(fn.c_str(), &err); r < 0) { - throw std::runtime_error("read_file"); + return crimson::stateful_ec{ singleton_ec() }; } std::set collections; @@ -70,7 +71,7 @@ seastar::future<> CyanStore::mount() std::string fn = fmt::format("{}/{}", path, coll); ceph::bufferlist cbl; if (int r = cbl.read_file(fn.c_str(), &err); r < 0) { - throw std::runtime_error("read_file"); + return crimson::stateful_ec{ singleton_ec() }; } boost::intrusive_ptr c{new Collection{coll}}; auto p = cbl.cbegin(); @@ -78,7 +79,7 @@ seastar::future<> CyanStore::mount() coll_map[coll] = c; used_bytes += c->used_bytes(); } - return seastar::now(); + return mount_ertr::now(); } seastar::future<> CyanStore::umount() diff --git a/src/crimson/os/cyanstore/cyan_store.h b/src/crimson/os/cyanstore/cyan_store.h index d4881202c600b..492801e5a13be 100644 --- a/src/crimson/os/cyanstore/cyan_store.h +++ b/src/crimson/os/cyanstore/cyan_store.h @@ -68,7 +68,7 @@ public: seastar::future<> stop() final { return seastar::now(); } - seastar::future<> mount() final; + mount_ertr::future<> mount() final; seastar::future<> umount() final; mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) final; diff --git a/src/crimson/os/futurized_store.h b/src/crimson/os/futurized_store.h index b4dced9dc87cd..02e891254ac03 100644 --- a/src/crimson/os/futurized_store.h +++ b/src/crimson/os/futurized_store.h @@ -65,7 +65,9 @@ public: return seastar::now(); } virtual seastar::future<> stop() = 0; - virtual seastar::future<> mount() = 0; + + using mount_ertr = crimson::errorator; + virtual mount_ertr::future<> mount() = 0; virtual seastar::future<> umount() = 0; using mkfs_ertr = crimson::errorator; diff --git a/src/crimson/os/seastore/seastore.cc b/src/crimson/os/seastore/seastore.cc index 0a81fd63daf42..3ccf0e099a5a7 100644 --- a/src/crimson/os/seastore/seastore.cc +++ b/src/crimson/os/seastore/seastore.cc @@ -88,7 +88,7 @@ seastar::future<> SeaStore::stop() return seastar::now(); } -seastar::future<> SeaStore::mount() +SeaStore::mount_ertr::future<> SeaStore::mount() { return segment_manager->mount( ).safe_then([this] { diff --git a/src/crimson/os/seastore/seastore.h b/src/crimson/os/seastore/seastore.h index f21e2832fab41..f5dce81235147 100644 --- a/src/crimson/os/seastore/seastore.h +++ b/src/crimson/os/seastore/seastore.h @@ -50,7 +50,7 @@ public: ~SeaStore(); seastar::future<> stop() final; - seastar::future<> mount() final; + mount_ertr::future<> mount() final; seastar::future<> umount() final; mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) final; diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index 02ef518bb3197..b5a263eeea161 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -161,7 +161,13 @@ seastar::future<> OSD::mkfs(uuid_d osd_uuid, uuid_d cluster_fsid) std::exit(EXIT_FAILURE); })); }).then([this] { - return store.mount(); + return store.mount().handle_error( + crimson::stateful_ec::handle([] (const auto& ec) { + logger().error("error mounting object store in {}: ({}) {}", + local_conf().get_val("osd_data"), + ec.value(), ec.message()); + std::exit(EXIT_FAILURE); + })); }).then([cluster_fsid, this] { superblock.cluster_fsid = cluster_fsid; superblock.osd_fsid = store.get_fsid(); @@ -295,7 +301,13 @@ seastar::future<> OSD::start() startup_time = ceph::mono_clock::now(); return store.start().then([this] { - return store.mount(); + return store.mount().handle_error( + crimson::stateful_ec::handle([] (const auto& ec) { + logger().error("error mounting object store in {}: ({}) {}", + local_conf().get_val("osd_data"), + ec.value(), ec.message()); + std::exit(EXIT_FAILURE); + })); }).then([this] { return store.open_collection(coll_t::meta()); }).then([this](auto ch) { diff --git a/src/test/crimson/seastore/transaction_manager_test_state.h b/src/test/crimson/seastore/transaction_manager_test_state.h index 00e77b68b7841..4e868e173b7e3 100644 --- a/src/test/crimson/seastore/transaction_manager_test_state.h +++ b/src/test/crimson/seastore/transaction_manager_test_state.h @@ -37,14 +37,14 @@ protected: virtual seastar::future<> _teardown() = 0; virtual FuturizedStore::mkfs_ertr::future<> _mkfs() = 0; - virtual seastar::future<> _mount() = 0; + virtual FuturizedStore::mount_ertr::future<> _mount() = 0; void restart() { _teardown().get0(); destroy(); static_cast(&*segment_manager)->remount(); init(); - _mount().get0(); + _mount().handle_error(crimson::ct_error::assert_all{}).get0(); } seastar::future<> tm_setup() { @@ -145,7 +145,7 @@ protected: ); } - virtual seastar::future<> _mount() { + virtual FuturizedStore::mount_ertr::future<> _mount() { return tm->mount( ).handle_error( crimson::ct_error::assert_all{"Error in mount"} @@ -276,7 +276,7 @@ protected: }); } - virtual seastar::future<> _mount() final { + virtual FuturizedStore::mount_ertr::future<> _mount() final { return seastore->mount(); }