From c6e634875316cf17368d497e6dc4f6f4b5dd65d2 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 --- src/crush/CrushTester.cc | 7 ++++--- src/crush/CrushTester.h | 1 + src/mon/OSDMonitor.cc | 6 +----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/crush/CrushTester.cc b/src/crush/CrushTester.cc index 47d094ad8607..2a3ae8f47b45 100644 --- a/src/crush/CrushTester.cc +++ b/src/crush/CrushTester.cc @@ -7,7 +7,7 @@ #include #include - +#include #include void CrushTester::set_device_weight(int dev, float f) @@ -355,10 +355,11 @@ void CrushTester::write_integer_indexed_scalar_data_string(vector &dst, dst.push_back( data_buffer.str() ); } -int CrushTester::test_with_crushtool(const char *crushtool_cmd, int timeout) +int CrushTester::test_with_crushtool(const char *crushtool_cmd, int max_id, int timeout) { SubProcessTimed crushtool(crushtool_cmd, true, false, true, timeout); - crushtool.add_cmd_args("-i", "-", "--test", NULL); + string opt_max_id = boost::lexical_cast(max_id); + crushtool.add_cmd_args("-i", "-", "--test", "--check", opt_max_id.c_str(), NULL); int ret = crushtool.spawn(); if (ret != 0) { err << "failed run crushtool: " << crushtool.err(); diff --git a/src/crush/CrushTester.h b/src/crush/CrushTester.h index 4522fdfdca9d..ed14761462ac 100644 --- a/src/crush/CrushTester.h +++ b/src/crush/CrushTester.h @@ -343,6 +343,7 @@ public: bool check_name_maps(unsigned max_id = 0) const; int test(); int test_with_crushtool(const char *crushtool_cmd = "crushtool", + int max_id = -1, int timeout = 0); }; diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index c60b273f233d..dacd4b668591 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -4841,16 +4841,12 @@ bool OSDMonitor::prepare_command_impl(MMonCommand *m, dout(10) << " testing map" << dendl; stringstream ess; CrushTester tester(crush, ess); - if (!tester.check_name_maps(osdmap.get_max_osd())) { - err = -EINVAL; - ss << ess.str(); - goto reply; - } // XXX: Use mon_lease as a timeout value for crushtool. // If the crushtool consistently takes longer than 'mon_lease' seconds, // then we would consistently trigger an election before the command // finishes, having a flapping monitor unable to hold quorum. int r = tester.test_with_crushtool(g_conf->crushtool.c_str(), + osdmap.get_max_osd(), g_conf->mon_lease); if (r < 0) { derr << "error on crush map: " << ess.str() << dendl; -- 2.47.3