From: Sage Weil Date: Thu, 21 Jun 2012 02:08:34 +0000 (-0700) Subject: mon: conditionally encode old monmap when peer lacks feature X-Git-Tag: v0.48argonaut~29 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2355b233ea976e7cd31546498e96f44375b845eb;p=ceph.git mon: conditionally encode old monmap when peer lacks feature This allows a rolling upgrade from 0.47.2 to 0.48. Signed-off-by: Sage Weil --- diff --git a/src/messages/MMonElection.h b/src/messages/MMonElection.h index b35cbd566b59..e9dcfcb8c6ca 100644 --- a/src/messages/MMonElection.h +++ b/src/messages/MMonElection.h @@ -60,6 +60,14 @@ public: } void encode_payload(uint64_t features) { + if (monmap_bl.length() && (features & CEPH_FEATURE_MONENC) == 0) { + // reencode old-format monmap + MonMap t; + t.decode(monmap_bl); + monmap_bl.clear(); + t.encode(monmap_bl, features); + } + ::encode(fsid, payload); ::encode(op, payload); ::encode(epoch, payload); diff --git a/src/messages/MMonMap.h b/src/messages/MMonMap.h index a314594752f2..3e950fa6f639 100644 --- a/src/messages/MMonMap.h +++ b/src/messages/MMonMap.h @@ -15,7 +15,9 @@ #ifndef CEPH_MMONMAP_H #define CEPH_MMONMAP_H +#include "include/ceph_features.h" #include "msg/Message.h" +#include "mon/MonMap.h" class MMonMap : public Message { public: @@ -32,6 +34,14 @@ public: const char *get_type_name() const { return "mon_map"; } void encode_payload(uint64_t features) { + if (monmapbl.length() && (features & CEPH_FEATURE_MONENC) == 0) { + // reencode old-format monmap + MonMap t; + t.decode(monmapbl); + monmapbl.clear(); + t.encode(monmapbl, features); + } + ::encode(monmapbl, payload); } void decode_payload() { diff --git a/src/messages/MMonProbe.h b/src/messages/MMonProbe.h index 72144ab0f185..e7ea1193731a 100644 --- a/src/messages/MMonProbe.h +++ b/src/messages/MMonProbe.h @@ -16,6 +16,7 @@ #ifndef CEPH_MMONPROBE_H #define CEPH_MMONPROBE_H +#include "include/ceph_features.h" #include "msg/Message.h" #include "mon/MonMap.h" @@ -81,6 +82,14 @@ public: } void encode_payload(uint64_t features) { + if (monmap_bl.length() && (features & CEPH_FEATURE_MONENC) == 0) { + // reencode old-format monmap + MonMap t; + t.decode(monmap_bl); + monmap_bl.clear(); + t.encode(monmap_bl, features); + } + ::encode(fsid, payload); ::encode(op, payload); ::encode(name, payload);