Skip to content

Commit 3caa542

Browse files
authored
Merge pull request ceph#60747 from mohit84/crimson_device_class
crimson: Set device class during spawn of a crimson osd Reviewed-by: Matan Breizman <[email protected]>
2 parents 631c687 + d2ee4c1 commit 3caa542

File tree

9 files changed

+69
-0
lines changed

9 files changed

+69
-0
lines changed

src/crimson/os/alienstore/alien_store.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,19 @@ seastar::future<struct stat> AlienStore::stat(
590590
});
591591
}
592592

593+
seastar::future<std::string> AlienStore::get_default_device_class()
594+
{
595+
logger().debug("{}", __func__);
596+
assert(tp);
597+
return op_gates.simple_dispatch("get_default_device_class", [=, this] {
598+
return tp->submit([=, this] {
599+
return store->get_default_device_class();
600+
}).then([] (std::string device_class) {
601+
return seastar::make_ready_future<std::string>(device_class);
602+
});
603+
});
604+
}
605+
593606
auto AlienStore::omap_get_header(CollectionRef ch,
594607
const ghobject_t& oid)
595608
-> get_attr_errorator::future<ceph::bufferlist>

src/crimson/os/alienstore/alien_store.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class AlienStore final : public FuturizedStore,
9898
seastar::future<struct stat> stat(
9999
CollectionRef,
100100
const ghobject_t&) final;
101+
seastar::future<std::string> get_default_device_class() final;
101102
get_attr_errorator::future<ceph::bufferlist> omap_get_header(
102103
CollectionRef,
103104
const ghobject_t&) final;

src/crimson/os/cyanstore/cyan_store.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ CyanStore::list_collections()
143143
});
144144
}
145145

146+
seastar::future<std::string>
147+
CyanStore::get_default_device_class()
148+
{
149+
return seastar::make_ready_future<std::string>("");
150+
}
151+
146152
CyanStore::mount_ertr::future<> CyanStore::Shard::mount()
147153
{
148154
static const char read_file_errmsg[]{"read_file"};

src/crimson/os/cyanstore/cyan_store.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ class CyanStore final : public FuturizedStore {
221221

222222
seastar::future<std::vector<coll_core_t>> list_collections() final;
223223

224+
seastar::future<std::string> get_default_device_class() final;
225+
224226
private:
225227
seastar::sharded<CyanStore::Shard> shard_stores;
226228
const std::string path;

src/crimson/os/futurized_store.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class FuturizedStore {
203203
using coll_core_t = std::pair<coll_t, core_id_t>;
204204
virtual seastar::future<std::vector<coll_core_t>> list_collections() = 0;
205205

206+
virtual seastar::future<std::string> get_default_device_class() = 0;
206207
protected:
207208
const core_id_t primary_core;
208209
};

src/crimson/os/seastore/seastore.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,6 +2721,13 @@ SeaStore::read_meta(const std::string& key)
27212721
);
27222722
}
27232723

2724+
seastar::future<std::string> SeaStore::get_default_device_class()
2725+
{
2726+
using crimson::common::get_conf;
2727+
std::string type = get_conf<std::string>("seastore_main_device_type");
2728+
return seastar::make_ready_future<std::string>(type);
2729+
}
2730+
27242731
uuid_d SeaStore::Shard::get_fsid() const
27252732
{
27262733
return device->get_meta().seastore_id;

src/crimson/os/seastore/seastore.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ class SeaStore final : public FuturizedStore {
191191
seastar::future<> write_meta(const std::string& key,
192192
const std::string& value);
193193

194+
seastar::future<std::string> get_default_device_class();
195+
194196
store_statfs_t stat() const;
195197

196198
uuid_d get_fsid() const;
@@ -567,6 +569,8 @@ class SeaStore final : public FuturizedStore {
567569

568570
seastar::future<std::vector<coll_core_t>> list_collections() final;
569571

572+
seastar::future<std::string> get_default_device_class() final;
573+
570574
FuturizedStore::Shard& get_sharded_store() final {
571575
return shard_stores.local();
572576
}

src/crimson/osd/osd.cc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,8 @@ seastar::future<> OSD::start()
504504
}).then_unpack([this] {
505505
return _add_me_to_crush();
506506
}).then([this] {
507+
return _add_device_class();
508+
}).then([this] {
507509
monc->sub_want("osd_pg_creates", last_pg_create_epoch, 0);
508510
monc->sub_want("mgrmap", 0, 0);
509511
monc->sub_want("osdmap", 0, 0);
@@ -608,6 +610,38 @@ seastar::future<> OSD::_send_boot()
608610
return monc->send_message(std::move(m));
609611
}
610612

613+
seastar::future<> OSD::_add_device_class()
614+
{
615+
LOG_PREFIX(OSD::_add_device_class);
616+
if (!local_conf().get_val<bool>("osd_class_update_on_start")) {
617+
co_return;
618+
}
619+
620+
std::string device_class = co_await store.get_default_device_class();
621+
if (device_class.empty()) {
622+
WARN("Device class is empty; skipping crush update.");
623+
co_return;
624+
}
625+
626+
INFO("device_class is {} ", device_class);
627+
628+
std::string cmd = fmt::format(
629+
R"({{"prefix": "osd crush set-device-class", "class": "{}", "ids": ["{}"]}})",
630+
device_class, stringify(whoami)
631+
);
632+
633+
auto [code, message, out] = co_await monc->run_command(std::move(cmd), {});
634+
if (code) {
635+
// to be caught by crimson/osd/main.cc
636+
WARN("fail to set device_class : {} ({})", message, code);
637+
throw std::runtime_error("fail to set device_class");
638+
} else {
639+
INFO("device_class was set: {}", message);
640+
}
641+
642+
co_return;
643+
}
644+
611645
seastar::future<> OSD::_add_me_to_crush()
612646
{
613647
LOG_PREFIX(OSD::_add_me_to_crush);

src/crimson/osd/osd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ class OSD final : public crimson::net::Dispatcher,
188188
seastar::future<> _preboot(version_t oldest_osdmap, version_t newest_osdmap);
189189
seastar::future<> _send_boot();
190190
seastar::future<> _add_me_to_crush();
191+
seastar::future<> _add_device_class();
191192

192193
seastar::future<> osdmap_subscribe(version_t epoch, bool force_request);
193194

0 commit comments

Comments
 (0)