Skip to content

Commit

Permalink
mon/OSDMonitor: more options in new-style
Browse files Browse the repository at this point in the history
Signed-off-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Oct 24, 2017
1 parent ca1d956 commit fdc0183
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 44 deletions.
10 changes: 0 additions & 10 deletions src/common/legacy_config_opts.h
Expand Up @@ -345,7 +345,6 @@ OPTION(mon_client_ping_timeout, OPT_DOUBLE) // fail if we don't hear back
OPTION(mon_client_hunt_interval_backoff, OPT_DOUBLE) // each time we reconnect to a monitor, double our timeout
OPTION(mon_client_hunt_interval_max_multiple, OPT_DOUBLE) // up to a max of 10*default (30 seconds)
OPTION(mon_client_max_log_entries_per_message, OPT_INT)
OPTION(mon_max_pool_pg_num, OPT_INT)
OPTION(mon_pool_quota_warn_threshold, OPT_INT) // percent of quota at which to issue warnings
OPTION(mon_pool_quota_crit_threshold, OPT_INT) // percent of quota at which to issue errors
OPTION(client_cache_size, OPT_INT)
Expand Down Expand Up @@ -604,7 +603,6 @@ OPTION(osd_pool_use_gmt_hitset, OPT_BOOL) // try to use gmt for hitset archive n
OPTION(osd_crush_update_on_start, OPT_BOOL)
OPTION(osd_class_update_on_start, OPT_BOOL) // automatically set device class on start
OPTION(osd_crush_initial_weight, OPT_DOUBLE) // if >=0, the initial weight is for newly added osds.
OPTION(osd_pool_erasure_code_stripe_unit, OPT_U32) // in bytes
OPTION(osd_erasure_code_plugins, OPT_STR) // list of erasure code plugins

// Allows the "peered" state for recovery and backfill below min_size
Expand All @@ -630,14 +628,6 @@ OPTION(osd_hit_set_namespace, OPT_STR) // rados namespace for hit_set tracking
OPTION(osd_tier_promote_max_objects_sec, OPT_U64)
OPTION(osd_tier_promote_max_bytes_sec, OPT_U64)

OPTION(osd_tier_default_cache_mode, OPT_STR)
OPTION(osd_tier_default_cache_hit_set_count, OPT_INT)
OPTION(osd_tier_default_cache_hit_set_period, OPT_INT)
OPTION(osd_tier_default_cache_hit_set_type, OPT_STR)
OPTION(osd_tier_default_cache_min_read_recency_for_promote, OPT_INT) // number of recent HitSets the object must appear in to be promoted (on read)
OPTION(osd_tier_default_cache_min_write_recency_for_promote, OPT_INT) // number of recent HitSets the object must appear in to be promoted (on write)
OPTION(osd_tier_default_cache_hit_set_grade_decay_rate, OPT_INT)
OPTION(osd_tier_default_cache_hit_set_search_last_n, OPT_INT)
OPTION(osd_objecter_finishers, OPT_INT)

