From: Samuel Just Date: Wed, 13 Nov 2013 21:24:10 +0000 (-0800) Subject: osd_types: fix object_info_t backwards compatibility X-Git-Tag: v0.73~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bf7c09a893118bf30ca9f4f94ad19bdc08d8922a;p=ceph.git osd_types: fix object_info_t backwards compatibility Shipping an object_info_t to a replica with the dirty flag set would cause the replica to interpret that object as being lost. Instead, we always encode lost into the slot where dumpling expects to find it and add another field at the end of the encoding. Backport: emperor Fixes: #6761 Signed-off-by: Samuel Just Reviewed-by: Greg Farnum --- diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 05b83c4af21b..4a9a96c0b902 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -2913,7 +2913,7 @@ void object_info_t::encode(bufferlist& bl) const ++i) { old_watchers.insert(make_pair(i->first.second, i->second)); } - ENCODE_START(12, 8, bl); + ENCODE_START(13, 8, bl); ::encode(soid, bl); ::encode(myoloc, bl); //Retained for compatibility ::encode(category, bl); @@ -2928,23 +2928,23 @@ void object_info_t::encode(bufferlist& bl) const ::encode(snaps, bl); ::encode(truncate_seq, bl); ::encode(truncate_size, bl); - __u8 flags_lo = flags & 0xff; - __u8 flags_hi = (flags & 0xff00) >> 8; - ::encode(flags_lo, bl); + ::encode(is_lost(), bl); ::encode(old_watchers, bl); /* shenanigans to avoid breaking backwards compatibility in the disk format. * When we can, switch this out for simply putting the version_t on disk. */ eversion_t user_eversion(0, user_version); ::encode(user_eversion, bl); - ::encode(flags_hi, bl); + ::encode(test_flag(FLAG_USES_TMAP), bl); ::encode(watchers, bl); + __u32 _flags = flags; + ::encode(_flags, bl); ENCODE_FINISH(bl); } void object_info_t::decode(bufferlist::iterator& bl) { object_locator_t myoloc; - DECODE_START_LEGACY_COMPAT_LEN(12, 8, 8, bl); + DECODE_START_LEGACY_COMPAT_LEN(13, 8, 8, bl); map old_watchers; if (struct_v >= 2 && struct_v <= 5) { sobject_t obj; @@ -2975,6 +2975,9 @@ void object_info_t::decode(bufferlist::iterator& bl) ::decode(truncate_seq, bl); ::decode(truncate_size, bl); if (struct_v >= 3) { + // if this is struct_v >= 13, we will overwrite this + // below since this field is just here for backwards + // compatibility __u8 lo; ::decode(lo, bl); flags = (flag_t)lo; @@ -2988,9 +2991,10 @@ void object_info_t::decode(bufferlist::iterator& bl) user_version = user_eversion.version; } if (struct_v >= 9) { - __u8 hi; - ::decode(hi, bl); - flags = (flag_t)(flags | ((unsigned)hi << 8)); + bool uses_tmap = false; + ::decode(uses_tmap, bl); + if (uses_tmap) + set_flag(FLAG_USES_TMAP); } else { set_flag(FLAG_USES_TMAP); } @@ -3007,6 +3011,11 @@ void object_info_t::decode(bufferlist::iterator& bl) make_pair(i->second.cookie, i->first), i->second)); } } + if (struct_v >= 13) { + __u32 _flags; + ::decode(_flags, bl); + flags = (flag_t)_flags; + } DECODE_FINISH(bl); }