From 5dd3dff0f61987fea8a2511496ae952ec1b07f52 Mon Sep 17 00:00:00 2001 From: chenhg Date: Sun, 23 Jul 2017 17:21:26 +0800 Subject: [PATCH] OSDMonitor: check mon_max_pool_pg_num when set pool pg_num Check the mon_max_pool_pg_num when creating pools, but did not check in the the modification. So we can create a pool and then modify pg_num exceeds the mon_max_pool_pg_num limit. By following these steps can verify this problem step 1: set mon_max_pool_pg_num = 65536 step 2: ceph osd pool create testpool 65536 65536 step 3: ceph osd pool set testpool pg_num 65537 Signed-off-by: chenhg --- src/mon/OSDMonitor.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 82fd1cfae43..c61ce5d4c53 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -6008,6 +6008,12 @@ int OSDMonitor::prepare_command_pool_set(map &cmdmap, return -EEXIST; return 0; } + if (n > (unsigned)g_conf->mon_max_pool_pg_num) { + ss << "'pg_num' must be greater than 0 and less than or equal to " + << g_conf->mon_max_pool_pg_num + << " (you may adjust 'mon max pool pg num' for higher values)"; + return -ERANGE; + } string force; cmd_getval(g_ceph_context,cmdmap, "force", force); if (p.cache_mode != pg_pool_t::CACHEMODE_NONE && -- 2.39.5