From: Sage Weil Date: Wed, 28 Nov 2018 22:55:49 +0000 (-0600) Subject: mon/OSDMonitor: accept optional target_size_{bytes,ratio} to 'osd pool create' X-Git-Tag: v14.1.0~582^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d98bc941bafdda1c2b6364c97a60b1d780e63294;p=ceph.git mon/OSDMonitor: accept optional target_size_{bytes,ratio} to 'osd pool create' Signed-off-by: Sage Weil --- diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 5462ea955cd7..3ae0e7fac5f4 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -941,7 +941,9 @@ COMMAND("osd pool create " \ "name=rule,type=CephString,req=false " \ "name=expected_num_objects,type=CephInt,req=false " \ "name=size,type=CephInt,req=false " \ - "name=pg_num_min,type=CephInt,range=0,req=false", \ + "name=pg_num_min,type=CephInt,range=0,req=false " \ + "name=target_size_bytes,type=CephInt,range=0,req=false " \ + "name=target_size_ratio,type=CephFloat,range=0|1,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 2412f298b1d5..166f2dcd70ff 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, 0, 0, 0.0, erasure_code_profile, pg_pool_t::TYPE_REPLICATED, 0, FAST_READ_OFF, &ss); @@ -6672,6 +6672,8 @@ int OSDMonitor::prepare_new_pool(string& name, unsigned pg_num, unsigned pgp_num, unsigned pg_num_min, const uint64_t repl_size, + const uint64_t target_size_bytes, + const float target_size_ratio, const string &erasure_code_profile, const unsigned pool_type, const uint64_t expected_num_objects, @@ -6817,7 +6819,8 @@ 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) { + if (osdmap.require_osd_release >= CEPH_RELEASE_NAUTILUS && + pg_num_min) { pi->opts.set(pool_opts_t::PG_NUM_MIN, static_cast(pg_num_min)); } @@ -6831,6 +6834,16 @@ int OSDMonitor::prepare_new_pool(string& name, } pi->stripe_width = stripe_width; + if (osdmap.require_osd_release >= CEPH_RELEASE_NAUTILUS && + target_size_bytes) { + // only store for nautilus+ because TARGET_SIZE_BYTES may be + // larger than int32_t max. + pi->opts.set(pool_opts_t::TARGET_SIZE_BYTES, static_cast(target_size_bytes)); + } + if (target_size_ratio > 0.0) { + pi->opts.set(pool_opts_t::TARGET_SIZE_RATIO, target_size_ratio); + } + pi->cache_target_dirty_ratio_micro = g_conf()->osd_pool_default_cache_target_dirty_ratio * 1000000; pi->cache_target_dirty_high_ratio_micro = @@ -11629,12 +11642,16 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, int64_t repl_size = 0; cmd_getval(cct, cmdmap, "size", repl_size); + int64_t target_size_bytes = 0; + double target_size_ratio = 0.0; + cmd_getval(cct, cmdmap, "target_size_bytes", target_size_bytes); + cmd_getval(cct, cmdmap, "target_size_ratio", target_size_ratio); err = prepare_new_pool(poolstr, -1, // default crush rule rule_name, pg_num, pgp_num, pg_num_min, - repl_size, + repl_size, target_size_bytes, target_size_ratio, erasure_code_profile, pool_type, (uint64_t)expected_num_objects, fast_read, diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 442c59090462..29b1a1065ba9 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -457,6 +457,8 @@ private: unsigned pg_num, unsigned pgp_num, unsigned pg_num_min, uint64_t repl_size, + const uint64_t target_size_bytes, + const float target_size_ratio, const string &erasure_code_profile, const unsigned pool_type, const uint64_t expected_num_objects,