From: Kamoltat Date: Mon, 19 Apr 2021 19:29:30 +0000 (+0000) Subject: mon/OSDMonitor: prepare_new_pool() starts out with 1 pg X-Git-Tag: v17.1.0~1934^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2bdc220dfb66a4743c2c1d451d03df5d7aa990cc;p=ceph.git mon/OSDMonitor: prepare_new_pool() starts out with 1 pg 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 --- diff --git a/src/common/options/global.yaml.in b/src/common/options/global.yaml.in index e0836379ac00..f826a4a5f9fb 100644 --- a/src/common/options/global.yaml.in +++ b/src/common/options/global.yaml.in @@ -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' diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 08ea6b2f3994..95bb1bc7a685 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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("osd_pool_default_pg_num"); + if (pg_num == 0) { + auto pg_num_from_mode = + [pg_num=g_conf().get_val("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("osd_pool_default_pg_autoscale_mode") : + pg_autoscale_mode); + } if (pgp_num == 0) pgp_num = g_conf().get_val("osd_pool_default_pgp_num"); if (!pgp_num)