start_boot();
// Override a few options if mclock scheduler is enabled.
- maybe_override_max_osd_capacity_for_qos();
maybe_override_options_for_qos();
+ maybe_override_max_osd_capacity_for_qos();
return 0;
<< " elapsed_sec: " << elapsed
<< dendl;
- // Persist iops to the MON store
- ret = mon_cmd_set_config(max_capacity_iops_config, std::to_string(iops));
- if (ret < 0) {
- // Fallback to setting the config within the in-memory "values" map.
- cct->_conf.set_val(max_capacity_iops_config, std::to_string(iops));
- }
-
- // Override the max osd capacity for all shards
- for (auto& shard : shards) {
- shard->update_scheduler_config();
- }
+ // Persist the iops value to the MON store.
+ mon_cmd_set_config(max_capacity_iops_config, std::to_string(iops));
}
}
return false;
}
-int OSD::mon_cmd_set_config(const std::string &key, const std::string &val)
+/**
+ * A context for receiving status from a background mon command to set
+ * a config option and optionally apply the changes on each op shard.
+ */
+class MonCmdSetConfigOnFinish : public Context {
+ OSD *osd;
+ CephContext *cct;
+ std::string key;
+ std::string val;
+ bool update_shard;
+public:
+ explicit MonCmdSetConfigOnFinish(
+ OSD *o,
+ CephContext *cct,
+ const std::string &k,
+ const std::string &v,
+ const bool s)
+ : osd(o), cct(cct), key(k), val(v), update_shard(s) {}
+ void finish(int r) override {
+ if (r != 0) {
+ // Fallback to setting the config within the in-memory "values" map.
+ cct->_conf.set_val_default(key, val);
+ }
+
+ // If requested, apply this option on the
+ // active scheduler of each op shard.
+ if (update_shard) {
+ for (auto& shard : osd->shards) {
+ shard->update_scheduler_config();
+ }
+ }
+ }
+};
+
+void OSD::mon_cmd_set_config(const std::string &key, const std::string &val)
{
std::string cmd =
"{"
"\"name\": \"" + key + "\", "
"\"value\": \"" + val + "\""
"}";
-
vector<std::string> vcmd{cmd};
- bufferlist inbl;
- std::string outs;
- C_SaferCond cond;
- monc->start_mon_command(vcmd, inbl, nullptr, &outs, &cond);
- int r = cond.wait();
- if (r < 0) {
- derr << __func__ << " Failed to set config key " << key
- << " err: " << cpp_strerror(r)
- << " errstr: " << outs << dendl;
- return r;
- }
- return 0;
+ // List of config options to be distributed across each op shard.
+ // Currently limited to a couple of mClock options.
+ static const std::vector<std::string> shard_option =
+ { "osd_mclock_max_capacity_iops_hdd", "osd_mclock_max_capacity_iops_ssd" };
+ const bool update_shard = std::find(shard_option.begin(),
+ shard_option.end(),
+ key) != shard_option.end();
+
+ auto on_finish = new MonCmdSetConfigOnFinish(this, cct, key,
+ val, update_shard);
+ dout(10) << __func__ << " Set " << key << " = " << val << dendl;
+ monc->start_mon_command(vcmd, {}, nullptr, nullptr, on_finish);
}
bool OSD::unsupported_objstore_for_qos()