From: Kefu Chai Date: Tue, 26 May 2015 10:11:59 +0000 (+0800) Subject: mon: add "--check" to CrushTester::test_with_crushtool() X-Git-Tag: v0.94.3~51^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F4936%2Fhead;p=ceph.git mon: add "--check" to CrushTester::test_with_crushtool() so we don't need to call CrushTester::check_name_maps() in OSDMonitor.cc anymore. Fixes: #11680 Signed-off-by: Kefu Chai (cherry picked from commit c6e634875316cf17368d497e6dc4f6f4b5dd65d2) --- diff --git a/src/crush/CrushTester.cc b/src/crush/CrushTester.cc index 2b60c22d409..04c5be1de16 100644 --- a/src/crush/CrushTester.cc +++ b/src/crush/CrushTester.cc @@ -358,9 +358,11 @@ void CrushTester::write_integer_indexed_scalar_data_string(vector &dst, } int CrushTester::test_with_crushtool(const string& crushtool, + int max_id, int timeout) { string timeout_string = stringify(timeout); + string opt_max_id = stringify(max_id); vector cmd_args; cmd_args.push_back("timeout"); cmd_args.push_back(timeout_string.c_str()); @@ -368,6 +370,8 @@ int CrushTester::test_with_crushtool(const string& crushtool, cmd_args.push_back("-i"); cmd_args.push_back("-"); cmd_args.push_back("--test"); + cmd_args.push_back("--check"); + cmd_args.push_back(opt_max_id.c_str()); cmd_args.push_back(NULL); int pipefds[2]; diff --git a/src/crush/CrushTester.h b/src/crush/CrushTester.h index 22424757f6e..4f90aae940b 100644 --- a/src/crush/CrushTester.h +++ b/src/crush/CrushTester.h @@ -343,7 +343,8 @@ public: bool check_name_maps(unsigned max_id = 0) const; int test(); int test_with_crushtool(const string& crushtool, - int timeout); + int max_id = -1, + int timeout = 0); }; #endif diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 5ca2a9b1822..b249f10214b 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -4530,12 +4530,8 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m, // then we would consistently trigger an election before the command // finishes, having a flapping monitor unable to hold quorum. CrushTester tester(crush, ess); - if (!tester.check_name_maps(osdmap.get_max_osd())) { - err = -EINVAL; - ss << ess.str(); - goto reply; - } int r = tester.test_with_crushtool(g_conf->crushtool, + osdmap.get_max_osd(), g_conf->mon_lease); if (r < 0) { if (r == -EINTR) {