]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: update tries statistics for indep rules
authorLoic Dachary <ldachary@redhat.com>
Wed, 17 Dec 2014 12:43:41 +0000 (13:43 +0100)
committerLoic Dachary <ldachary@redhat.com>
Thu, 15 Jan 2015 20:26:53 +0000 (21:26 +0100)
http://tracker.ceph.com/issues/10349 Fixes: #10349

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/crush/mapper.c
src/test/cli/crushtool/show-choose-tries.t [new file with mode: 0644]
src/test/cli/crushtool/show-choose-tries.txt [new file with mode: 0644]

index cce7d9447b1dbe18bdadc0aadec4a386fca854f6..2de70eb573ed1a0b97409ed9ec212981a7e49561 100644 (file)
@@ -644,6 +644,9 @@ static void crush_choose_indep(const struct crush_map *map,
                        out2[rep] = CRUSH_ITEM_NONE;
                }
        }
+        if (map->choose_tries && ftotal <= map->choose_total_tries)
+          map->choose_tries[ftotal]++;
+
 #ifdef DEBUG_INDEP
        if (out2) {
                printf("%u %d a: ", ftotal, left);
diff --git a/src/test/cli/crushtool/show-choose-tries.t b/src/test/cli/crushtool/show-choose-tries.t
new file mode 100644 (file)
index 0000000..6a7ecae
--- /dev/null
@@ -0,0 +1,109 @@
+  $ crushtool -c "$TESTDIR/show-choose-tries.txt" -o "$TESTDIR/show-choose-tries.crushmap"
+  $ FIRSTN_RULESET=0
+  $ crushtool -i "$TESTDIR/show-choose-tries.crushmap" --test --show-choose-tries --rule $FIRSTN_RULESET --x 1 --num-rep 2
+   0:         1
+   1:         1
+   2:         0
+   3:         0
+   4:         0
+   5:         0
+   6:         0
+   7:         0
+   8:         0
+   9:         0
+  10:         0
+  11:         0
+  12:         0
+  13:         0
+  14:         0
+  15:         0
+  16:         0
+  17:         0
+  18:         0
+  19:         0
+  20:         0
+  21:         0
+  22:         0
+  23:         0
+  24:         0
+  25:         0
+  26:         0
+  27:         0
+  28:         0
+  29:         0
+  30:         0
+  31:         0
+  32:         0
+  33:         0
+  34:         0
+  35:         0
+  36:         0
+  37:         0
+  38:         0
+  39:         0
+  40:         0
+  41:         0
+  42:         0
+  43:         0
+  44:         0
+  45:         0
+  46:         0
+  47:         0
+  48:         0
+  49:         0
+  $ INDEP_RULESET=1
+  $ crushtool -i "$TESTDIR/show-choose-tries.crushmap" --test --show-choose-tries --rule $INDEP_RULESET --x 1 --num-rep 1
+   0:         0
+   1:         1
+   2:         0
+   3:         0
+   4:         0
+   5:         0
+   6:         0
+   7:         0
+   8:         0
+   9:         0
+  10:         0
+  11:         0
+  12:         0
+  13:         0
+  14:         0
+  15:         0
+  16:         0
+  17:         0
+  18:         0
+  19:         0
+  20:         0
+  21:         0
+  22:         0
+  23:         0
+  24:         0
+  25:         0
+  26:         0
+  27:         0
+  28:         0
+  29:         0
+  30:         0
+  31:         0
+  32:         0
+  33:         0
+  34:         0
+  35:         0
+  36:         0
+  37:         0
+  38:         0
+  39:         0
+  40:         0
+  41:         0
+  42:         0
+  43:         0
+  44:         0
+  45:         0
+  46:         0
+  47:         0
+  48:         0
+  49:         0
+  $ rm -f "$TESTDIR/show-choose-tries.crushmap"
+# Local Variables:
+# compile-command: "cd ../../.. ; make -j4 crushtool && test/run-cli-tests"
+# End:
diff --git a/src/test/cli/crushtool/show-choose-tries.txt b/src/test/cli/crushtool/show-choose-tries.txt
new file mode 100644 (file)
index 0000000..919ff3e
--- /dev/null
@@ -0,0 +1,47 @@
+# begin crush map
+tunable choose_local_tries 0
+tunable choose_local_fallback_tries 0
+tunable choose_total_tries 50
+tunable chooseleaf_descend_once 1
+
+# devices
+device 0 device0
+device 1 device1
+device 2 device2
+
+# types
+type 0 device
+type 1 root
+
+# buckets
+root root {
+       id -1           # do not change unnecessarily
+       # weight 3.000
+       alg straw
+       hash 0  # rjenkins1
+       item device0 weight 1.000
+       item device1 weight 1.000
+       item device2 weight 1.000
+}
+
+rule first_ruleset {
+       ruleset 0
+       type replicated
+       min_size 1
+       max_size 10
+       step take root
+       step choose firstn 0 type device
+       step emit
+}
+
+rule indep_ruleset {
+    ruleset 1
+    type erasure
+    min_size 3
+    max_size 20
+    step set_chooseleaf_tries 5
+    step take root
+    step choose indep 0 type device
+    step emit
+}
+