From 7f26f701149c016520d0f6100fc5ddae652a15c2 Mon Sep 17 00:00:00 2001 From: Xuehan Xu Date: Tue, 31 Mar 2020 19:14:45 +0800 Subject: [PATCH] crimson/os: add readv method to futurized_store Signed-off-by: Xuehan Xu --- src/crimson/os/alienstore/alien_store.cc | 24 ++++++++++++++++++++++++ src/crimson/os/alienstore/alien_store.h | 5 +++++ src/crimson/os/cyanstore/cyan_store.cc | 21 +++++++++++++++++++++ src/crimson/os/cyanstore/cyan_store.h | 6 ++++++ src/crimson/os/futurized_store.h | 5 +++++ 5 files changed, 61 insertions(+) diff --git a/src/crimson/os/alienstore/alien_store.cc b/src/crimson/os/alienstore/alien_store.cc index 2f64f993804..fb8dad487fb 100644 --- a/src/crimson/os/alienstore/alien_store.cc +++ b/src/crimson/os/alienstore/alien_store.cc @@ -221,6 +221,30 @@ AlienStore::read(CollectionRef ch, }); } +AlienStore::read_errorator::future +AlienStore::readv(CollectionRef ch, + const ghobject_t& oid, + interval_set& m, + uint32_t op_flags) +{ + logger().debug("{}", __func__); + return seastar::do_with(ceph::bufferlist{}, + [this, ch, oid, &m, op_flags](auto& bl) { + return tp->submit([this, ch, oid, &m, op_flags, &bl] { + auto c = static_cast(ch.get()); + return store->readv(c->collection, oid, m, bl, op_flags); + }).then([&bl](int r) -> read_errorator::future { + if (r == -ENOENT) { + return crimson::ct_error::enoent::make(); + } else if (r == -EIO) { + return crimson::ct_error::input_output_error::make(); + } else { + return read_errorator::make_ready_future(std::move(bl)); + } + }); + }); +} + AlienStore::get_attr_errorator::future AlienStore::get_attr(CollectionRef ch, const ghobject_t& oid, diff --git a/src/crimson/os/alienstore/alien_store.h b/src/crimson/os/alienstore/alien_store.h index 87f71bd89a3..8885a196a62 100644 --- a/src/crimson/os/alienstore/alien_store.h +++ b/src/crimson/os/alienstore/alien_store.h @@ -53,6 +53,11 @@ public: uint64_t offset, size_t len, uint32_t op_flags = 0) final; + read_errorator::future readv(CollectionRef c, + const ghobject_t& oid, + interval_set& m, + uint32_t op_flags = 0) final; + get_attr_errorator::future get_attr(CollectionRef c, const ghobject_t& oid, diff --git a/src/crimson/os/cyanstore/cyan_store.cc b/src/crimson/os/cyanstore/cyan_store.cc index efcd6e7a1f2..109767c4b1b 100644 --- a/src/crimson/os/cyanstore/cyan_store.cc +++ b/src/crimson/os/cyanstore/cyan_store.cc @@ -198,6 +198,27 @@ CyanStore::read_errorator::future CyanStore::read( return read_errorator::make_ready_future(o->read(offset, l)); } +CyanStore::read_errorator::future CyanStore::readv( + CollectionRef ch, + const ghobject_t& oid, + interval_set& m, + uint32_t op_flags) +{ + return seastar::do_with(ceph::bufferlist{}, + [this, ch, oid, &m, op_flags](auto& bl) { + return crimson::do_for_each(m, + [this, ch, oid, op_flags, &bl](auto& p) { + return read(ch, oid, p.first, p.second, op_flags) + .safe_then([this, &bl](auto ret) { + bl.claim_append(ret); + }); + }).safe_then([&bl] { + return read_errorator::make_ready_future(std::move(bl)); + }); + }); +} + + CyanStore::get_attr_errorator::future CyanStore::get_attr( CollectionRef ch, const ghobject_t& oid, diff --git a/src/crimson/os/cyanstore/cyan_store.h b/src/crimson/os/cyanstore/cyan_store.h index 9af1cd640c8..b2d1ba25203 100644 --- a/src/crimson/os/cyanstore/cyan_store.h +++ b/src/crimson/os/cyanstore/cyan_store.h @@ -84,6 +84,12 @@ public: uint64_t offset, size_t len, uint32_t op_flags = 0) final; + read_errorator::future readv( + CollectionRef c, + const ghobject_t& oid, + interval_set& m, + uint32_t op_flags = 0) final; + get_attr_errorator::future get_attr( CollectionRef c, const ghobject_t& oid, diff --git a/src/crimson/os/futurized_store.h b/src/crimson/os/futurized_store.h index 2a0078d0bc4..a47855d8c0b 100644 --- a/src/crimson/os/futurized_store.h +++ b/src/crimson/os/futurized_store.h @@ -92,6 +92,11 @@ public: uint64_t offset, size_t len, uint32_t op_flags = 0) = 0; + virtual read_errorator::future readv( + CollectionRef c, + const ghobject_t& oid, + interval_set& m, + uint32_t op_flags = 0) = 0; using get_attr_errorator = crimson::errorator< crimson::ct_error::enoent, -- 2.39.5