From: Piotr Dałek Date: Tue, 16 Jan 2018 09:47:19 +0000 (+0100) Subject: osd_types.cc: don't store 32 least siognificant bits of state twice X-Git-Tag: v13.0.2~477^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F19965%2Fhead;p=ceph.git osd_types.cc: don't store 32 least siognificant bits of state twice a25221e55172c326b48dea6f08c16d700921864e introduced a new, 64bit pg state field, retaining encoding and decoding of least significant 32 bits for compatibility reasons. This commit also adds encoding of entire 64bit state field, meaning that the least significant bits are encoded and decoded twice. Fix this by encoding each half of 64bit field separately. Signed-off-by: Piotr Dałek --- diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 349b82a2b28e..cf46ac67c878 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -2411,7 +2411,8 @@ void pg_stat_t::encode(bufferlist &bl) const encode(last_became_peered, bl); encode(pin_stats_invalid, bl); encode(snaptrimq_len, bl); - encode(state, bl); + __u32 top_state = (state >> 32); + encode(top_state, bl); encode(purged_snaps, bl); ENCODE_FINISH(bl); } @@ -2470,7 +2471,9 @@ void pg_stat_t::decode(bufferlist::iterator &bl) if (struct_v >= 23) { decode(snaptrimq_len, bl); if (struct_v >= 24) { - decode(state, bl); + __u32 top_state; + decode(top_state, bl); + state = (uint64_t)old_state | ((uint64_t)top_state << 32); decode(purged_snaps, bl); } else { state = old_state;