From 5945d8453b26f68929e546c220d0ae7067869a51 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 22 Nov 2021 16:42:25 -0500 Subject: [PATCH] mon/OSDMonitor: add option --pg-num_max arg for create pool Signed-off-by: Sage Weil --- src/mon/MonCommands.h | 1 + src/mon/OSDMonitor.cc | 12 ++++++++++-- src/mon/OSDMonitor.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 1613f457df5a0..31a2d11aa49ba 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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 " diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index a565ddac95f22..ab9c53c060a35 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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); @@ -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 @@ -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, @@ -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(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(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; @@ -12750,6 +12757,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else if (prefix == "osd pool create") { int64_t pg_num = cmd_getval_or(cmdmap, "pg_num", 0); int64_t pg_num_min = cmd_getval_or(cmdmap, "pg_num_min", 0); + int64_t pg_num_max = cmd_getval_or(cmdmap, "pg_num_max", 0); int64_t pgp_num = cmd_getval_or(cmdmap, "pgp_num", pg_num); string pool_type_str; cmd_getval(cmdmap, "pool_type", pool_type_str); @@ -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, diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index aa789e2e26255..faa5620e3a560 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, -- 2.39.5