Skip to content

Commit 4b8ca5f

Browse files
committed
common/mclock_common: move config registration and tracking into MclockConfig
mClockScheduler doesn't listen on any keys of its own, simpler to just bring it into MclockConfig. Signed-off-by: Samuel Just <[email protected]>
1 parent d4c8950 commit 4b8ca5f

File tree

4 files changed

+41
-55
lines changed

4 files changed

+41
-55
lines changed

src/common/mclock_common.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,8 @@ uint32_t MclockConfig::calc_scaled_cost(int item_cost)
377377
return std::max<uint32_t>(cost, cost_per_io);
378378
}
379379

380-
void MclockConfig::mclock_handle_conf_change(const ConfigProxy& conf,
381-
const std::set<std::string>
382-
&changed)
380+
void MclockConfig::handle_conf_change(const ConfigProxy& conf,
381+
const std::set<std::string> &changed)
383382
{
384383
if (changed.count("osd_mclock_max_capacity_iops_hdd") ||
385384
changed.count("osd_mclock_max_capacity_iops_ssd")) {
@@ -466,4 +465,5 @@ MclockConfig::~MclockConfig()
466465
delete logger;
467466
logger = nullptr;
468467
}
468+
cct->_conf.remove_observer(this);
469469
}

src/common/mclock_common.h

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class ClientRegistry {
186186
const scheduler_id_t &id) const;
187187
};
188188

