]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: implement --show-bad-mappings for indep 923/head
authorLoic Dachary <loic@dachary.org>
Mon, 9 Dec 2013 13:35:00 +0000 (14:35 +0100)
committerLoic Dachary <loic@dachary.org>
Mon, 9 Dec 2013 20:10:29 +0000 (21:10 +0100)
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 <loic@dachary.org>
src/crush/CrushTester.cc
src/test/cli/crushtool/bad-mappings.crushmap.txt
src/test/cli/crushtool/bad-mappings.t

index 90a59a998584017d2744014e6275828d9cfa6819..23f1a7d3b085e6725656d93fb0b6da5d10ce4bcf 100644 (file)
@@ -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;
           }
         }
index e7b2b929714e754f72bc257161afb97f85a6d7f1..a3d5dfee01f40b57d87ec34abedcf32d35afb009 100644 (file)
@@ -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
+}
index ce95990ad010d3e589f59f6223d97fc63bccda7f..ce00c7041f222676c175c7da9cd4892c3ef759df 100644 (file)
@@ -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]