From 0d249a0fc6a7d846e04bc786c47f4811ccee9764 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Wed, 23 Aug 2017 11:31:35 +0800 Subject: [PATCH] mon/OSDMonitor: fix improper input/testing range of crush somke testing CrushTester::test() will reset testing range to [0, 1023] whenever min_x or max_x is negative and the constructor of CrushTester will always default min_x and max_x to -1. Thus to set the test range correctly, you have to specify both min_x and max_x. Local test shows this patch shall decrease the time consumed by the crush smoke testing to approximate 1/20 of those without this. For exmaple: crush somke test duration: 0.668354 seconds -> crush somke test duration: 0.012592 seconds Signed-off-by: xie xingguo (cherry picked from commit e128a1e913fb4a224e392cd09203fc7cf4fa9f5f) --- src/mon/OSDMonitor.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 2292c9a34b25..5c86432ef73e 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -5726,15 +5726,20 @@ int OSDMonitor::prepare_new_pool(string& name, uint64_t auid, _get_pending_crush(newcrush); ostringstream err; CrushTester tester(newcrush, err); + tester.set_min_x(0); tester.set_max_x(50); tester.set_rule(crush_rule); + auto start = ceph::coarse_mono_clock::now(); r = tester.test_with_fork(g_conf->mon_lease); + auto duration = ceph::coarse_mono_clock::now() - start; if (r < 0) { dout(10) << " tester.test_with_fork returns " << r << ": " << err.str() << dendl; *ss << "crush test failed with " << r << ": " << err.str(); return r; } + dout(10) << __func__ << " crush somke test duration: " + << duration << dendl; } unsigned size, min_size; r = prepare_pool_size(pool_type, erasure_code_profile, &size, &min_size, ss); @@ -7301,8 +7306,11 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, dout(10) << " testing map" << dendl; stringstream ess; CrushTester tester(crush, ess); + tester.set_min_x(0); tester.set_max_x(50); + auto start = ceph::coarse_mono_clock::now(); int r = tester.test_with_fork(g_conf->mon_lease); + auto duration = ceph::coarse_mono_clock::now() - start; if (r < 0) { dout(10) << " tester.test_with_fork returns " << r << ": " << ess.str() << dendl; @@ -7310,7 +7318,8 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = r; goto reply; } - dout(10) << " crush test result " << ess.str() << dendl; + dout(10) << __func__ << " crush somke test duration: " + << duration << ", result: " << ess.str() << dendl; } pending_inc.crush = data; -- 2.47.3