From: Sage Weil Date: Mon, 22 Nov 2021 21:42:25 +0000 (-0500) Subject: mon/OSDMonitor: add option --pg-num_max arg for create pool X-Git-Tag: v16.2.8~44^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=12bef02faa4a3621f821c653e52741f96cfa94d1;p=ceph.git mon/OSDMonitor: add option --pg-num_max arg for create pool Signed-off-by: Sage Weil (cherry picked from commit 5945d8453b26f68929e546c220d0ae7067869a51) Conflicts: src/mon/OSDMonitor.cc - change from quincy to pacific osd_release - use cmd_getval instead of cmd_getval_or. Signed-off-by: Kamoltat --- diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 1b5ee340b0222..592965c1b3967 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -1083,6 +1083,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 " diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index df04c839d846d..bd89a120042f2 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -7337,7 +7337,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); @@ -7908,6 +7908,8 @@ int OSDMonitor::check_pg_num(int64_t pool, int pg_num, int size, ostream *ss) * @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 @@ -7922,6 +7924,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, @@ -8100,6 +8103,10 @@ int OSDMonitor::prepare_new_pool(string& name, pg_num_min) { pi->opts.set(pool_opts_t::PG_NUM_MIN, static_cast(pg_num_min)); } + if (osdmap.require_osd_release >= ceph_release_t::pacific && + pg_num_max) { + pi->opts.set(pool_opts_t::PG_NUM_MAX, static_cast(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; @@ -12809,12 +12816,11 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, get_last_committed() + 1)); return true; } else if (prefix == "osd pool create") { - int64_t pg_num, pg_num_min; - int64_t pgp_num; + int64_t pg_num, pgp_num, pg_num_min, pg_num_max; cmd_getval(cmdmap, "pg_num", pg_num, int64_t(0)); - cmd_getval(cmdmap, "pgp_num", pgp_num, pg_num); cmd_getval(cmdmap, "pg_num_min", pg_num_min, int64_t(0)); - + cmd_getval(cmdmap, "pg_num_max", pg_num_max, int64_t(0)); + cmd_getval(cmdmap, "pgp_num", pgp_num, int64_t(pg_num)); string pool_type_str; cmd_getval(cmdmap, "pool_type", pool_type_str); if (pool_type_str.empty()) @@ -12982,7 +12988,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, diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index c1f613bf4d36e..e7701a63970ea 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -520,6 +520,7 @@ private: 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,