]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: decode old PGMap Incrementals differently from new ones
authorGreg Farnum <gregory.farnum@dreamhost.com>
Tue, 24 Apr 2012 22:13:02 +0000 (15:13 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Tue, 24 Apr 2012 23:44:23 +0000 (16:44 -0700)
We need to distinguish between the old 0 (meaning undefined) and
the new 0 (meaning switch to 0 and disable the flags). So rev the
encoding version on PGMap::Incremental, and if you decode an old
version with [near]full_ratio == 0, set the ratio to -1 instead. Then
when applying the Incremental interpret -1 as no change.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
Reviewed-by: Sage Weil <sage@newdream.net>
src/mon/PGMap.cc

index 8dd9ced452ebe8f9d299a5669a0c696bbf42e055..1f6c73b6878dd093627f0c1868b45c0cc7fc50eb 100644 (file)
@@ -12,7 +12,7 @@
 
 void PGMap::Incremental::encode(bufferlist &bl) const
 {
-  __u8 v = 3;
+  __u8 v = 4;
   ::encode(v, bl);
   ::encode(version, bl);
   ::encode(pg_stat_updates, bl);
@@ -63,6 +63,12 @@ void PGMap::Incremental::decode(bufferlist::iterator &bl)
   } else {
     ::decode(pg_remove, bl);
   }
+  if (v < 4 && full_ratio == 0) {
+    full_ratio = -1;
+  }
+  if (v < 4 && nearfull_ratio == 0) {
+    nearfull_ratio = -1;
+  }
 }
 
 void PGMap::Incremental::dump(Formatter *f) const
@@ -131,11 +137,11 @@ void PGMap::apply_incremental(const Incremental& inc)
   assert(inc.version == version+1);
   version++;
   bool ratios_changed = false;
-  if (inc.full_ratio != full_ratio) {
+  if (inc.full_ratio != full_ratio && inc.full_ratio != -1) {
     full_ratio = inc.full_ratio;
     ratios_changed = true;
   }
-  if (inc.nearfull_ratio != nearfull_ratio) {
+  if (inc.nearfull_ratio != nearfull_ratio && inc.full_ratio != -1) {
     nearfull_ratio = inc.nearfull_ratio;
     ratios_changed = true;
   }