From 51413011417b76f5ad2830d9f93fbfe78c77e467 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 26 May 2015 18:11:59 +0800 Subject: [PATCH] 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) --- src/crush/CrushTester.cc | 4 ++++ src/crush/CrushTester.h | 3 ++- src/mon/OSDMonitor.cc | 6 +----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/crush/CrushTester.cc b/src/crush/CrushTester.cc index 2b60c22d40914..04c5be1de1617 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 22424757f6ed6..4f90aae940bc3 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 5ca2a9b182258..b249f10214b80 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) { -- 2.39.5