From 84bd0dce18f6dd0c35d7e6cfee91ce8c5a0f4db7 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 29 Apr 2016 22:01:56 -0400 Subject: [PATCH] mon/OSDMonitor: max_osds must be > 0 for reweight-by-* Include a few test cases. Signed-off-by: Sage Weil --- qa/workunits/cephtool/test.sh | 5 +++++ src/mon/OSDMonitor.cc | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index d8cb7249bd9..1e18b78111a 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -1625,7 +1625,12 @@ function test_mon_osd_misc() ceph osd reweight-by-utilization 110 ceph osd reweight-by-utilization 110 .5 + expect_false ceph osd reweight-by-utilization 110 0 + expect_false ceph osd reweight-by-utilization 110 -0.1 ceph osd test-reweight-by-utilization 110 .5 --no-increasing + ceph osd test-reweight-by-utilization 110 .5 4 --no-increasing + expect_false ceph osd test-reweight-by-utilization 110 .5 0 --no-increasing + expect_false ceph osd test-reweight-by-utilization 110 .5 -10 --no-increasing ceph osd reweight-by-pg 110 ceph osd test-reweight-by-pg 110 .5 ceph osd reweight-by-pg 110 rbd diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index b7b48927541..a1ec856e6d8 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -7645,6 +7645,11 @@ done: } int64_t max_osds = g_conf->mon_reweight_max_osds; cmd_getval(g_ceph_context, cmdmap, "max_osds", max_osds); + if (max_osds <= 0) { + ss << "max_osds " << max_osds << " must be positive"; + err = -EINVAL; + goto reply; + } string no_increasing; cmd_getval(g_ceph_context, cmdmap, "no_increasing", no_increasing); string out_str;