From: Sage Weil Date: Sat, 16 Aug 2014 01:06:14 +0000 (-0700) Subject: mon/OSDMonitor: handle MMonGetOSDMap X-Git-Tag: v0.91~55^2~2^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3978c1d3e189f293bedd45f7984142b0a815fc0b;p=ceph.git mon/OSDMonitor: handle MMonGetOSDMap Respond to MMonGetOSDMap with an MOSDMap filled with what we have. Signed-off-by: Sage Weil --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 3fcc040e886..7f882ca2a58 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -3224,6 +3224,7 @@ void Monitor::dispatch(MonSession *s, Message *m, const bool src_is_mon) switch (m->get_type()) { // OSDs + case CEPH_MSG_MON_GET_OSDMAP: case MSG_OSD_MARK_ME_DOWN: case MSG_OSD_FAILURE: case MSG_OSD_BOOT: diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index ea73a3f13c8..8efc700c3ee 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -31,6 +31,7 @@ #include "messages/MOSDFailure.h" #include "messages/MOSDMarkMeDown.h" #include "messages/MOSDMap.h" +#include "messages/MMonGetOSDMap.h" #include "messages/MOSDBoot.h" #include "messages/MOSDAlive.h" #include "messages/MPoolOp.h" @@ -746,6 +747,8 @@ bool OSDMonitor::preprocess_query(PaxosServiceMessage *m) // READs case MSG_MON_COMMAND: return preprocess_command(static_cast(m)); + case CEPH_MSG_MON_GET_OSDMAP: + return preprocess_get_osdmap(static_cast(m)); // damp updates case MSG_OSD_MARK_ME_DOWN: @@ -832,6 +835,32 @@ bool OSDMonitor::should_propose(double& delay) // --------------------------- // READs +bool OSDMonitor::preprocess_get_osdmap(MMonGetOSDMap *m) +{ + dout(10) << __func__ << " " << *m << dendl; + MOSDMap *reply = new MOSDMap(mon->monmap->fsid); + epoch_t first = get_first_committed(); + epoch_t last = osdmap.get_epoch(); + int max = g_conf->osd_map_message_max; + for (epoch_t e = MAX(first, m->get_full_first()); + e < MIN(last, m->get_full_last()) && max > 0; + ++e, --max) { + int r = get_version_full(e, reply->maps[e]); + assert(r >= 0); + } + for (epoch_t e = MAX(first, m->get_inc_first()); + e < MIN(last, m->get_inc_last()) && max > 0; + ++e, --max) { + int r = get_version(e, reply->incremental_maps[e]); + assert(r >= 0); + } + reply->oldest_map = get_first_committed(); + reply->newest_map = osdmap.get_epoch(); + mon->send_reply(m, reply); + m->put(); + return true; +} + // --------------------------- // UPDATEs diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 411650dcddc..3f9d578e4ad 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -224,6 +224,8 @@ private: bool check_source(PaxosServiceMessage *m, uuid_d fsid); + bool preprocess_get_osdmap(class MMonGetOSDMap *m); + bool preprocess_mark_me_down(class MOSDMarkMeDown *m); friend class C_AckMarkedDown;