]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd_types.cc: reorder encoding/decoding of fields in pg_stat_t
authorPiotr Dałek <piotr.dalek@corp.ovh.com>
Tue, 16 Jan 2018 09:28:58 +0000 (10:28 +0100)
committerPiotr Dałek <piotr.dalek@corp.ovh.com>
Tue, 16 Jan 2018 09:28:58 +0000 (10:28 +0100)
Fields state, purged_snaps and snaptrimq_len are new to Mimic.
Reorder them in a way that newest field (snaptrimq_len) is before
two others and uses other encoding version, so the pull request
https://github.com/ceph/ceph/pull/19520 can be backported to Luminous
without breaking Luminous -> Mimic upgrade.
This also changes encoding/decoding version back to 24 as both state
and purged snaps were added post-Luminous and pre-Mimic, so we can
push it into a single struct version and keep snaptrimq_len into other
version.

Signed-off-by: Piotr Dałek <piotr.dalek@corp.ovh.com>
src/osd/osd_types.cc

index c7246c498d5f63f16a3be62721f24bc50dde0d49..349b82a2b28ed16da6bb10c7de74e43b23046e1e 100644 (file)
@@ -2369,7 +2369,7 @@ void pg_stat_t::dump_brief(Formatter *f) const
 
 void pg_stat_t::encode(bufferlist &bl) const
 {
-  ENCODE_START(25, 22, bl);
+  ENCODE_START(24, 22, bl);
   encode(version, bl);
   encode(reported_seq, bl);
   encode(reported_epoch, bl);
@@ -2410,9 +2410,9 @@ void pg_stat_t::encode(bufferlist &bl) const
   encode(last_peered, bl);
   encode(last_became_peered, bl);
   encode(pin_stats_invalid, bl);
+  encode(snaptrimq_len, bl);
   encode(state, bl);
   encode(purged_snaps, bl);
-  encode(snaptrimq_len, bl);
   ENCODE_FINISH(bl);
 }
 
@@ -2468,14 +2468,12 @@ void pg_stat_t::decode(bufferlist::iterator &bl)
   decode(tmp, bl);
   pin_stats_invalid = tmp;
   if (struct_v >= 23) {
-    decode(state, bl);
-  } else {
-    state = old_state;
-  }
-  if (struct_v >= 24) {
-    decode(purged_snaps, bl);
-    if (struct_v >= 25) {
-      decode(snaptrimq_len, bl);
+    decode(snaptrimq_len, bl);
+    if (struct_v >= 24) {
+      decode(state, bl);
+      decode(purged_snaps, bl);
+    } else {
+      state = old_state;
     }
   }
   DECODE_FINISH(bl);