]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: handle MMonGetOSDMap
authorSage Weil <sage@redhat.com>
Sat, 16 Aug 2014 01:06:14 +0000 (18:06 -0700)
committerSage Weil <sage@redhat.com>
Mon, 10 Nov 2014 22:20:25 +0000 (14:20 -0800)
Respond to MMonGetOSDMap with an MOSDMap filled with what we have.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/Monitor.cc
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h

index 3fcc040e886a9bbe3528c8d8c15c8b882a65c260..7f882ca2a589b7c5591d47466ac388eda098c87c 100644 (file)
@@ -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:
index ea73a3f13c82ceab4c7d58bdc2270d569a2ca595..8efc700c3ee7fbf12a5dbb87d4daa3e22d61d29c 100644 (file)
@@ -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<MMonCommand*>(m));
+  case CEPH_MSG_MON_GET_OSDMAP:
+    return preprocess_get_osdmap(static_cast<MMonGetOSDMap*>(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
index 411650dcddcc7187862a29eac1ecfb6ab984435b..3f9d578e4adb644030f392a515217e41b82381ba 100644 (file)
@@ -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;