OPTION(osd_map_dedup, OPT_BOOL)
Expand Down
30 changes: 18 additions & 12 deletions src/common/options.cc
Expand Up @@ -1503,7 +1503,7 @@ std::vector<Option> get_global_options() {
.set_default(1000)
.set_description(""),

Option("mon_max_pool_pg_num", Option::TYPE_INT, Option::LEVEL_ADVANCED)
Option("mon_max_pool_pg_num", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(65536)
.set_description(""),

Expand Down Expand Up @@ -1715,7 +1715,8 @@ std::vector<Option> get_global_options() {

Option("osd_pool_erasure_code_stripe_unit", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(4_K)
.set_description(""),
.set_description("the amount of data (in bytes) in a data chunk, per stripe")
.add_service("mon"),

Option("osd_pool_default_size", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(3)
Expand Down Expand Up @@ -1743,7 +1744,8 @@ std::vector<Option> get_global_options() {
Option("osd_pool_default_type", Option::TYPE_STR, Option::LEVEL_ADVANCED)
.set_default("replicated")
.set_enum_allowed({"replicated", "erasure"})
.set_description(""),
.set_description("")
.add_service("mon"),

Option("osd_pool_default_erasure_code_profile", Option::TYPE_STR, Option::LEVEL_ADVANCED)
.set_default("plugin=jerasure technique=reed_sol_van k=2 m=1")
Expand Down Expand Up @@ -1783,7 +1785,8 @@ std::vector<Option> get_global_options() {

Option("osd_pool_default_hit_set_bloom_fpp", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
.set_default(.05)
.set_description(""),
.set_description("")
.add_see_also("osd_tier_default_cache_hit_set_type"),

Option("osd_pool_default_cache_target_dirty_ratio", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
.set_default(.4)
Expand Down Expand Up @@ -1831,33 +1834,36 @@ std::vector<Option> get_global_options() {

Option("osd_tier_default_cache_mode", Option::TYPE_STR, Option::LEVEL_ADVANCED)
.set_default("writeback")
.set_enum_allowed({"none", "writeback", "forward",
"readonly", "readforward", "readproxy", "proxy"})
.set_description(""),

Option("osd_tier_default_cache_hit_set_count", Option::TYPE_INT, Option::LEVEL_ADVANCED)
Option("osd_tier_default_cache_hit_set_count", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(4)
.set_description(""),

Option("osd_tier_default_cache_hit_set_period", Option::TYPE_INT, Option::LEVEL_ADVANCED)
Option("osd_tier_default_cache_hit_set_period", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(1200)
.set_description(""),

Option("osd_tier_default_cache_hit_set_type", Option::TYPE_STR, Option::LEVEL_ADVANCED)
.set_default("bloom")
.set_enum_allowed({"bloom", "explicit_hash", "explicit_object"})
.set_description(""),

Option("osd_tier_default_cache_min_read_recency_for_promote", Option::TYPE_INT, Option::LEVEL_ADVANCED)
Option("osd_tier_default_cache_min_read_recency_for_promote", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(1)
.set_description(""),
.set_description("number of recent HitSets the object must appear in to be promoted (on read)"),

Option("osd_tier_default_cache_min_write_recency_for_promote", Option::TYPE_INT, Option::LEVEL_ADVANCED)
Option("osd_tier_default_cache_min_write_recency_for_promote", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(1)
.set_description(""),
.set_description("number of recent HitSets the object must appear in to be promoted (on write)"),

Option("osd_tier_default_cache_hit_set_grade_decay_rate", Option::TYPE_INT, Option::LEVEL_ADVANCED)
Option("osd_tier_default_cache_hit_set_grade_decay_rate", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(20)
.set_description(""),

Option("osd_tier_default_cache_hit_set_search_last_n", Option::TYPE_INT, Option::LEVEL_ADVANCED)
Option("osd_tier_default_cache_hit_set_search_last_n", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(1)
.set_description(""),

Expand Down
41 changes: 21 additions & 20 deletions src/mon/OSDMonitor.cc
Expand Up @@ -5300,7 +5300,7 @@ int OSDMonitor::prepare_pool_stripe_width(const unsigned pool_type,
if (err)
break;
uint32_t data_chunks = erasure_code->get_data_chunk_count();
uint32_t stripe_unit = g_conf->osd_pool_erasure_code_stripe_unit;
uint32_t stripe_unit = g_conf->get_val<uint64_t>("osd_pool_erasure_code_stripe_unit");
auto it = profile.find("stripe_unit");
if (it != profile.end()) {
string err_str;
Expand Down Expand Up @@ -5471,9 +5471,9 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid,
pg_num = g_conf->get_val<uint64_t>("osd_pool_default_pg_num");
if (pgp_num == 0)
pgp_num = g_conf->get_val<uint64_t>("osd_pool_default_pgp_num");
if (pg_num > (unsigned)g_conf->mon_max_pool_pg_num) {
if (pg_num > g_conf->get_val<uint64_t>("mon_max_pool_pg_num")) {
*ss << "'pg_num' must be greater than 0 and less than or equal to "
<< g_conf->mon_max_pool_pg_num
<< g_conf->get_val<uint64_t>("mon_max_pool_pg_num")
<< " (you may adjust 'mon max pool pg num' for higher values)";
return -ERANGE;
}
Expand Down Expand Up @@ -5761,9 +5761,9 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
return -EEXIST;
return 0;
}
if (n > (unsigned)g_conf->mon_max_pool_pg_num) {
if (static_cast<uint64_t>(n) > g_conf->get_val<uint64_t>("mon_max_pool_pg_num")) {
ss << "'pg_num' must be greater than 0 and less than or equal to "
<< g_conf->mon_max_pool_pg_num
<< g_conf->get_val<uint64_t>("mon_max_pool_pg_num")
<< " (you may adjust 'mon max pool pg num' for higher values)";
return -ERANGE;
}
Expand Down Expand Up @@ -5864,7 +5864,7 @@ int OSDMonitor::prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
return err;
if (val == "bloom") {
BloomHitSet::Params *bsp = new BloomHitSet::Params;
bsp->set_fpp(g_conf->osd_pool_default_hit_set_bloom_fpp);
bsp->set_fpp(g_conf->get_val<double>("osd_pool_default_hit_set_bloom_fpp"));
p.hit_set_params = HitSet::Params(bsp);
} else if (val == "explicit_hash")
p.hit_set_params = HitSet::Params(new ExplicitHashHitSet::Params);
Expand Down Expand Up @@ -10530,26 +10530,27 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
err = -ENOTEMPTY;
goto reply;
}
string modestr = g_conf->osd_tier_default_cache_mode;
auto& modestr = g_conf->get_val<string>("osd_tier_default_cache_mode");
pg_pool_t::cache_mode_t mode = pg_pool_t::get_cache_mode_from_str(modestr);
if (mode < 0) {
ss << "osd tier cache default mode '" << modestr << "' is not a valid cache mode";
err = -EINVAL;
goto reply;
}
HitSet::Params hsp;
if (g_conf->osd_tier_default_cache_hit_set_type == "bloom") {
auto& cache_hit_set_type =
g_conf->get_val<string>("osd_tier_default_cache_hit_set_type");
if (cache_hit_set_type == "bloom") {
BloomHitSet::Params *bsp = new BloomHitSet::Params;
bsp->set_fpp(g_conf->osd_pool_default_hit_set_bloom_fpp);
bsp->set_fpp(g_conf->get_val<double>("osd_pool_default_hit_set_bloom_fpp"));
hsp = HitSet::Params(bsp);
} else if (g_conf->osd_tier_default_cache_hit_set_type == "explicit_hash") {
} else if (cache_hit_set_type == "explicit_hash") {
hsp = HitSet::Params(new ExplicitHashHitSet::Params);
}
else if (g_conf->osd_tier_default_cache_hit_set_type == "explicit_object") {
} else if (cache_hit_set_type == "explicit_object") {
hsp = HitSet::Params(new ExplicitObjectHitSet::Params);
} else {
ss << "osd tier cache default hit set type '" <<
g_conf->osd_tier_default_cache_hit_set_type << "' is not a known type";
ss << "osd tier cache default hit set type '"
<< cache_hit_set_type << "' is not a known type";
err = -EINVAL;
goto reply;
}
Expand All @@ -10567,12 +10568,12 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
ntp->set_last_force_op_resend(pending_inc.epoch);
ntp->tier_of = pool_id;
ntp->cache_mode = mode;
ntp->hit_set_count = g_conf->osd_tier_default_cache_hit_set_count;
ntp->hit_set_period = g_conf->osd_tier_default_cache_hit_set_period;
ntp->min_read_recency_for_promote = g_conf->osd_tier_default_cache_min_read_recency_for_promote;
ntp->min_write_recency_for_promote = g_conf->osd_tier_default_cache_min_write_recency_for_promote;
ntp->hit_set_grade_decay_rate = g_conf->osd_tier_default_cache_hit_set_grade_decay_rate;
ntp->hit_set_search_last_n = g_conf->osd_tier_default_cache_hit_set_search_last_n;
ntp->hit_set_count = g_conf->get_val<uint64_t>("osd_tier_default_cache_hit_set_count");
ntp->hit_set_period = g_conf->get_val<uint64_t>("osd_tier_default_cache_hit_set_period");
ntp->min_read_recency_for_promote = g_conf->get_val<uint64_t>("osd_tier_default_cache_min_read_recency_for_promote");
ntp->min_write_recency_for_promote = g_conf->get_val<uint64_t>("osd_tier_default_cache_min_write_recency_for_promote");
ntp->hit_set_grade_decay_rate = g_conf->get_val<uint64_t>("osd_tier_default_cache_hit_set_grade_decay_rate");
ntp->hit_set_search_last_n = g_conf->get_val<uint64_t>("osd_tier_default_cache_hit_set_search_last_n");
ntp->hit_set_params = hsp;
ntp->target_max_bytes = size;
ss << "pool '" << tierpoolstr << "' is now (or already was) a cache tier of '" << poolstr << "'";
Expand Down
4 changes: 2 additions & 2 deletions src/test/erasure-code/TestErasureCodeLrc.cc
Expand Up @@ -615,7 +615,7 @@ TEST(ErasureCodeLrc, encode_decode)
profile["layers"] = description_string;
EXPECT_EQ(0, lrc.init(profile, &cerr));
EXPECT_EQ(4U, lrc.get_data_chunk_count());
unsigned int chunk_size = g_conf->osd_pool_erasure_code_stripe_unit;
unsigned int chunk_size = g_conf->get_val<uint64_t>("osd_pool_erasure_code_stripe_unit");
unsigned int stripe_width = lrc.get_data_chunk_count() * chunk_size;
EXPECT_EQ(chunk_size, lrc.get_chunk_size(stripe_width));
set<int> want_to_encode;
Expand Down Expand Up @@ -745,7 +745,7 @@ TEST(ErasureCodeLrc, encode_decode_2)
profile["layers"] = description_string;
EXPECT_EQ(0, lrc.init(profile, &cerr));
EXPECT_EQ(4U, lrc.get_data_chunk_count());
unsigned int chunk_size = g_conf->osd_pool_erasure_code_stripe_unit;
unsigned int chunk_size = g_conf->get_val<uint64_t>("osd_pool_erasure_code_stripe_unit");
unsigned int stripe_width = lrc.get_data_chunk_count() * chunk_size;
EXPECT_EQ(chunk_size, lrc.get_chunk_size(stripe_width));
set<int> want_to_encode;
Expand Down

0 comments on commit fdc0183

Please sign in to comment.