From: xie xingguo Date: Tue, 11 Sep 2018 08:29:36 +0000 (+0800) Subject: mon/OSDMonitor: reject pg_num -> 0 X-Git-Tag: v14.0.1~306^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F24025%2Fhead;p=ceph.git 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 --- diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index a132fd42af2a8..d88bb65ad9333 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 dc7aefd493ed6..65a4370409ebc 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)";