From a888a57f79a6d1ab943efe12c10ad2654659c797 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Mon, 9 Dec 2013 14:35:00 +0100 Subject: [PATCH] crush: implement --show-bad-mappings for indep Support the presence of ITEM_NONE device numbers in the indep mapping as proof of a bad mapping. Implement the associated unit tests. Signed-off-by: Loic Dachary --- src/crush/CrushTester.cc | 13 ++++++++++--- src/test/cli/crushtool/bad-mappings.crushmap.txt | 10 ++++++++++ src/test/cli/crushtool/bad-mappings.t | 2 ++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/crush/CrushTester.cc b/src/crush/CrushTester.cc index 90a59a99858..23f1a7d3b08 100644 --- a/src/crush/CrushTester.cc +++ b/src/crush/CrushTester.cc @@ -503,14 +503,21 @@ int CrushTester::test() if (output_data_file) write_integer_indexed_vector_data_string(tester_data.placement_information, x, out); + bool has_item_none = false; for (unsigned i = 0; i < out.size(); i++) { - per[out[i]]++; - temporary_per[out[i]]++; + if (out[i] != CRUSH_ITEM_NONE) { + per[out[i]]++; + temporary_per[out[i]]++; + } else { + has_item_none = true; + } } batch_per[current_batch] = temporary_per; sizes[out.size()]++; - if (output_bad_mappings && out.size() != (unsigned)nr) { + if (output_bad_mappings && + (out.size() != (unsigned)nr || + has_item_none)) { err << "bad mapping rule " << r << " x " << x << " num_rep " << nr << " result " << out << std::endl; } } diff --git a/src/test/cli/crushtool/bad-mappings.crushmap.txt b/src/test/cli/crushtool/bad-mappings.crushmap.txt index e7b2b929714..a3d5dfee01f 100644 --- a/src/test/cli/crushtool/bad-mappings.crushmap.txt +++ b/src/test/cli/crushtool/bad-mappings.crushmap.txt @@ -27,3 +27,13 @@ rule rule-firstn { step choose firstn 0 type osd step emit } + +rule rule-indep { + ruleset 1 + type erasure + min_size 1 + max_size 10 + step take root + step choose indep 0 type osd + step emit +} diff --git a/src/test/cli/crushtool/bad-mappings.t b/src/test/cli/crushtool/bad-mappings.t index ce95990ad01..ce00c7041f2 100644 --- a/src/test/cli/crushtool/bad-mappings.t +++ b/src/test/cli/crushtool/bad-mappings.t @@ -1,3 +1,5 @@ $ crushtool -c "$TESTDIR/bad-mappings.crushmap.txt" -o "$TESTDIR/bad-mappings.crushmap" $ crushtool -i "$TESTDIR/bad-mappings.crushmap" --test --show-bad-mappings --rule 0 --x 1 --num-rep 10 bad mapping rule 0 x 1 num_rep 10 result [4,0,2,3,1] + $ crushtool -i "$TESTDIR/bad-mappings.crushmap" --test --show-bad-mappings --rule 1 --x 1 --num-rep 10 + bad mapping rule 1 x 1 num_rep 10 result [4,0,2,1,3,2147483647,2147483647,2147483647,2147483647,2147483647] -- 2.47.3