From 6d8d20a55b25f05acacb5b29830644fa7b1a8894 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Tue, 11 Sep 2018 16:29:36 +0800 Subject: [PATCH] mon/OSDMonitor: reject pg_num -> 0 Otherwise it will finally crash the mgr process: ``` -2> 2018-09-11 16:23:31.272 7ff521d59700 -1 /clove/xxG/ceph/src/osd/osd_types.cc: In function 'pg_t pg_t::get_parent() const' thread 7ff521d59700 time 2018-09-11 16:23:31.272096 /clove/xxG/ceph/src/osd/osd_types.cc: 587: FAILED ceph_assert(bits) ``` Signed-off-by: xie xingguo --- qa/workunits/cephtool/test.sh | 2 ++ src/mon/OSDMonitor.cc | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index a132fd42af2..d88bb65ad93 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -2019,6 +2019,8 @@ function test_mon_osd_pool_set() ceph osd pool set $TEST_POOL_GETSET pg_num 10 wait_for_clean ceph osd pool set $TEST_POOL_GETSET pgp_num 10 + expect_false ceph osd pool set $TEST_POOL_GETSET pg_num 0 + expect_false ceph osd pool set $TEST_POOL_GETSET pgp_num 0 old_pgs=$(ceph osd pool get $TEST_POOL_GETSET pg_num | sed -e 's/pg_num: //') new_pgs=$(($old_pgs + $(ceph osd stat --format json | jq '.num_osds') * 32)) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index dc7aefd493e..65a4370409e 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -6919,7 +6919,8 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap, if (n == (int)p.get_pg_num_target()) { return 0; } - if (static_cast(n) > g_conf().get_val("mon_max_pool_pg_num")) { + if (n <= 0 || static_cast(n) > + g_conf().get_val("mon_max_pool_pg_num")) { ss << "'pg_num' must be greater than 0 and less than or equal to " << g_conf().get_val("mon_max_pool_pg_num") << " (you may adjust 'mon max pool pg num' for higher values)"; -- 2.39.5