]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon/OSDMonitor: accept optional target_size_{bytes,ratio} to 'osd pool create'
authorSage Weil <sage@redhat.com>
Wed, 28 Nov 2018 22:55:49 +0000 (16:55 -0600)
committerSage Weil <sage@redhat.com>
Tue, 18 Dec 2018 19:30:54 +0000 (13:30 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 5462ea955cd766726fda37745b9379550f8b7832..3ae0e7fac5f49e422c0f5afc2464c72a6c609fa1 100644 (file)
@@ -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 " \
index 2412f298b1d55433c9bd5cd97fa43c40a76af061..166f2dcd70ffe88b55a77365de3f2aa1bdab27c4 100644 (file)
@@ -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<int64_t>(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<int64_t>(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,
index 442c59090462ed20fc85bdc404d5896b7a870f3e..29b1a1065ba9770ee69543b116a32219d88f8b8a 100644 (file)
@@ -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,