void encode(bufferlist& bl) const;
void decode(bufferlist::const_iterator& p);
};
+using ObjectRef = boost::intrusive_ptr<Object>;
+
}
});
}
-store_statfs_t CyanStore::stat() const
+seastar::future<store_statfs_t> CyanStore::stat() const
{
logger().debug("{}", __func__);
store_statfs_t st;
st.total = crimson::common::local_conf().get_val<Option::size_t>("memstore_device_bytes");
st.available = st.total - used_bytes;
- return st;
+ return seastar::make_ready_future<store_statfs_t>(std::move(st));
}
seastar::future<std::vector<ghobject_t>, ghobject_t>
#include <optional>
#include <seastar/core/future.hh>
+#include <seastar/core/future-util.hh>
#include "osd/osd_types.h"
#include "include/uuid.h"
CyanStore(const std::string& path);
~CyanStore() final;
+ seastar::future<> stop() final {return seastar::now();}
seastar::future<> mount() final;
seastar::future<> umount() final;
seastar::future<> mkfs(uuid_d new_osd_fsid) final;
- store_statfs_t stat() const final;
+ seastar::future<store_statfs_t> stat() const final;
read_errorator::future<ceph::bufferlist> read(
CollectionRef c,
#include "osd/osd_types.h"
namespace crimson::os {
+class FuturizedStore;
class FuturizedCollection
: public boost::intrusive_ref_counter<FuturizedCollection,
: cid{cid} {}
virtual ~FuturizedCollection() {}
virtual seastar::future<> flush() {
- return seastar::now();
+ return seastar::make_ready_future<>();
}
virtual seastar::future<bool> flush_commit() {
return seastar::make_ready_future<bool>(true);
explicit FuturizedStore(const FuturizedStore& o) = delete;
const FuturizedStore& operator=(const FuturizedStore& o) = delete;
+ virtual seastar::future<> start() {
+ return seastar::now();
+ }
+ virtual seastar::future<> stop() = 0;
virtual seastar::future<> mount() = 0;
virtual seastar::future<> umount() = 0;
virtual seastar::future<> mkfs(uuid_d new_osd_fsid) = 0;
- virtual store_statfs_t stat() const = 0;
+ virtual seastar::future<store_statfs_t> stat() const = 0;
using CollectionRef = boost::intrusive_ptr<FuturizedCollection>;
- using read_errorator = crimson::errorator<crimson::ct_error::enoent>;
+ using read_errorator = crimson::errorator<crimson::ct_error::enoent,
+ crimson::ct_error::input_output_error>;
virtual read_errorator::future<ceph::bufferlist> read(
CollectionRef c,
const ghobject_t& oid,
seastar::future<> OSD::mkfs(uuid_d osd_uuid, uuid_d cluster_fsid)
{
- return store->mkfs(osd_uuid).then([this] {
+ return store->start().then([this, osd_uuid] {
+ return store->mkfs(osd_uuid);
+ }).then([this] {
return store->mount();
}).then([cluster_fsid, this] {
superblock.cluster_fsid = cluster_fsid;
startup_time = ceph::mono_clock::now();
- return store->mount().then([this] {
+ return store->start().then([this] {
+ return store->mount();
+ }).then([this] {
return store->open_collection(coll_t::meta());
}).then([this](auto ch) {
meta_coll = make_unique<OSDMeta>(ch, store.get());
if (!local_conf().get_val<bool>("osd_crush_update_on_start")) {
return seastar::now();
}
- const double weight = [this] {
+ auto get_weight = [this] {
if (auto w = local_conf().get_val<double>("osd_crush_initial_weight");
w >= 0) {
- return w;
+ return seastar::make_ready_future<double>(w);
} else {
- auto total = store->stat().total;
- return std::max(.00001, double(total) / double(1ull << 40)); // TB
+ return store->stat().then([](auto st) {
+ auto total = st.total;
+ return seastar::make_ready_future<double>(
+ std::max(.00001,
+ double(total) / double(1ull << 40))); // TB
+ });
}
- }();
- const crimson::crush::CrushLocation loc{make_unique<CephContext>().get()};
- logger().info("{} crush location is {}", __func__, loc);
- string cmd = fmt::format(R"({{
- "prefix": "osd crush create-or-move",
- "id": {},
- "weight": {:.4f},
- "args": [{}]
- }})", whoami, weight, loc);
- return monc->run_command({cmd}, {}).then(
- [](int32_t code, string message, bufferlist) {
- if (code) {
- logger().warn("fail to add to crush: {} ({})", message, code);
- throw std::runtime_error("fail to add to crush");
- } else {
- logger().info("added to crush: {}", message);
- }
- return seastar::now();
- });
+ };
+ return get_weight().then([this](auto weight) {
+ const crimson::crush::CrushLocation loc{make_unique<CephContext>().get()};
+ logger().info("{} crush location is {}", __func__, loc);
+ string cmd = fmt::format(R"({{
+ "prefix": "osd crush create-or-move",
+ "id": {},
+ "weight": {:.4f},
+ "args": [{}]
+ }})", whoami, weight, loc);
+ return monc->run_command({cmd}, {});
+ }).then([](int32_t code, string message, bufferlist) {
+ if (code) {
+ logger().warn("fail to add to crush: {} ({})", message, code);
+ throw std::runtime_error("fail to add to crush");
+ } else {
+ logger().info("added to crush: {}", message);
+ }
+ return seastar::now();
+ });
}
seastar::future<> OSD::_send_alive()
cluster_msgr->shutdown());
}).then([this] {
return store->umount();
+ }).then([this] {
+ return store->stop();
}).handle_exception([](auto ep) {
logger().error("error while stopping osd: {}", ep);
});
return store->read(coll,
osdmap_oid(e), 0, 0,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED).handle_error(
- crimson::ct_error::enoent::handle([e] {
+ read_errorator::all_same_way([e] {
throw std::runtime_error(fmt::format("read gave enoent on {}",
osdmap_oid(e)));
}));
OSDSuperblock superblock;
decode(superblock, p);
return seastar::make_ready_future<OSDSuperblock>(std::move(superblock));
- }, crimson::ct_error::enoent::handle([] {
+ }, read_errorator::all_same_way([] {
throw std::runtime_error(fmt::format("read gave enoent on {}",
superblock_oid()));
}));
ec_profile_t>(std::move(pi),
std::move(name),
std::move(ec_profile));
- }, crimson::ct_error::enoent::handle([pool] {
+ },read_errorator::all_same_way([pool] {
throw std::runtime_error(fmt::format("read gave enoent on {}",
final_pool_info_oid(pool)));
}));
#include <string>
#include <seastar/core/future.hh>
#include "osd/osd_types.h"
+#include "crimson/os/futurized_collection.h"
namespace ceph::os {
class Transaction;
: store{store}, coll{coll}
{}
-
auto collection() {
return coll;
}
const ec_profile_t& ec_profile);
using read_errorator = ll_read_errorator::extend<
- crimson::ct_error::input_output_error,
crimson::ct_error::object_corrupted>;
read_errorator::future<ceph::bufferlist> read(
const object_info_t& oi,