]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tag monitor messages with fsid
authorSage Weil <sage@newdream.net>
Tue, 8 Apr 2008 18:29:17 +0000 (11:29 -0700)
committerSage Weil <sage@newdream.net>
Tue, 8 Apr 2008 21:30:23 +0000 (14:30 -0700)
14 files changed:
src/cmonctl.cc
src/fakefuse.cc
src/fakesyn.cc
src/include/ceph_fs.h
src/kernel/mon_client.c
src/mds/MDS.cc
src/messages/MMonCommand.h
src/messages/MMonGetMap.h
src/messages/MOSDFailure.h
src/messages/MOSDGetMap.h
src/mon/Monitor.cc
src/mon/OSDMonitor.cc
src/osd/OSD.cc
src/osdc/Objecter.cc

index 8ea5b78895c55d9c210a9aae06e40b6009688351..28958c2c0f740a2e19142930ba4673a30ca17b5d 100644 (file)
@@ -140,7 +140,7 @@ int main(int argc, const char **argv, const char *envp[]) {
   messenger->set_dispatcher(&dispatcher);
   
   // build command
-  MMonCommand *m = new MMonCommand(messenger->get_myinst());
+  MMonCommand *m = new MMonCommand(monmap.fsid, messenger->get_myinst());
   m->set_data(indata);
   m->cmd.swap(vcmd);
   int mon = monmap.pick_mon();
index 9861ff86c4e813f1b700412ba0291a857b60dd91..f799b1ff1c8a69d28f08add9b5ae43cec09cd906 100644 (file)
@@ -127,7 +127,7 @@ int main(int argc, const char **argv) {
     bufferlist bl;
     map.encode(bl);
     Messenger *messenger = new FakeMessenger(entity_name_t::ADMIN(-1));
-    MMonCommand *m = new MMonCommand(messenger->get_myinst());
+    MMonCommand *m = new MMonCommand(monmap->fsid, messenger->get_myinst());
     m->set_data(bl);
     m->cmd.push_back("osd");
     m->cmd.push_back("setmap");
index c2c7c7a3dfc971ded66c21de80bf44069cecffdf..4828238689383a88f2ae149629cb6670b62c4df7 100644 (file)
@@ -126,7 +126,7 @@ int main(int argc, const char **argv)
     bufferlist bl;
     map.encode(bl);
     Messenger *messenger = new FakeMessenger(entity_name_t::ADMIN(-1));
-    MMonCommand *m = new MMonCommand(messenger->get_myinst());
+    MMonCommand *m = new MMonCommand(monmap->fsid, messenger->get_myinst());
     m->set_data(bl);
     m->cmd.push_back("osd");
     m->cmd.push_back("setmap");
index 67bc33de2330489464320167ff11707dc4047799..b77e0d160eb486fa6032a510bfc2bb50eaeaf8ec 100644 (file)
@@ -286,6 +286,17 @@ struct ceph_statfs {
        __le64 f_objects;
 };
 
+struct ceph_osd_getmap {
+       struct ceph_fsid fsid;
+       __le64 start, want;
+} __attribute__ ((packed));
+
+struct ceph_mds_getmap {
+       struct ceph_fsid fsid;
+       __le64 have;
+} __attribute__ ((packed));
+
+
 /*
  * mds states 
  *   > 0 -> in
index 6252bae2f8c2eb0d2647e8935775e3ed071ef176..7802c3e8af249f33b17f9defe6b59545838a9c71 100644 (file)
@@ -119,13 +119,16 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
 int ceph_monc_request_mdsmap(struct ceph_mon_client *monc, __u32 have)
 {
        int mon = pick_mon(monc, -1);
+       struct ceph_mds_getmap *h;
 
        dout(5, "ceph_monc_request_mdsmap from mon%d have %u\n", mon, have);
        monc->want_mdsmap = have;
-       monc->msg = ceph_msg_new(CEPH_MSG_MDS_GETMAP, sizeof(__u32), 0, 0, 0);
+       monc->msg = ceph_msg_new(CEPH_MSG_MDS_GETMAP, sizeof(*h), 0, 0, 0);
        if (IS_ERR(monc->msg))
                return PTR_ERR(monc->msg);
-       *(__le32*)monc->msg->front.iov_base = cpu_to_le32(have);
+       h = monc->msg->front.iov_base;
+       h->fsid = monc->monmap->fsid;
+       h->have = cpu_to_le32(have);
        monc->msg->hdr.dst = monc->monmap->mon_inst[mon];
        ceph_delayed_work(&monc->delayed_work, &monc->delay);
        return 0;
@@ -152,16 +155,19 @@ int ceph_monc_request_osdmap(struct ceph_mon_client *monc,
                             __u32 have, __u32 want)
 {
        struct ceph_msg *msg;
+       struct ceph_osd_getmap *h;
        int mon = pick_mon(monc, -1);
        
        dout(5, "ceph_monc_request_osdmap from mon%d have %u want %u\n", 
             mon, have, want);
        monc->want_mdsmap = have;
-       msg = ceph_msg_new(CEPH_MSG_OSD_GETMAP, 2*sizeof(__u32), 0, 0, 0);
+       msg = ceph_msg_new(CEPH_MSG_OSD_GETMAP, sizeof(*h), 0, 0, 0);
        if (IS_ERR(msg))
                return PTR_ERR(msg);
-       *(__le32*)msg->front.iov_base = cpu_to_le32(have);
-       *(((__le32*)msg->front.iov_base)+1) = cpu_to_le32(want);
+       h = msg->front.iov_base;
+       h->fsid = monc->monmap->fsid;
+       h->start = cpu_to_le32(have);
+       h->want = cpu_to_le32(want);
        msg->hdr.dst = monc->monmap->mon_inst[mon];
        ceph_msg_send(monc->client->msgr, msg, 0);
        return 0;
index 6440c7f00853de7df735a51753869712a50c1e94..9278f3520276ecc52351d7c1fefbd0910b1d77a9 100644 (file)
@@ -509,7 +509,7 @@ void MDS::handle_mds_map(MMDSMap *m)
     if (oldwhoami < 0) {
       // we need an osdmap too.
       int mon = monmap->pick_mon();
-      messenger->send_message(new MOSDGetMap(0),
+      messenger->send_message(new MOSDGetMap(monmap->fsid, 0),
                              monmap->get_inst(mon));
     }
   }
index ca2f7dc96ed8b372fbf78938402cf933cbb6a58c..f982d23034aadc3785aed16b34a808ee816096b0 100644 (file)
@@ -22,13 +22,14 @@ using std::vector;
 
 class MMonCommand : public Message {
  public:
+  ceph_fsid fsid;
   entity_inst_t inst;
   vector<string> cmd;
 
   MMonCommand() : Message(MSG_MON_COMMAND) {}
-  MMonCommand(entity_inst_t i) : 
+  MMonCommand(ceph_fsid &f, entity_inst_t i) : 
     Message(MSG_MON_COMMAND),
-    inst(i) { }
+    fsid(f), inst(i) { }
   
   const char *get_type_name() { return "mon_command"; }
   void print(ostream& o) {
@@ -41,11 +42,13 @@ class MMonCommand : public Message {
   }
   
   void encode_payload() {
+    ::_encode(fsid, payload);
     ::_encode(inst, payload);
     ::_encode(cmd, payload);
   }
   void decode_payload() {
     int off = 0;
+    ::_decode(fsid, payload, off);
     ::_decode(inst, payload, off);
     ::_decode(cmd, payload, off);
   }
index b942fe1b56067ce8d2d22fa60ce4737612584505..5e28cac8d8c445526828dfd5f0da495ca97b7988 100644 (file)
@@ -24,7 +24,7 @@ class MMonGetMap : public Message {
  public:
   MMonGetMap() : Message(CEPH_MSG_MON_GET_MAP) { }
 
-  const char *get_type_name() { return "mongetmap"; }
+  const char *get_type_name() { return "mon_getmap"; }
   
   void encode_payload() { }
   void decode_payload() { }
index 9f709bc7deeb0bd31e6abb96f67857df60a3b103..f5ca4a0d218f41ba6b30131eb16e7b5f85f21b48 100644 (file)
 
 class MOSDFailure : public Message {
  public:
+  ceph_fsid fsid;
   entity_inst_t from;
   entity_inst_t failed;
   epoch_t       epoch;
 
-  MOSDFailure() {}
-  MOSDFailure(entity_inst_t fr, entity_inst_t f, epoch_t e) : 
+  MOSDFailure() : Message(MSG_OSD_FAILURE) {}
+  MOSDFailure(ceph_fsid &fs, entity_inst_t fr, entity_inst_t f, epoch_t e) : 
     Message(MSG_OSD_FAILURE),
-    from(fr), failed(f), epoch(e) {}
+    fsid(fs), from(fr), failed(f), epoch(e) {}
  
   entity_inst_t get_from() { return from; }
   entity_inst_t get_failed() { return failed; }
@@ -36,11 +37,13 @@ class MOSDFailure : public Message {
 
   void decode_payload() {
     int off = 0;
+    ::_decode(fsid, payload, off);
     ::_decode(from, payload, off);
     ::_decode(failed, payload, off);
     ::_decode(epoch, payload, off);
   }
   void encode_payload() {
+    ::_encode(fsid, payload);
     ::_encode(from, payload);
     ::_encode(failed, payload);
     ::_encode(epoch, payload);
index bd4dd586e5ee8ad9c6a1ccc4795b9915107d475f..8111964777ad44006199ff2b8d59995ef61b2af7 100644 (file)
 
 class MOSDGetMap : public Message {
  public:
+  ceph_fsid fsid;
   epoch_t start, want;
 
-  MOSDGetMap(epoch_t s=0, epoch_t w=0) : 
+  MOSDGetMap() : Message(CEPH_MSG_OSD_GETMAP) {}
+  MOSDGetMap(ceph_fsid& f, epoch_t s=0, epoch_t w=0) : 
     Message(CEPH_MSG_OSD_GETMAP),
-    start(s), want(w) { }
+    fsid(f), start(s), want(w) { }
 
   epoch_t get_start_epoch() { return start; }
   epoch_t get_want_epoch() { return want; }
index 9b9f7a94dace2a2fcece09c440f070a963c0c71f..1b7784dff80a37cedeca4220fc1bd94f4b17b44e 100644 (file)
@@ -193,6 +193,12 @@ void Monitor::lose_election(epoch_t epoch, int l)
 
 void Monitor::handle_command(MMonCommand *m)
 {
+  if (!ceph_fsid_equal(&m->fsid, &monmap->fsid)) {
+    dout(0) << "handle_command on fsid " << m->fsid << " != " << monmap->fsid << dendl;
+    reply_command(m, -EPERM, "wrong fsid");
+    return;
+  }
+
   dout(0) << "handle_command " << *m << dendl;
   string rs;
   if (!m->cmd.empty()) {
index 295757fc36b2439c0105ae3e4abdf4fcbd3b0e32..4e4018c36f0fbbe635f442db057c01bb51728489 100644 (file)
@@ -344,6 +344,11 @@ void OSDMonitor::handle_osd_getmap(MOSDGetMap *m)
 {
   dout(7) << "handle_osd_getmap from " << m->get_source() << " from " << m->get_start_epoch() << dendl;
   
+  if (!ceph_fsid_equal(&m->fsid, &mon->monmap->fsid)) {
+    dout(0) << "handle_osd_getmap on fsid " << m->fsid << " != " << mon->monmap->fsid << dendl;
+    delete m;
+  }
+
   if (m->get_start_epoch()) {
     if (m->get_want_epoch() <= osdmap.get_epoch())
        send_incremental(m->get_source_inst(), m->get_start_epoch());
@@ -365,6 +370,12 @@ void OSDMonitor::handle_osd_getmap(MOSDGetMap *m)
 
 bool OSDMonitor::preprocess_failure(MOSDFailure *m)
 {
+  if (!ceph_fsid_equal(&m->fsid, &mon->monmap->fsid)) {
+    dout(0) << "preprocess_failure on fsid " << m->fsid << " != " << mon->monmap->fsid << dendl;
+    delete m;
+    return true;
+  }
+
   /*
    * FIXME
    * this whole thing needs a rework of some sort.  we shouldn't
@@ -394,6 +405,7 @@ bool OSDMonitor::preprocess_failure(MOSDFailure *m)
     dout(5) << "preprocess_failure dne(/dup?): " << m->get_failed() << ", from " << m->get_from() << dendl;
     if (m->get_epoch() < osdmap.get_epoch())
       send_incremental(m->get_from(), m->get_epoch()+1);
+    delete m;
     return true;
   }
   if (osdmap.get_inst(badboy) != m->get_failed()) {
@@ -401,6 +413,7 @@ bool OSDMonitor::preprocess_failure(MOSDFailure *m)
            << ", from " << m->get_from() << dendl;
     if (m->get_epoch() < osdmap.get_epoch())
       send_incremental(m->get_from(), m->get_epoch()+1);
+    delete m;
     return true;
   }
   // already reported?
@@ -408,6 +421,7 @@ bool OSDMonitor::preprocess_failure(MOSDFailure *m)
     dout(5) << "preprocess_failure dup: " << m->get_failed() << ", from " << m->get_from() << dendl;
     if (m->get_epoch() < osdmap.get_epoch())
       send_incremental(m->get_from(), m->get_epoch()+1);
+    delete m;
     return true;
   }
 
@@ -446,6 +460,12 @@ void OSDMonitor::_reported_failure(MOSDFailure *m)
 
 bool OSDMonitor::preprocess_boot(MOSDBoot *m)
 {
+  if (!ceph_fsid_equal(&m->sb.fsid, &mon->monmap->fsid)) {
+    dout(0) << "preprocess_boot on fsid " << m->sb.fsid << " != " << mon->monmap->fsid << dendl;
+    delete m;
+    return true;
+  }
+
   assert(m->inst.name.is_osd());
   int from = m->inst.name.num();
   
index bbbb92b10a3a906e5c7653044f66a521ca2c5b56..255edd1e37e4bca189c1253db21dcfb4575fcf24 100644 (file)
@@ -883,7 +883,7 @@ void OSD::heartbeat()
        dout(0) << "no heartbeat from osd" << *p << " since " << heartbeat_from_stamp[*p]
                << " (cutoff " << grace << ")" << dendl;
        int mon = monmap->pick_mon();
-       messenger->send_message(new MOSDFailure(messenger->get_myinst(), osdmap->get_inst(*p), osdmap->get_epoch()),
+       messenger->send_message(new MOSDFailure(monmap->fsid, messenger->get_myinst(), osdmap->get_inst(*p), osdmap->get_epoch()),
                                monmap->get_inst(mon));
       }
     } else
@@ -1165,7 +1165,8 @@ void OSD::ms_handle_failure(Message *m, const entity_inst_t& inst)
              << ", dropping and reporting to mon" << mon 
              << " " << *m
              << dendl;
-      messenger->send_message(new MOSDFailure(messenger->get_myinst(), inst, osdmap->get_epoch()),
+      messenger->send_message(new MOSDFailure(monmap->fsid, messenger->get_myinst(), inst, 
+                                             osdmap->get_epoch()),
                              monmap->get_inst(mon));
     }
     delete m;
@@ -1213,7 +1214,7 @@ void OSD::wait_for_new_map(Message *m)
   // ask 
   if (waiting_for_osdmap.empty()) {
     int mon = monmap->pick_mon();
-    messenger->send_message(new MOSDGetMap(osdmap->get_epoch()+1),
+    messenger->send_message(new MOSDGetMap(osdmap->get_fsid(), osdmap->get_epoch()+1),
                             monmap->get_inst(mon));
   }
   
@@ -1371,7 +1372,7 @@ void OSD::handle_osd_map(MOSDMap *m)
     else {
       dout(10) << "handle_osd_map missing epoch " << cur+1 << dendl;
       int mon = monmap->pick_mon();
-      messenger->send_message(new MOSDGetMap(cur+1), monmap->get_inst(mon));
+      messenger->send_message(new MOSDGetMap(monmap->fsid, cur+1), monmap->get_inst(mon));
       break;
     }
 
index 90be9b57a394b4b3bb2862245c5ac6075b8e27e6..3f5bad4c245f85eda4d4babedac06b5f61dcf301 100644 (file)
@@ -107,7 +107,7 @@ void Objecter::handle_osd_map(MOSDMap *m)
       else {
         dout(3) << "handle_osd_map requesting missing epoch " << osdmap->get_epoch()+1 << dendl;
         int mon = monmap->pick_mon();
-        messenger->send_message(new MOSDGetMap(osdmap->get_epoch()+1), 
+        messenger->send_message(new MOSDGetMap(osdmap->get_fsid(), osdmap->get_epoch()+1), 
                                 monmap->get_inst(mon));
         break;
       }
@@ -140,7 +140,7 @@ void Objecter::maybe_request_map()
   dout(10) << "maybe_request_map requesting next osd map" << dendl;
   last_epoch_requested_stamp = now;
   last_epoch_requested = osdmap->get_epoch()+1;
-  messenger->send_message(new MOSDGetMap(osdmap->get_epoch(), last_epoch_requested),
+  messenger->send_message(new MOSDGetMap(osdmap->get_fsid(), osdmap->get_epoch(), last_epoch_requested),
                          monmap->get_inst(monmap->pick_mon()));
 }
 
@@ -999,7 +999,8 @@ void Objecter::ms_handle_failure(Message *m, entity_name_t dest, const entity_in
       dout(0) << "ms_handle_failure " << dest << " inst " << inst 
              << ", dropping, reporting to mon" << mon 
              << dendl;
-      messenger->send_message(new MOSDFailure(messenger->get_myinst(), inst, osdmap->get_epoch()), 
+      messenger->send_message(new MOSDFailure(monmap->fsid, messenger->get_myinst(), inst, 
+                                             osdmap->get_epoch()), 
                              monmap->get_inst(mon));
     }
     delete m;