From: Loic Dachary Date: Sun, 16 Apr 2017 15:21:41 +0000 (+0200) Subject: crush: implement CrushWrapper::dump(choose_args) X-Git-Tag: v12.0.2~11^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1b02fef697ad033ec57a272b9c06c1e62f2f2a7a;p=ceph.git crush: implement CrushWrapper::dump(choose_args) Signed-off-by: Loic Dachary --- diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 4a32ccb7325c8..7974b9a75014e 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -5,6 +5,7 @@ #include "common/debug.h" #include "common/Formatter.h" #include "common/errno.h" +#include "include/stringify.h" #include "CrushWrapper.h" #include "CrushTreeDumper.h" @@ -1822,6 +1823,8 @@ void CrushWrapper::dump(Formatter *f) const f->open_object_section("tunables"); dump_tunables(f); f->close_section(); + + dump_choose_args(f); } namespace { @@ -1914,6 +1917,46 @@ void CrushWrapper::dump_tunables(Formatter *f) const f->dump_int("has_v5_rules", (int)has_v5_rules()); } +void CrushWrapper::dump_choose_args(Formatter *f) const +{ + f->open_object_section("choose_args"); + for (auto c : choose_args) { + crush_choose_arg_map arg_map = c.second; + f->open_array_section(stringify(c.first).c_str()); + for (__u32 i = 0; i < arg_map.size; i++) { + crush_choose_arg *arg = &arg_map.args[i]; + if (arg->weight_set_size == 0 && + arg->ids_size == 0) + continue; + f->open_object_section("choose_args"); + int bucket_index = i; + f->dump_int("bucket_id", -1-bucket_index); + if (arg->weight_set_size > 0) { + f->open_array_section("weight_set"); + for (__u32 j = 0; j < arg->weight_set_size; j++) { + f->open_array_section("weights"); + __u32 *weights = arg->weight_set[j].weights; + __u32 size = arg->weight_set[j].size; + for (__u32 k = 0; k < size; k++) { + f->dump_float("weight", (float)weights[k]/(float)0x10000); + } + f->close_section(); + } + f->close_section(); + } + if (arg->ids_size > 0) { + f->open_array_section("ids"); + for (__u32 j = 0; j < arg->ids_size; j++) + f->dump_int("id", arg->ids[j]); + f->close_section(); + } + f->close_section(); + } + f->close_section(); + } + f->close_section(); +} + void CrushWrapper::dump_rules(Formatter *f) const { for (int i=0; i