]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: prepare_new_pool() starts out with 1 pg 40921/head
authorKamoltat <ksirivad@redhat.com>
Mon, 19 Apr 2021 19:29:30 +0000 (19:29 +0000)
committerKamoltat <ksirivad@redhat.com>
Fri, 23 Apr 2021 14:39:42 +0000 (14:39 +0000)
Starts a new pool with 1 pg if the autoscale mode is `on`.
If user didn't explicitly specify autoscale mode to be `on`,
we look at the default_autoscale_mode value that is set globally,
if that is `on` then we also start new pool with 1 pg. Else,
just use the default pg value.

Updated `common/options/global.yaml.in` to document the change.

Fixes: https://tracker.ceph.com/issues/49364
Signed-off-by: Kamoltat <ksirivad@redhat.com>
src/common/options/global.yaml.in
src/mon/OSDMonitor.cc

index e0836379ac00f4f614c2049844027355bc241604..f826a4a5f9fbfca775a143f0a7159141df0b7210 100644 (file)
@@ -3980,9 +3980,14 @@ options:
   desc: number of PGs for new pools
   fmt_desc: The default number of placement groups for a pool. The default
     value is the same as ``pg_num`` with ``mkpool``.
+  long_desc: With default value of `osd_pool_default_pg_autoscale_mode` being 
+    `on` the number of PGs for new pools will start out with 1 pg, unless the 
+    user specifies the pg_num.
   default: 32
   services:
   - mon
+  see_also: 
+  - osd_pool_default_pg_autoscale_mode
   flags:
   - runtime
 - name: osd_pool_default_pgp_num
@@ -4131,6 +4136,8 @@ options:
   type: str
   level: advanced
   desc: Default PG autoscaling behavior for new pools
+  long_desc: With default value `on`, the autoscaler starts a new pool with 1
+    pg, unless the user specifies the pg_num.
   default: 'on'
   enum_values:
   - 'off'
index 08ea6b2f39949e348d213735c1a1b2cdaf9bf933..95bb1bc7a685ab006b14dbb40ff629c1df3cfee3 100644 (file)
@@ -7831,8 +7831,17 @@ int OSDMonitor::prepare_new_pool(string& name,
 {
   if (name.length() == 0)
     return -EINVAL;
-  if (pg_num == 0)
-    pg_num = g_conf().get_val<uint64_t>("osd_pool_default_pg_num");
+  if (pg_num == 0) {
+    auto pg_num_from_mode =
+      [pg_num=g_conf().get_val<uint64_t>("osd_pool_default_pg_num")]
+      (const string& mode) {
+      return mode == "on" ? 1 : pg_num;
+    };
+    pg_num = pg_num_from_mode(
+      pg_autoscale_mode.empty() ?
+      g_conf().get_val<string>("osd_pool_default_pg_autoscale_mode") :
+      pg_autoscale_mode);
+  }
   if (pgp_num == 0)
     pgp_num = g_conf().get_val<uint64_t>("osd_pool_default_pgp_num");
   if (!pgp_num)