mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
Merge pull request #43592 from rzarzynski/wip-crimson-mount_ertr
crimson: errorate the FuturizedStore::mount() paths. Reviewed-by: Samuel Just <sjust@redhat.com> Reviewed-by: Chunmei Liu <chunmei.liu@intel.com>
This commit is contained in:
commit
92d0a7ca3d
src
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -34,13 +34,33 @@ CyanStore::CyanStore(const std::string& path)
|
||||
|
||||
CyanStore::~CyanStore() = default;
|
||||
|
||||
seastar::future<> CyanStore::mount()
|
||||
template <const char* MsgV>
|
||||
struct singleton_ec : std::error_code {
|
||||
singleton_ec()
|
||||
: error_code(42, this_error_category{}) {
|
||||
};
|
||||
private:
|
||||
struct this_error_category : std::error_category {
|
||||
const char* name() const noexcept final {
|
||||
// XXX: we could concatenate with MsgV at compile-time but the burden
|
||||
// isn't worth the benefit.
|
||||
return "singleton_ec";
|
||||
}
|
||||
std::string message([[maybe_unused]] const int ev) const final {
|
||||
assert(ev == 42);
|
||||
return MsgV;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
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<read_file_errmsg>() };
|
||||
}
|
||||
|
||||
std::set<coll_t> collections;
|
||||
@ -51,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<read_file_errmsg>() };
|
||||
}
|
||||
boost::intrusive_ptr<Collection> c{new Collection{coll}};
|
||||
auto p = cbl.cbegin();
|
||||
@ -59,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()
|
||||
@ -82,25 +102,6 @@ seastar::future<> CyanStore::umount()
|
||||
});
|
||||
}
|
||||
|
||||
template <const char* MsgV>
|
||||
struct singleton_ec : std::error_code {
|
||||
singleton_ec()
|
||||
: error_code(42, this_error_category{}) {
|
||||
};
|
||||
private:
|
||||
struct this_error_category : std::error_category {
|
||||
const char* name() const noexcept final {
|
||||
// XXX: we could concatenate with MsgV at compile-time but the burden
|
||||
// isn't worth the benefit.
|
||||
return "singleton_ec";
|
||||
}
|
||||
std::string message([[maybe_unused]] const int ev) const final {
|
||||
assert(ev == 42);
|
||||
return MsgV;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
CyanStore::mkfs_ertr::future<> CyanStore::mkfs(uuid_d new_osd_fsid)
|
||||
{
|
||||
static const char read_meta_errmsg[]{"read_meta"};
|
||||
|
@ -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;
|
||||
|
@ -65,7 +65,9 @@ public:
|
||||
return seastar::now();
|
||||
}
|
||||
virtual seastar::future<> stop() = 0;
|
||||
virtual seastar::future<> mount() = 0;
|
||||
|
||||
using mount_ertr = crimson::errorator<crimson::stateful_ec>;
|
||||
virtual mount_ertr::future<> mount() = 0;
|
||||
virtual seastar::future<> umount() = 0;
|
||||
|
||||
using mkfs_ertr = crimson::errorator<crimson::stateful_ec>;
|
||||
|
@ -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] {
|
||||
|
@ -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;
|
||||
|
@ -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<std::string>("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<std::string>("osd_data"),
|
||||
ec.value(), ec.message());
|
||||
std::exit(EXIT_FAILURE);
|
||||
}));
|
||||
}).then([this] {
|
||||
return store.open_collection(coll_t::meta());
|
||||
}).then([this](auto ch) {
|
||||
|
@ -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::EphemeralSegmentManager*>(&*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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user