]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/: encode LOST_REVERT reverting_to in prior_version pos
authorSamuel Just <sam.just@inktank.com>
Mon, 5 Nov 2012 19:02:30 +0000 (11:02 -0800)
committerSamuel Just <sam.just@inktank.com>
Mon, 5 Nov 2012 19:02:32 +0000 (11:02 -0800)
This will allow older osds to interpret the LOST_REVERT event
correctly.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/osd_types.cc

index e8a0c7126f318a286f7c236b5a61c22f6cb638d6..848075b467f5f756a7b198694cb562aad64c08e8 100644 (file)
@@ -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);
 }