Skip to content

Commit

Permalink
mon/OSDMonitor: fix improper input/testing range of crush somke testing
Browse files Browse the repository at this point in the history
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 <xie.xingguo@zte.com.cn>
  • Loading branch information
xiexingguo committed Aug 23, 2017
1 parent 05f16b4 commit 337884e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/mon/OSDMonitor.cc
Expand Up @@ -5800,15 +5800,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_clock_now();
r = tester.test_with_fork(g_conf->mon_lease);
auto duration = ceph_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 << " seconds" << dendl;
}
unsigned size, min_size;
r = prepare_pool_size(pool_type, erasure_code_profile, &size, &min_size, ss);
Expand Down Expand Up @@ -7375,16 +7380,20 @@ 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_clock_now();
int r = tester.test_with_fork(g_conf->mon_lease);
auto duration = ceph_clock_now() - start;
if (r < 0) {
dout(10) << " tester.test_with_fork returns " << r
<< ": " << ess.str() << dendl;
ss << "crush smoke test failed with " << r << ": " << ess.str();
err = r;
goto reply;
}
dout(10) << " crush test result " << ess.str() << dendl;
dout(10) << __func__ << " crush somke test duration: "
<< duration << " seconds" << dendl;
}

pending_inc.crush = data;
Expand Down

0 comments on commit 337884e

Please sign in to comment.