]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
include/encoding: Fix encode/decode of float types on big-endian systems 37033/head
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Fri, 4 Sep 2020 13:42:41 +0000 (15:42 +0200)
committerNathan Cutler <ncutler@suse.com>
Mon, 7 Sep 2020 20:22:37 +0000 (22:22 +0200)
commitce83f3b14cd21b2172e60de921cd1b295f9eb1c5
tree14f6ed6a15219805f7e8f84fdbd50020b7087b6f
parentfee7b7e4d8927d79c886fba1b53276175c503b4b
include/encoding: Fix encode/decode of float types on big-endian systems

Currently, floating-point types use "raw" encoding, which means they're
simply copied as byte stream.

This means that if the decoding happens on a machine that differs in
byte order from the source machine, the returned value will be
incorrect. As one effect of this problem, a big-endian OSD node cannot
join a cluster where the MON node is little-endian (or vice versa),
because the OSDMap (incremental) structure contains floating-point
values, and as a result of this conversion problem, the OSD node will
crash with an assertion failure as soon as it receives any OSDMap update
from the MON.

This should be fixed by always encoding floating-point values in
little-endian byte order just as is done for integers. (Note that this
still assumes source and target machines used the same floating-point
format except for byte order. But given that nearly all platforms these
days use IEEE binary32/binary64 for float/double, that seems a
reasonable assumption.)

Fixes: https://tracker.ceph.com/issues/47302
Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
(cherry picked from commit f1f8b9f93b8c64a17c430a66e73e1e47a58781c7)
src/include/encoding.h