]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: make it MOSDAlive, and respond with new osdmap
authorSage Weil <sage@newdream.net>
Tue, 13 May 2008 21:54:29 +0000 (14:54 -0700)
committerSage Weil <sage@newdream.net>
Tue, 13 May 2008 21:54:29 +0000 (14:54 -0700)
src/messages/MOSDAlive.h [new file with mode: 0644]
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h
src/msg/Message.h

diff --git a/src/messages/MOSDAlive.h b/src/messages/MOSDAlive.h
new file mode 100644 (file)
index 0000000..1caeaf9
--- /dev/null
@@ -0,0 +1,44 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software 
+ * Foundation.  See file COPYING.
+ * 
+ */
+
+
+
+#ifndef __MOSDALIVE_H
+#define __MOSDALIVE_H
+
+#include "msg/Message.h"
+
+class MOSDAlive : public Message {
+ public:
+  epoch_t map_epoch;
+
+  MOSDAlive(epoch_t e) : Message(MSG_OSD_ALIVE), map_epoch(e) { }
+  MOSDAlive() {}
+
+  void encode_payload() {
+    ::encode(map_epoch, payload);
+  }
+  void decode_payload() {
+    bufferlist::iterator p = payload.begin();
+    ::decode(map_epoch, p);
+  }
+
+  const char *get_type_name() { return "osd_alive"; }
+  void print(ostream &out) {
+    out << "osd_alive(" << map_epoch << ")";
+  }
+  
+};
+
+#endif
index 3a41aa0f1d905cc23bb6cc8d256b52b5e101d4d8..0b8d60152fb542eb62d164f462ba92bd7c2620f6 100644 (file)
@@ -25,8 +25,7 @@
 #include "messages/MOSDMap.h"
 #include "messages/MOSDGetMap.h"
 #include "messages/MOSDBoot.h"
-#include "messages/MOSDIn.h"
-#include "messages/MOSDOut.h"
+#include "messages/MOSDAlive.h"
 #include "messages/MMonCommand.h"
 
 #include "common/Timer.h"
@@ -273,8 +272,8 @@ bool OSDMonitor::preprocess_query(Message *m)
     return preprocess_failure((MOSDFailure*)m);
   case MSG_OSD_BOOT:
     return preprocess_boot((MOSDBoot*)m);
-  case MSG_OSD_IN:
-    return preprocess_in((MOSDIn*)m);
+  case MSG_OSD_ALIVE:
+    return preprocess_alive((MOSDAlive*)m);
     /*
   case MSG_OSD_OUT:
     return preprocess_out((MOSDOut*)m);
@@ -297,8 +296,8 @@ bool OSDMonitor::prepare_update(Message *m)
     return prepare_failure((MOSDFailure*)m);
   case MSG_OSD_BOOT:
     return prepare_boot((MOSDBoot*)m);
-  case MSG_OSD_IN:
-    return prepare_in((MOSDIn*)m);
+  case MSG_OSD_ALIVE:
+    return prepare_alive((MOSDAlive*)m);
 
   case MSG_MON_COMMAND:
     return prepare_command((MMonCommand*)m);
@@ -538,38 +537,39 @@ void OSDMonitor::_booted(MOSDBoot *m)
 // -------------
 // in
 
-bool OSDMonitor::preprocess_in(MOSDIn *m)
+bool OSDMonitor::preprocess_alive(MOSDAlive *m)
 {
   int from = m->get_source().num();
   if (osdmap.is_up(from) &&
       osdmap.get_inst(from) == m->get_source_inst() &&
       osdmap.get_alive_thru(from) >= m->map_epoch) {
     // yup.
-    dout(7) << "preprocess_in e" << m->map_epoch << " dup from " << m->get_source_inst() << dendl;
-    _in(m);
+    dout(7) << "preprocess_alive e" << m->map_epoch << " dup from " << m->get_source_inst() << dendl;
+    _alive(m);
     return true;
   }
   
-  dout(10) << "preprocess_in e" << m->map_epoch << " from " << m->get_source_inst() << dendl;
+  dout(10) << "preprocess_alive e" << m->map_epoch << " from " << m->get_source_inst() << dendl;
   return false;
 }
 
-bool OSDMonitor::prepare_in(MOSDIn *m)
+bool OSDMonitor::prepare_alive(MOSDAlive *m)
 {
   int from = m->get_source().num();
 
-  dout(7) << "prepare_in e" << m->map_epoch << " from " << m->get_source_inst() << dendl;
+  dout(7) << "prepare_alive e" << m->map_epoch << " from " << m->get_source_inst() << dendl;
   pending_inc.new_alive_thru[from] = m->map_epoch;
-  paxos->wait_for_commit(new C_In(this,m ));
+  paxos->wait_for_commit(new C_Alive(this,m ));
   return true;
 }
 
-void OSDMonitor::_in(MOSDIn *m)
+void OSDMonitor::_alive(MOSDAlive *m)
 {
-  dout(7) << "_in e" << m->map_epoch
+  dout(7) << "_alive e" << m->map_epoch
          << " from " << m->get_source_inst()
          << dendl;
-  mon->messenger->send_message(m, m->get_source_inst());
+  send_latest(m->get_source_inst(), m->map_epoch);
+  delete m;
 }
 
 
index 450787772a940028b50490cdd3bb8d1be2d6b7c8..467f7c8db98fee179195c375f4ad87b8d4692d1b 100644 (file)
@@ -79,9 +79,9 @@ private:
   bool prepare_boot(class MOSDBoot *m);
   void _booted(MOSDBoot *m);
 
-  bool preprocess_in(class MOSDIn *m);
-  bool prepare_in(class MOSDIn *m);
-  void _in(MOSDIn *m);
+  bool preprocess_alive(class MOSDAlive *m);
+  bool prepare_alive(class MOSDAlive *m);
+  void _alive(MOSDAlive *m);
 
   struct C_Booted : public Context {
     OSDMonitor *cmon;
@@ -95,12 +95,12 @@ private:
        cmon->dispatch((Message*)m);
     }
   };
-  struct C_In : public Context {
+  struct C_Alive : public Context {
     OSDMonitor *osdmon;
-    MOSDIn *m;
-    C_In(OSDMonitor *o, MOSDIn *mm) : osdmon(o), m(mm) {}
+    MOSDAlive *m;
+    C_Alive(OSDMonitor *o, MOSDAlive *mm) : osdmon(o), m(mm) {}
     void finish(int r) {
-      osdmon->_in(m);
+      osdmon->_alive(m);
     }    
   };
   struct C_Reported : public Context {
index b7320e4c194c00d3f6b2a52d000823fcb33a9389..2095be5a10bcfea3e4f8615a2ceb96de7f87c3a5 100644 (file)
 #define MSG_OSD_PING         70
 #define MSG_OSD_BOOT         71
 #define MSG_OSD_FAILURE      72
-#define MSG_OSD_IN           73
-#define MSG_OSD_OUT          74
+#define MSG_OSD_ALIVE        73
+#define MSG_OSD_IN           74
+#define MSG_OSD_OUT          75
 
-#define MSG_OSD_SUBOP        75
-#define MSG_OSD_SUBOPREPLY   76
+#define MSG_OSD_SUBOP        76
+#define MSG_OSD_SUBOPREPLY   77
 
 #define MSG_OSD_PG_NOTIFY      80
 #define MSG_OSD_PG_QUERY       81