From: Samuel Just Date: Mon, 5 Nov 2012 19:02:30 +0000 (-0800) Subject: osd/: encode LOST_REVERT reverting_to in prior_version pos X-Git-Tag: v0.55~187^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=85cd694846ef04ad5e4975955f9696856158da8a;p=ceph.git osd/: encode LOST_REVERT reverting_to in prior_version pos This will allow older osds to interpret the LOST_REVERT event correctly. Signed-off-by: Samuel Just --- diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index e8a0c7126f3..848075b467f 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -1583,12 +1583,26 @@ void pg_log_entry_t::encode(bufferlist &bl) const ::encode(op, bl); ::encode(soid, bl); ::encode(version, bl); - ::encode(prior_version, bl); + + /** + * Added with reverting_to: + * Previous code used prior_version to encode + * what we now call reverting_to. This will + * allow older code to decode reverting_to + * into prior_version as expected. + */ + if (op == LOST_REVERT) + ::encode(reverting_to, bl); + else + ::encode(prior_version, bl); + ::encode(reqid, bl); ::encode(mtime, bl); if (op == CLONE) ::encode(snaps, bl); - ::encode(reverting_to, bl); + + if (op == LOST_REVERT) + ::encode(prior_version, bl); ENCODE_FINISH(bl); } @@ -1608,18 +1622,27 @@ void pg_log_entry_t::decode(bufferlist::iterator &bl) if (struct_v < 3) invalid_hash = true; ::decode(version, bl); - ::decode(prior_version, bl); + + if (struct_v >= 6 && op == LOST_REVERT) + ::decode(reverting_to, bl); + else + ::decode(prior_version, bl); + ::decode(reqid, bl); ::decode(mtime, bl); if (op == CLONE) ::decode(snaps, bl); if (struct_v < 5) invalid_pool = true; - if (struct_v >= 6) { - ::decode(reverting_to, bl); - } else { - reverting_to = prior_version; + + if (op == LOST_REVERT) { + if (struct_v >= 6) { + ::decode(prior_version, bl); + } else { + reverting_to = prior_version; + } } + DECODE_FINISH(bl); }