From 7b5c8511c960bfe009b64b0f5a1e2f218eff9616 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 28 Nov 2018 15:28:56 -0600 Subject: [PATCH] mon/OSDMonitor: accept optional pg_num_min to 'osd pool create' Signed-off-by: Sage Weil --- src/mon/MonCommands.h | 3 ++- src/mon/OSDMonitor.cc | 16 +++++++++++++--- src/mon/OSDMonitor.h | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 4606ced6cd2..5462ea955cd 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -940,7 +940,8 @@ COMMAND("osd pool create " \ "name=erasure_code_profile,type=CephString,req=false,goodchars=[A-Za-z0-9-_.] " \ "name=rule,type=CephString,req=false " \ "name=expected_num_objects,type=CephInt,req=false " \ - "name=size,type=CephInt,req=false", \ + "name=size,type=CephInt,req=false " \ + "name=pg_num_min,type=CephInt,range=0,req=false", \ "create pool", "osd", "rw") COMMAND_WITH_FLAG("osd pool delete " \ "name=pool,type=CephPoolname " \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index a8327b853c5..9b90f19d316 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -6148,7 +6148,7 @@ int OSDMonitor::prepare_new_pool(MonOpRequestRef op) string rule_name; int ret = 0; ret = prepare_new_pool(m->name, m->crush_rule, rule_name, - 0, 0, 0, + 0, 0, 0, 0, erasure_code_profile, pg_pool_t::TYPE_REPLICATED, 0, FAST_READ_OFF, &ss); @@ -6670,6 +6670,7 @@ int OSDMonitor::prepare_new_pool(string& name, int crush_rule, const string &crush_rule_name, unsigned pg_num, unsigned pgp_num, + unsigned pg_num_min, const uint64_t repl_size, const string &erasure_code_profile, const unsigned pool_type, @@ -6802,6 +6803,7 @@ int OSDMonitor::prepare_new_pool(string& name, pi->crush_rule = crush_rule; pi->expected_num_objects = expected_num_objects; pi->object_hash = CEPH_STR_HASH_RJENKINS; + { auto m = pg_pool_t::get_pg_autoscale_mode_by_name( g_conf().get_val("osd_pool_default_pg_autoscale_mode")); @@ -6815,14 +6817,20 @@ int OSDMonitor::prepare_new_pool(string& name, pi->set_pg_num_target(pg_num); pi->set_pgp_num(pi->get_pg_num()); pi->set_pgp_num_target(pgp_num); + if (pg_num_min) { + pi->opts.set(pool_opts_t::PG_NUM_MIN, static_cast(pg_num_min)); + } + pi->last_change = pending_inc.epoch; pi->auid = 0; + if (pool_type == pg_pool_t::TYPE_ERASURE) { pi->erasure_code_profile = erasure_code_profile; } else { pi->erasure_code_profile = ""; } pi->stripe_width = stripe_width; + pi->cache_target_dirty_ratio_micro = g_conf()->osd_pool_default_cache_target_dirty_ratio * 1000000; pi->cache_target_dirty_high_ratio_micro = @@ -6831,6 +6839,7 @@ int OSDMonitor::prepare_new_pool(string& name, g_conf()->osd_pool_default_cache_target_full_ratio * 1000000; pi->cache_min_flush_age = g_conf()->osd_pool_default_cache_min_flush_age; pi->cache_min_evict_age = g_conf()->osd_pool_default_cache_min_evict_age; + pending_inc.new_pool_names[pool] = name; return 0; } @@ -11485,10 +11494,11 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, get_last_committed() + 1)); return true; } else if (prefix == "osd pool create") { - int64_t pg_num; + int64_t pg_num, pg_num_min; int64_t pgp_num; cmd_getval(cct, cmdmap, "pg_num", pg_num, int64_t(0)); cmd_getval(cct, cmdmap, "pgp_num", pgp_num, pg_num); + cmd_getval(cct, cmdmap, "pg_num_min", pg_num_min, int64_t(0)); string pool_type_str; cmd_getval(cct, cmdmap, "pool_type", pool_type_str); @@ -11632,7 +11642,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, pgp_num, pg_num_min, repl_size, erasure_code_profile, pool_type, (uint64_t)expected_num_objects, diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index efb0589d89c..442c5909046 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -455,6 +455,7 @@ private: int crush_rule, const string &crush_rule_name, unsigned pg_num, unsigned pgp_num, + unsigned pg_num_min, uint64_t repl_size, const string &erasure_code_profile, const unsigned pool_type, -- 2.39.5