]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: add boundary check for pool recovery_priority 26729/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Sat, 2 Mar 2019 01:43:58 +0000 (09:43 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Tue, 5 Mar 2019 00:15:39 +0000 (08:15 +0800)
See https://github.com/ceph/ceph/pull/26705

Fixes: http://tracker.ceph.com/issues/38578
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
qa/workunits/cephtool/test.sh
src/mon/OSDMonitor.cc

index e20d61d34e9c73104bef1f083a5b5ee31bac8f47..bd01614a90fff4386c367acad676fa2651c13295 100755 (executable)
@@ -2012,6 +2012,8 @@ function test_mon_osd_pool_set()
   ceph osd pool get $TEST_POOL_GETSET recovery_priority | grep 'recovery_priority: 5'
   ceph osd pool set $TEST_POOL_GETSET recovery_priority 0
   ceph osd pool get $TEST_POOL_GETSET recovery_priority | expect_false grep '.'
+  expect_false ceph osd pool set $TEST_POOL_GETSET recovery_priority -1
+  expect_false ceph osd pool set $TEST_POOL_GETSET recovery_priority 30
 
   ceph osd pool get $TEST_POOL_GETSET recovery_op_priority | expect_false grep '.'
   ceph osd pool set $TEST_POOL_GETSET recovery_op_priority 5 
index 00d3227202643306c80ec8398dfad4c1520d9c9b..a24b8e8f83cc731c19063f37b164cc564b608ec1 100644 (file)
@@ -7557,6 +7557,19 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap,
           << " > pg_num " << p.get_pg_num_target();
        return -EINVAL;
       }
+    } else if (var == "recovery_priority") {
+      if (interr.length()) {
+        ss << "error parsing int value '" << val << "': " << interr;
+        return -EINVAL;
+      }
+      if (n < 0) {
+        ss << "pool recovery_priority can not be negative";
+        return -EINVAL;
+      } else if (n >= 30) {
+        ss << "pool recovery_priority should be less than 30 due to "
+           << "Ceph internal implementation restrictions";
+        return -EINVAL;
+      }
     }
 
     pool_opts_t::opt_desc_t desc = pool_opts_t::get_opt_desc(var);