return seastar::make_ready_future<std::vector<coll_t>>(std::move(collections));
}
-seastar::future<ceph::bufferlist> CyanStore::read(CollectionRef ch,
- const ghobject_t& oid,
- uint64_t offset,
- size_t len,
- uint32_t op_flags)
+CyanStore::read_errorator::future<ceph::bufferlist> CyanStore::read(
+ CollectionRef ch,
+ const ghobject_t& oid,
+ uint64_t offset,
+ size_t len,
+ uint32_t op_flags)
{
auto c = static_cast<Collection*>(ch.get());
logger().debug("{} {} {} {}~{}",
__func__, c->get_cid(), oid, offset, len);
if (!c->exists) {
- throw std::runtime_error(fmt::format("collection does not exist: {}",
- c->get_cid()));
+ return crimson::make_error<ceph::ct_error::enoent>();
}
ObjectRef o = c->get_object(oid);
if (!o) {
- throw std::runtime_error(fmt::format("object does not exist: {}", oid));
+ return crimson::make_error<ceph::ct_error::enoent>();
}
if (offset >= o->get_size())
return seastar::make_ready_future<ceph::bufferlist>();
seastar::future<> mkfs(uuid_d new_osd_fsid) final;
store_statfs_t stat() const final;
- seastar::future<ceph::bufferlist> read(CollectionRef c,
- const ghobject_t& oid,
- uint64_t offset,
- size_t len,
- uint32_t op_flags = 0) final;
+ read_errorator::future<ceph::bufferlist> read(
+ CollectionRef c,
+ const ghobject_t& oid,
+ uint64_t offset,
+ size_t len,
+ uint32_t op_flags = 0) final;
get_attr_errorator::future<ceph::bufferptr> get_attr(
CollectionRef c,
const ghobject_t& oid,
virtual store_statfs_t stat() const = 0;
using CollectionRef = boost::intrusive_ptr<FuturizedCollection>;
- virtual seastar::future<ceph::bufferlist> read(CollectionRef c,
- const ghobject_t& oid,
- uint64_t offset,
- size_t len,
- uint32_t op_flags = 0) = 0;
+
+ // TODO: using read_errorator = ceph::errorator<...>
+ struct read_errorator : crimson::errorator<crimson::ct_error::enoent> {
+ // just for the makeshift period of switching to errorator
+ struct throw_as_runtime_error : discard_all {
+ auto operator()(const auto& e) {
+ throw std::runtime_error("legacy throwing");
+ return discard_all::operator()(e);
+ }
+ };
+ };
+ virtual read_errorator::future<ceph::bufferlist> read(
+ CollectionRef c,
+ const ghobject_t& oid,
+ uint64_t offset,
+ size_t len,
+ uint32_t op_flags = 0) = 0;
+
using get_attr_errorator = crimson::errorator<
crimson::ct_error::enoent,
crimson::ct_error::enodata>;
#include "crimson/os/futurized_store.h"
#include "os/Transaction.h"
+using read_errorator = crimson::os::FuturizedStore::read_errorator;
+
void OSDMeta::create(ceph::os::Transaction& t)
{
t.create_collection(coll->get_cid(), 0);
{
return store->read(coll,
osdmap_oid(e), 0, 0,
- CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
+ CEPH_OSD_OP_FLAG_FADVISE_WILLNEED).safe_then(
+ [] (auto&& bl) { return bl; },
+ read_errorator::throw_as_runtime_error{});
}
void OSDMeta::store_superblock(ceph::os::Transaction& t,
seastar::future<OSDSuperblock> OSDMeta::load_superblock()
{
return store->read(coll, superblock_oid(), 0, 0)
- .then([this] (bufferlist&& bl) {
+ .safe_then([this] (bufferlist&& bl) {
auto p = bl.cbegin();
OSDSuperblock superblock;
decode(superblock, p);
return seastar::make_ready_future<OSDSuperblock>(std::move(superblock));
- });
+ }, read_errorator::throw_as_runtime_error{});
}
seastar::future<pg_pool_t,
OSDMeta::ec_profile_t>
OSDMeta::load_final_pool_info(int64_t pool) {
return store->read(coll, final_pool_info_oid(pool),
- 0, 0).then([this] (bufferlist&& bl) {
+ 0, 0).safe_then([this] (bufferlist&& bl) {
auto p = bl.cbegin();
pg_pool_t pi;
string name;
ec_profile_t>(std::move(pi),
std::move(name),
std::move(ec_profile));
- });
+ }, read_errorator::throw_as_runtime_error{});
}
ghobject_t OSDMeta::osdmap_oid(epoch_t epoch)
uint64_t len,
uint32_t flags)
{
- return store->read(coll, ghobject_t{hoid}, off, len, flags);
+ using read_errorator = ceph::os::FuturizedStore::read_errorator;
+ return store->read(coll, ghobject_t{hoid}, off, len, flags).safe_then(
+ [] (auto&& bl) { return bl; },
+ read_errorator::throw_as_runtime_error{});
}
seastar::future<crimson::osd::acked_peers_t>