From b64641c3ddbd7ce23a09911fbfcc98de2bea674e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 27 Aug 2012 17:23:30 -0700 Subject: [PATCH] osd: include boot_epoch in MOSDBoot This will let the monitor infer whether we were wrongly marked down or the daemon restarted. Signed-off-by: Sage Weil --- src/messages/MOSDBoot.h | 20 ++++++++++++++------ src/osd/OSD.cc | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/messages/MOSDBoot.h b/src/messages/MOSDBoot.h index 70cf3ade23fd5..482f1dd5c5e80 100644 --- a/src/messages/MOSDBoot.h +++ b/src/messages/MOSDBoot.h @@ -22,20 +22,25 @@ class MOSDBoot : public PaxosServiceMessage { - static const int HEAD_VERSION = 2; + static const int HEAD_VERSION = 3; public: OSDSuperblock sb; entity_addr_t hb_addr; entity_addr_t cluster_addr; + epoch_t boot_epoch; // last epoch this daemon was added to the map (if any) - MOSDBoot() : PaxosServiceMessage(MSG_OSD_BOOT, 0, HEAD_VERSION) { } - MOSDBoot(OSDSuperblock& s, const entity_addr_t& hb_addr_ref, + MOSDBoot() + : PaxosServiceMessage(MSG_OSD_BOOT, 0, HEAD_VERSION), + boot_epoch(0) + { } + MOSDBoot(OSDSuperblock& s, epoch_t be, const entity_addr_t& hb_addr_ref, const entity_addr_t& cluster_addr_ref) : PaxosServiceMessage(MSG_OSD_BOOT, s.current_epoch, HEAD_VERSION), sb(s), - hb_addr(hb_addr_ref), cluster_addr(cluster_addr_ref) { - } + hb_addr(hb_addr_ref), cluster_addr(cluster_addr_ref), + boot_epoch(be) + { } private: ~MOSDBoot() { } @@ -43,7 +48,7 @@ private: public: const char *get_type_name() const { return "osd_boot"; } void print(ostream& out) const { - out << "osd_boot(osd." << sb.whoami << " v" << version << ")"; + out << "osd_boot(osd." << sb.whoami << " booted " << boot_epoch << " v" << version << ")"; } void encode_payload(uint64_t features) { @@ -51,6 +56,7 @@ public: ::encode(sb, payload); ::encode(hb_addr, payload); ::encode(cluster_addr, payload); + ::encode(boot_epoch, payload); } void decode_payload() { bufferlist::iterator p = payload.begin(); @@ -59,6 +65,8 @@ public: ::decode(hb_addr, p); if (header.version >= 2) ::decode(cluster_addr, p); + if (header.version >= 3) + ::decode(boot_epoch, p); } }; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 675665ff8f472..eb661417b5c04 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2396,7 +2396,7 @@ void OSD::_send_boot() hbserver_messenger->set_addr_unknowns(hb_addr); dout(10) << " assuming hb_addr ip matches cluster_addr" << dendl; } - MOSDBoot *mboot = new MOSDBoot(superblock, hb_addr, cluster_addr); + MOSDBoot *mboot = new MOSDBoot(superblock, boot_epoch, hb_addr, cluster_addr); dout(10) << " client_addr " << client_messenger->get_myaddr() << ", cluster_addr " << cluster_addr << ", hb addr " << hb_addr -- 2.39.5