From cc90a0ef819181479a97db039d3559d9a855e500 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Tue, 27 Jun 2017 16:47:38 +0200 Subject: [PATCH] crush/CrushWrapper: encode choose_args.size() as __u32 choose_args.size() returns size_t, which is not fixed size. Given that choose_args code just open-codes our std::map encoder, do what we do for std::map. This was introduced in commit dbe36e08be00 ("crush: compile/decompile crush_choose_arg_map") under SERVER_LUMINOUS bit. Signed-off-by: Ilya Dryomov --- src/crush/CrushWrapper.cc | 9 +++++---- src/test/cli/osdmaptool/crush.t | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index 650b2cfe04a49..f375c7412f853 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -1756,11 +1756,12 @@ void CrushWrapper::encode(bufferlist& bl, uint64_t features) const ::encode(class_name, bl); ::encode(class_bucket, bl); - ::encode(choose_args.size(), bl); + __u32 size = (__u32)choose_args.size(); + ::encode(size, bl); for (auto c : choose_args) { ::encode(c.first, bl); crush_choose_arg_map arg_map = c.second; - __u32 size = 0; + size = 0; for (__u32 i = 0; i < arg_map.size; i++) { crush_choose_arg *arg = &arg_map.args[i]; if (arg->weight_set_size == 0 && @@ -1889,9 +1890,9 @@ void CrushWrapper::decode(bufferlist::iterator& blp) cleanup_classes(); } if (!blp.end()) { - size_t choose_args_size; + __u32 choose_args_size; ::decode(choose_args_size, blp); - for (size_t i = 0; i < choose_args_size; i++) { + for (__u32 i = 0; i < choose_args_size; i++) { uint64_t choose_args_index; ::decode(choose_args_index, blp); crush_choose_arg_map arg_map; diff --git a/src/test/cli/osdmaptool/crush.t b/src/test/cli/osdmaptool/crush.t index 6086fc43e32ef..c01c952b8041d 100644 --- a/src/test/cli/osdmaptool/crush.t +++ b/src/test/cli/osdmaptool/crush.t @@ -6,5 +6,5 @@ osdmaptool: exported crush map to oc $ osdmaptool --import-crush oc myosdmap osdmaptool: osdmap file 'myosdmap' - osdmaptool: imported 489 byte crush map from oc + osdmaptool: imported 485 byte crush map from oc osdmaptool: writing epoch 3 to myosdmap -- 2.39.5