]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: add option --pg-num_max arg for create pool
authorSage Weil <sage@newdream.net>
Mon, 22 Nov 2021 21:42:25 +0000 (16:42 -0500)
committerKamoltat <ksirivad@redhat.com>
Wed, 23 Mar 2022 04:27:34 +0000 (04:27 +0000)
Signed-off-by: Sage Weil <sage@newdream.net>
(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 <ksirivad@redhat.com>
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 1b5ee340b022273e91740c19d77b62ecd987004a..592965c1b3967a51f7fda81605600a2029975122 100644 (file)
@@ -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 "
index df04c839d846d4c8b0a05578b820bc771d220b32..bd89a120042f22a2d88ca88d305c4d7cb8106110 100644 (file)
@@ -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<int64_t>(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<int64_t>(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,
index c1f613bf4d36ea07f94cf55680da71d75ad62a6f..e7701a63970ea5bcf7189f1764d5b1f7e7f983ed 100644 (file)
@@ -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,