]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: reject pg_num -> 0 24025/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 11 Sep 2018 08:29:36 +0000 (16:29 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 12 Sep 2018 00:58:10 +0000 (08:58 +0800)
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 <xie.xingguo@zte.com.cn>
qa/workunits/cephtool/test.sh
src/mon/OSDMonitor.cc

index a132fd42af2a84fb24cb08ef0e830daf91d2ac99..d88bb65ad93331517b32d83152f1e90c8fb0fc00 100755 (executable)
@@ -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))
index dc7aefd493ed682bc63394a7fb2556f49b27ba8a..65a4370409ebc464092bc6fff82ce7a5b39cf035 100644 (file)
@@ -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<uint64_t>(n) > g_conf().get_val<uint64_t>("mon_max_pool_pg_num")) {
+    if (n <= 0 || static_cast<uint64_t>(n) >
+                  g_conf().get_val<uint64_t>("mon_max_pool_pg_num")) {
       ss << "'pg_num' must be greater than 0 and less than or equal to "
          << g_conf().get_val<uint64_t>("mon_max_pool_pg_num")
          << " (you may adjust 'mon max pool pg num' for higher values)";