Implement "no_recovery" and "no_rebalance" flags

pull/5/head
Vitaliy Filippov 2021-03-11 00:36:23 +03:00
parent 0d2efbecc9
commit af5155fcd9
4 changed files with 33 additions and 16 deletions

View File

@ -47,6 +47,8 @@ const etcd_tree = {
client_dirty_limit: 33554432,
peer_connect_interval: 5, // seconds. min: 1
peer_connect_timeout: 5, // seconds. min: 1
osd_idle_timeout: 5, // seconds. min: 1
osd_ping_timeout: 5, // seconds. min: 1
up_wait_retry_interval: 500, // ms. min: 50
// osd
etcd_report_interval: 30, // min: 10
@ -57,7 +59,10 @@ const etcd_tree = {
client_queue_depth: 128, // unused
recovery_queue_depth: 4,
readonly: false,
no_recovery: false,
no_rebalance: false,
print_stats_interval: 3,
slow_log_interval: 10,
// blockstore - fixed in superblock
block_size,
disk_alignment,
@ -77,6 +82,7 @@ const etcd_tree = {
disable_meta_fsync,
disable_device_lock,
// blockstore - configurable
max_write_iodepth,
flusher_count,
inmemory_metadata,
inmemory_journal,

View File

@ -54,11 +54,12 @@ osd_t::~osd_t()
void osd_t::parse_config(blockstore_config_t & config)
{
if (config.find("log_level") == config.end())
config["log_level"] = "1";
// Initial startup configuration
json11::Json json_config = json11::Json(config);
st_cli.parse_config(json_config);
if (config.find("log_level") == config.end())
config["log_level"] = "1";
log_level = strtoull(config["log_level"].c_str(), NULL, 10);
etcd_report_interval = strtoull(config["etcd_report_interval"].c_str(), NULL, 10);
if (etcd_report_interval <= 0)
etcd_report_interval = 30;
@ -67,6 +68,8 @@ void osd_t::parse_config(blockstore_config_t & config)
throw std::runtime_error("osd_num is required in the configuration");
c_cli.osd_num = osd_num;
run_primary = config["run_primary"] != "false" && config["run_primary"] != "0" && config["run_primary"] != "no";
no_rebalance = config["no_rebalance"] == "true" || config["no_rebalance"] == "1" || config["no_rebalance"] == "yes";
no_recovery = config["no_recovery"] == "true" || config["no_recovery"] == "1" || config["no_recovery"] == "yes";
// Cluster configuration
bind_address = config["bind_address"];
if (bind_address == "")

View File

@ -64,6 +64,8 @@ class osd_t
bool readonly = false;
osd_num_t osd_num = 1; // OSD numbers start with 1
bool run_primary = false;
bool no_rebalance = false;
bool no_recovery = false;
std::string bind_address;
int bind_port, listen_backlog;
// FIXME: Implement client queue depth limit

View File

@ -209,6 +209,8 @@ void osd_t::submit_flush_op(pool_id_t pool_id, pg_num_t pg_num, pg_flush_batch_t
bool osd_t::pick_next_recovery(osd_recovery_op_t &op)
{
if (!no_recovery)
{
for (auto pg_it = pgs.begin(); pg_it != pgs.end(); pg_it++)
{
if ((pg_it->second.state & (PG_ACTIVE | PG_HAS_DEGRADED)) == (PG_ACTIVE | PG_HAS_DEGRADED))
@ -224,6 +226,9 @@ bool osd_t::pick_next_recovery(osd_recovery_op_t &op)
}
}
}
}
if (!no_rebalance)
{
for (auto pg_it = pgs.begin(); pg_it != pgs.end(); pg_it++)
{
if ((pg_it->second.state & (PG_ACTIVE | PG_HAS_MISPLACED)) == (PG_ACTIVE | PG_HAS_MISPLACED))
@ -239,6 +244,7 @@ bool osd_t::pick_next_recovery(osd_recovery_op_t &op)
}
}
}
}
return false;
}