From: Greg Farnum Date: Tue, 24 Apr 2012 22:13:02 +0000 (-0700) Subject: mon: decode old PGMap Incrementals differently from new ones X-Git-Tag: v0.46~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4bfcbe6ab890bf0112cd60ed451002dfb7516c1e;p=ceph.git mon: decode old PGMap Incrementals differently from new ones 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 Reviewed-by: Sage Weil --- diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 8dd9ced452eb..1f6c73b6878d 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -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; }