});
}
+seastar::future<std::string> AlienStore::get_default_device_class()
+{
+ logger().debug("{}", __func__);
+ assert(tp);
+ return op_gates.simple_dispatch("get_default_device_class", [=, this] {
+ return tp->submit([=, this] {
+ return store->get_default_device_class();
+ }).then([] (std::string device_class) {
+ return seastar::make_ready_future<std::string>(device_class);
+ });
+ });
+}
+
auto AlienStore::omap_get_header(CollectionRef ch,
const ghobject_t& oid)
-> get_attr_errorator::future<ceph::bufferlist>
seastar::future<struct stat> stat(
CollectionRef,
const ghobject_t&) final;
+ seastar::future<std::string> get_default_device_class() final;
get_attr_errorator::future<ceph::bufferlist> omap_get_header(
CollectionRef,
const ghobject_t&) final;
});
}
+seastar::future<std::string>
+CyanStore::get_default_device_class()
+{
+ return seastar::make_ready_future<std::string>("");
+}
+
CyanStore::mount_ertr::future<> CyanStore::Shard::mount()
{
static const char read_file_errmsg[]{"read_file"};
seastar::future<std::vector<coll_core_t>> list_collections() final;
+ seastar::future<std::string> get_default_device_class() final;
+
private:
seastar::sharded<CyanStore::Shard> shard_stores;
const std::string path;
using coll_core_t = std::pair<coll_t, core_id_t>;
virtual seastar::future<std::vector<coll_core_t>> list_collections() = 0;
+ virtual seastar::future<std::string> get_default_device_class() = 0;
protected:
const core_id_t primary_core;
};
);
}
+seastar::future<std::string> SeaStore::get_default_device_class()
+{
+ using crimson::common::get_conf;
+ std::string type = get_conf<std::string>("seastore_main_device_type");
+ return seastar::make_ready_future<std::string>(type);
+}
+
uuid_d SeaStore::Shard::get_fsid() const
{
return device->get_meta().seastore_id;
seastar::future<> write_meta(const std::string& key,
const std::string& value);
+ seastar::future<std::string> get_default_device_class();
+
store_statfs_t stat() const;
uuid_d get_fsid() const;
seastar::future<std::vector<coll_core_t>> list_collections() final;
+ seastar::future<std::string> get_default_device_class() final;
+
FuturizedStore::Shard& get_sharded_store() final {
return shard_stores.local();
}
}).then_unpack([this] {
return _add_me_to_crush();
}).then([this] {
+ return _add_device_class();
+ }).then([this] {
monc->sub_want("osd_pg_creates", last_pg_create_epoch, 0);
monc->sub_want("mgrmap", 0, 0);
monc->sub_want("osdmap", 0, 0);
return monc->send_message(std::move(m));
}
+seastar::future<> OSD::_add_device_class()
+{
+ LOG_PREFIX(OSD::_add_device_class);
+ if (!local_conf().get_val<bool>("osd_class_update_on_start")) {
+ co_return;
+ }
+
+ std::string device_class = co_await store.get_default_device_class();
+ if (device_class.empty()) {
+ WARN("Device class is empty; skipping crush update.");
+ co_return;
+ }
+
+ INFO("device_class is {} ", device_class);
+
+ std::string cmd = fmt::format(
+ R"({{"prefix": "osd crush set-device-class", "class": "{}", "ids": ["{}"]}})",
+ device_class, stringify(whoami)
+ );
+
+ auto [code, message, out] = co_await monc->run_command(std::move(cmd), {});
+ if (code) {
+ // to be caught by crimson/osd/main.cc
+ WARN("fail to set device_class : {} ({})", message, code);
+ throw std::runtime_error("fail to set device_class");
+ } else {
+ INFO("device_class was set: {}", message);
+ }
+
+ co_return;
+}
+
seastar::future<> OSD::_add_me_to_crush()
{
LOG_PREFIX(OSD::_add_me_to_crush);
seastar::future<> _preboot(version_t oldest_osdmap, version_t newest_osdmap);
seastar::future<> _send_boot();
seastar::future<> _add_me_to_crush();
+ seastar::future<> _add_device_class();
seastar::future<> osdmap_subscribe(version_t epoch, bool force_request);