Skip to content

Commit

Permalink
mon/OSDMonitor: add option --pg-num_max arg for create pool
Browse files Browse the repository at this point in the history
Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
liewegas committed Jan 3, 2022
1 parent 2d8753f commit 5945d84
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/mon/MonCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ COMMAND("osd pool create "
"name=expected_num_objects,type=CephInt,range=0,req=false "
"name=size,type=CephInt,range=0,req=false "
"name=pg_num_min,type=CephInt,range=0,req=false "
"name=pg_num_max,type=CephInt,range=0,req=false "
"name=autoscale_mode,type=CephChoices,strings=on|off|warn,req=false "
"name=bulk,type=CephBool,req=false "
"name=target_size_bytes,type=CephInt,range=0,req=false "
Expand Down
12 changes: 10 additions & 2 deletions src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7264,7 +7264,7 @@ int OSDMonitor::prepare_new_pool(MonOpRequestRef op)
bool bulk = false;
int ret = 0;
ret = prepare_new_pool(m->name, m->crush_rule, rule_name,
0, 0, 0, 0, 0, 0.0,
0, 0, 0, 0, 0, 0, 0.0,
erasure_code_profile,
pg_pool_t::TYPE_REPLICATED, 0, FAST_READ_OFF, {}, bulk,
&ss);
Expand Down Expand Up @@ -7866,6 +7866,8 @@ int OSDMonitor::check_pg_num(int64_t pool, int pg_num, int size, int crush_rule,
* @param crush_rule_name The crush rule to use, if crush_rulset <0
* @param pg_num The pg_num to use. If set to 0, will use the system default
* @param pgp_num The pgp_num to use. If set to 0, will use the system default
* @param pg_num_min min pg_num
* @param pg_num_max max pg_num
* @param repl_size Replication factor, or 0 for default
* @param erasure_code_profile The profile name in OSDMap to be used for erasure code
* @param pool_type TYPE_ERASURE, or TYPE_REP
Expand All @@ -7880,6 +7882,7 @@ int OSDMonitor::prepare_new_pool(string& name,
const string &crush_rule_name,
unsigned pg_num, unsigned pgp_num,
unsigned pg_num_min,
unsigned pg_num_max,
const uint64_t repl_size,
const uint64_t target_size_bytes,
const float target_size_ratio,
Expand Down Expand Up @@ -8068,6 +8071,10 @@ int OSDMonitor::prepare_new_pool(string& name,
pg_num_min) {
pi->opts.set(pool_opts_t::PG_NUM_MIN, static_cast<int64_t>(pg_num_min));
}
if (osdmap.require_osd_release >= ceph_release_t::quincy &&
pg_num_max) {
pi->opts.set(pool_opts_t::PG_NUM_MAX, static_cast<int64_t>(pg_num_max));
}
if (auto m = pg_pool_t::get_pg_autoscale_mode_by_name(
pg_autoscale_mode); m != pg_pool_t::pg_autoscale_mode_t::UNKNOWN) {
pi->pg_autoscale_mode = m;
Expand Down Expand Up @@ -12750,6 +12757,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
} else if (prefix == "osd pool create") {
int64_t pg_num = cmd_getval_or<int64_t>(cmdmap, "pg_num", 0);
int64_t pg_num_min = cmd_getval_or<int64_t>(cmdmap, "pg_num_min", 0);
int64_t pg_num_max = cmd_getval_or<int64_t>(cmdmap, "pg_num_max", 0);
int64_t pgp_num = cmd_getval_or<int64_t>(cmdmap, "pgp_num", pg_num);
string pool_type_str;
cmd_getval(cmdmap, "pool_type", pool_type_str);
Expand Down Expand Up @@ -12916,7 +12924,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
err = prepare_new_pool(poolstr,
-1, // default crush rule
rule_name,
pg_num, pgp_num, pg_num_min,
pg_num, pgp_num, pg_num_min, pg_num_max,
repl_size, target_size_bytes, target_size_ratio,
erasure_code_profile, pool_type,
(uint64_t)expected_num_objects,
Expand Down
1 change: 1 addition & 0 deletions src/mon/OSDMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ class OSDMonitor : public PaxosService,
const std::string &crush_rule_name,
unsigned pg_num, unsigned pgp_num,
unsigned pg_num_min,
unsigned pg_num_max,
uint64_t repl_size,
const uint64_t target_size_bytes,
const float target_size_ratio,
Expand Down

0 comments on commit 5945d84

Please sign in to comment.