namespace crimson::osd {
OSD::OSD(int id, uint32_t nonce,
- seastar::alien::instance& alien,
+ crimson::os::FuturizedStore& store,
crimson::net::MessengerRef cluster_msgr,
crimson::net::MessengerRef public_msgr,
crimson::net::MessengerRef hb_front_msgr,
public_msgr{public_msgr},
monc{new crimson::mon::Client{*public_msgr, *this}},
mgrc{new crimson::mgr::Client{*public_msgr, *this}},
- store{crimson::os::FuturizedStore::create(
- local_conf().get_val<std::string>("osd_objectstore"),
- local_conf().get_val<std::string>("osd_data"),
- local_conf().get_config_values(),
- alien)},
- shard_services{*this, whoami, *cluster_msgr, *public_msgr, *monc, *mgrc, *store},
+ store{store},
+ shard_services{*this, whoami, *cluster_msgr, *public_msgr, *monc, *mgrc, store},
heartbeat{new Heartbeat{whoami, shard_services, *monc, hb_front_msgr, hb_back_msgr}},
// do this in background
tick_timer{[this] {
seastar::future<> OSD::mkfs(uuid_d osd_uuid, uuid_d cluster_fsid)
{
- return store->start().then([this, osd_uuid] {
- return store->mkfs(osd_uuid);
+ return store.start().then([this, osd_uuid] {
+ return store.mkfs(osd_uuid);
}).then([this] {
- return store->mount();
+ return store.mount();
}).then([cluster_fsid, this] {
superblock.cluster_fsid = cluster_fsid;
- superblock.osd_fsid = store->get_fsid();
+ superblock.osd_fsid = store.get_fsid();
superblock.whoami = whoami;
superblock.compat_features = get_osd_initial_compat_set();
return _write_superblock();
}).then([cluster_fsid, this] {
return when_all_succeed(
- store->write_meta("ceph_fsid", cluster_fsid.to_string()),
- store->write_meta("whoami", std::to_string(whoami)));
+ store.write_meta("ceph_fsid", cluster_fsid.to_string()),
+ store.write_meta("whoami", std::to_string(whoami)));
}).then_unpack([cluster_fsid, this] {
fmt::print("created object store {} for osd.{} fsid {}\n",
local_conf().get_val<std::string>("osd_data"),
seastar::future<> OSD::_write_superblock()
{
- return store->open_collection(coll_t::meta()).then([this] (auto ch) {
+ return store.open_collection(coll_t::meta()).then([this] (auto ch) {
if (ch) {
// if we already have superblock, check if it matches
- meta_coll = make_unique<OSDMeta>(ch, store.get());
+ meta_coll = make_unique<OSDMeta>(ch, &store);
return meta_coll->load_superblock().then([this](OSDSuperblock&& sb) {
if (sb.cluster_fsid != superblock.cluster_fsid) {
logger().error("provided cluster fsid {} != superblock's {}",
__func__,
superblock.cluster_fsid,
superblock.osd_fsid);
- return store->create_new_collection(coll_t::meta()).then([this] (auto ch) {
- meta_coll = make_unique<OSDMeta>(ch , store.get());
+ return store.create_new_collection(coll_t::meta()).then([this] (auto ch) {
+ meta_coll = make_unique<OSDMeta>(ch , &store);
ceph::os::Transaction t;
meta_coll->create(t);
meta_coll->store_superblock(t, superblock);
- return store->do_transaction(meta_coll->collection(), std::move(t));
+ return store.do_transaction(meta_coll->collection(), std::move(t));
});
}
});
startup_time = ceph::mono_clock::now();
- return store->start().then([this] {
- return store->mount();
+ return store.start().then([this] {
+ return store.mount();
}).then([this] {
- return store->open_collection(coll_t::meta());
+ return store.open_collection(coll_t::meta());
}).then([this](auto ch) {
- meta_coll = make_unique<OSDMeta>(ch, store.get());
+ meta_coll = make_unique<OSDMeta>(ch, &store);
return meta_coll->load_superblock();
}).then([this](OSDSuperblock&& sb) {
superblock = std::move(sb);
w >= 0) {
return seastar::make_ready_future<double>(w);
} else {
- return store->stat().then([](auto st) {
+ return store.stat().then([](auto st) {
auto total = st.total;
return seastar::make_ready_future<double>(
std::max(.00001,
return asok->stop().then([this] {
return heartbeat->stop();
}).then([this] {
- return store->umount();
+ return store.umount();
}).then([this] {
- return store->stop();
+ return store.stop();
}).then([this] {
return seastar::parallel_for_each(pg_map.get_pgs(),
[](auto& p) {
seastar::future<> OSD::load_pgs()
{
- return store->list_collections().then([this](auto colls) {
+ return store.list_collections().then([this](auto colls) {
return seastar::parallel_for_each(colls, [this](auto coll) {
spg_t pgid;
if (coll.is_pg(&pgid)) {
auto get_collection = [pgid, do_create, this] {
const coll_t cid{pgid};
if (do_create) {
- return store->create_new_collection(cid);
+ return store.create_new_collection(cid);
} else {
- return store->open_collection(cid);
+ return store.open_collection(cid);
}
};
return seastar::when_all(
{
logger().debug("{}: {}", __func__, pgid);
- return seastar::do_with(PGMeta(store.get(), pgid), [] (auto& pg_meta) {
+ return seastar::do_with(PGMeta(&store, pgid), [] (auto& pg_meta) {
return pg_meta.get_epoch();
}).then([this](epoch_t e) {
return get_map(e);
}).then([pgid, this] (auto&& create_map) {
return make_pg(std::move(create_map), pgid, false);
}).then([this](Ref<PG> pg) {
- return pg->read_state(store.get()).then([pg] {
+ return pg->read_state(&store).then([pg] {
return seastar::make_ready_future<Ref<PG>>(std::move(pg));
});
}).handle_exception([pgid](auto ep) {
osd_stat.hb_peers = heartbeat->get_peers();
osd_stat.seq = (static_cast<uint64_t>(get_up_epoch()) << 32) | osd_stat_seq;
gate.dispatch_in_background("statfs", *this, [this] {
- (void) store->stat().then([this](store_statfs_t&& st) {
+ (void) store.stat().then([this](store_statfs_t&& st) {
osd_stat.statfs = st;
});
});
superblock.clean_thru = last;
}
meta_coll->store_superblock(t, superblock);
- return store->do_transaction(meta_coll->collection(), std::move(t));
+ return store.do_transaction(meta_coll->collection(), std::move(t));
});
}).then([=] {
// TODO: write to superblock and commit the transaction