189-
class MclockConfig {
189+
class MclockConfig final : public md_config_obs_t {
190190
private:
191191
CephContext *cct;
192192
uint32_t num_shards;
@@ -211,7 +211,13 @@ class MclockConfig {
211211
whoami(whoami), osd_bandwidth_cost_per_io(0.0),
212212
osd_bandwidth_capacity_per_shard(0.0),
213213
client_registry(creg)
214-
{}
214+
{
215+
cct->_conf.add_observer(this);
216+
set_osd_capacity_params_from_config();
217+
set_config_defaults_from_profile();
218+
client_registry.update_from_config(
219+
cct->_conf, get_capacity_per_shard());
220+
}
215221
#else
216222
MclockConfig(CephContext *cct, ClientRegistry& creg,
217223
MonClient *monc, uint32_t num_shards, bool is_rotational,
@@ -223,17 +229,42 @@ class MclockConfig {
223229
osd_bandwidth_cost_per_io(0.0),
224230
osd_bandwidth_capacity_per_shard(0.0),
225231
client_registry(creg), monc(monc)
226-
{}
232+
{
233+
cct->_conf.add_observer(this);
234+
set_osd_capacity_params_from_config();
235+
set_config_defaults_from_profile();
236+
client_registry.update_from_config(
237+
cct->_conf, get_capacity_per_shard());
238+
}
227239
#endif
228-
~MclockConfig();
240+
~MclockConfig() final;
229241
void set_config_defaults_from_profile();
230242
void set_osd_capacity_params_from_config();
231243
void init_logger();
232244
void get_mclock_counter(scheduler_id_t id);
233245
void put_mclock_counter(scheduler_id_t id);
234246
double get_cost_per_io() const;
235247
double get_capacity_per_shard() const;
236-
void mclock_handle_conf_change(const ConfigProxy& conf,
237-
const std::set<std::string> &changed);
248+
void handle_conf_change(const ConfigProxy& conf,
249+
const std::set<std::string> &changed) final;
250+
std::vector<std::string> get_tracked_keys() const noexcept final {
251+
using namespace std::literals;
252+
return {
253+
"osd_mclock_scheduler_client_res"s,
254+
"osd_mclock_scheduler_client_wgt"s,
255+
"osd_mclock_scheduler_client_lim"s,
256+
"osd_mclock_scheduler_background_recovery_res"s,
257+
"osd_mclock_scheduler_background_recovery_wgt"s,
258+
"osd_mclock_scheduler_background_recovery_lim"s,
259+
"osd_mclock_scheduler_background_best_effort_res"s,
260+
"osd_mclock_scheduler_background_best_effort_wgt"s,
261+
"osd_mclock_scheduler_background_best_effort_lim"s,
262+
"osd_mclock_max_capacity_iops_hdd"s,
263+
"osd_mclock_max_capacity_iops_ssd"s,
264+
"osd_mclock_max_sequential_bandwidth_hdd"s,
265+
"osd_mclock_max_sequential_bandwidth_ssd"s,
266+
"osd_mclock_profile"s
267+
};
268+
}
238269
uint32_t calc_scaled_cost(int item_cost);
239270
};

src/osd/scheduler/mClockScheduler.cc

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -197,38 +197,4 @@ std::string mClockScheduler::display_queues() const
197197
return out.str();
198198
}
199199

200-
201-
std::vector<std::string> mClockScheduler::get_tracked_keys() const noexcept
202-
{
203-
return {
204-
"osd_mclock_scheduler_client_res"s,
205-
"osd_mclock_scheduler_client_wgt"s,
206-
"osd_mclock_scheduler_client_lim"s,
207-
"osd_mclock_scheduler_background_recovery_res"s,
208-
"osd_mclock_scheduler_background_recovery_wgt"s,
209-
"osd_mclock_scheduler_background_recovery_lim"s,
210-
"osd_mclock_scheduler_background_best_effort_res"s,
211-
"osd_mclock_scheduler_background_best_effort_wgt"s,
212-
"osd_mclock_scheduler_background_best_effort_lim"s,
213-
"osd_mclock_max_capacity_iops_hdd"s,
214-
"osd_mclock_max_capacity_iops_ssd"s,
215-
"osd_mclock_max_sequential_bandwidth_hdd"s,
216-
"osd_mclock_max_sequential_bandwidth_ssd"s,
217-
"osd_mclock_profile"s
218-
};
219-
}
220-
221-
222-
void mClockScheduler::handle_conf_change(
223-
const ConfigProxy& conf,
224-
const std::set<std::string> &changed)
225-
{
226-
mclock_conf.mclock_handle_conf_change(conf, changed);
227-
}
228-
229-
mClockScheduler::~mClockScheduler()
230-
{
231-
cct->_conf.remove_observer(this);
232-
}
233-
234200
}

src/osd/scheduler/mClockScheduler.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace ceph::osd::scheduler {
3838
*
3939
* TODO: explain configs
4040
*/
41-
class mClockScheduler : public OpScheduler, md_config_obs_t {
41+
class mClockScheduler : public OpScheduler {
4242

4343
CephContext *cct;
4444
const unsigned cutoff_priority;
@@ -96,13 +96,7 @@ class mClockScheduler : public OpScheduler, md_config_obs_t {
9696
crimson::dmclock::AtLimit::Wait,
9797
cct->_conf.get_val<double>("osd_mclock_scheduler_anticipation_timeout"))
9898
{
99-
cct->_conf.add_observer(this);
10099
ceph_assert(num_shards > 0);
101-
mclock_conf.set_osd_capacity_params_from_config();
102-
mclock_conf.set_config_defaults_from_profile();
103-
client_registry.update_from_config(
104-
cct->_conf, mclock_conf.get_capacity_per_shard());
105-
106100
if (init_perfcounter) {
107101
mclock_conf.init_logger();
108102
}
@@ -118,7 +112,6 @@ class mClockScheduler : public OpScheduler, md_config_obs_t {
118112
crimson::dmclock::standard_erase_age,
119113
crimson::dmclock::standard_check_time,
120114
monc, init_perfcounter) {}
121-
~mClockScheduler() override;
122115

123116
/// Calculate scaled cost per item
124117
uint32_t calc_scaled_cost(int cost);
@@ -156,10 +149,6 @@ class mClockScheduler : public OpScheduler, md_config_obs_t {
156149
return op_queue_type_t::mClockScheduler;
157150
}
158151

159-
std::vector<std::string> get_tracked_keys() const noexcept final;
160-
void handle_conf_change(const ConfigProxy& conf,
161-
const std::set<std::string> &changed) final;
162-
163152
double get_cost_per_io() const {
164153
return mclock_conf.get_cost_per_io();
165154
}

0 commit comments

Comments
 (0)