diff --git a/src/kernel/mds_client.c b/src/kernel/mds_client.c index c34b7afe637..8b839f8a5fb 100644 --- a/src/kernel/mds_client.c +++ b/src/kernel/mds_client.c @@ -1627,8 +1627,15 @@ void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, struct ceph_msg *msg) struct ceph_mdsmap *newmap, *oldmap; int from = le32_to_cpu(msg->hdr.src.name.num); int newstate; + struct ceph_fsid fsid; - ceph_decode_need(&p, end, 2*sizeof(__u32), bad); + ceph_decode_need(&p, end, sizeof(fsid)+2*sizeof(__u32), bad); + ceph_decode_64(&p, fsid.major); + ceph_decode_64(&p, fsid.minor); + if (!ceph_fsid_equal(&fsid, &mdsc->client->monc.monmap->fsid)) { + derr(0, "got mdsmap with wrong fsid\n"); + return; + } ceph_decode_32(&p, epoch); ceph_decode_32(&p, maplen); dout(2, "handle_map epoch %u len %d\n", epoch, (int)maplen); diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index 67c9242b7eb..d9a21a3fac6 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -237,7 +237,7 @@ void MDS::send_message_mds(Message *m, int mds) { // send mdsmap first? if (peer_mdsmap_epoch[mds] < mdsmap->get_epoch()) { - messenger->send_message(new MMDSMap(mdsmap), + messenger->send_message(new MMDSMap(monmap->fsid, mdsmap), mdsmap->get_inst(mds)); peer_mdsmap_epoch[mds] = mdsmap->get_epoch(); } @@ -659,7 +659,7 @@ void MDS::bcast_mds_map() for (set::const_iterator p = clients.begin(); p != clients.end(); ++p) - messenger->send_message(new MMDSMap(mdsmap), (*p)->inst); + messenger->send_message(new MMDSMap(monmap->fsid, mdsmap), (*p)->inst); last_client_mdsmap_bcast = mdsmap->get_epoch(); } diff --git a/src/messages/MMDSMap.h b/src/messages/MMDSMap.h index 064fa737056..0ec0ae41497 100644 --- a/src/messages/MMDSMap.h +++ b/src/messages/MMDSMap.h @@ -44,7 +44,8 @@ class MMDSMap : public Message { return e; } */ - + + ceph_fsid fsid; epoch_t epoch; bufferlist encoded; @@ -53,8 +54,9 @@ class MMDSMap : public Message { MMDSMap() : Message(CEPH_MSG_MDS_MAP) {} - MMDSMap(MDSMap *mm) : - Message(CEPH_MSG_MDS_MAP) { + MMDSMap(ceph_fsid &f, MDSMap *mm) : + Message(CEPH_MSG_MDS_MAP), + fsid(f) { epoch = mm->get_epoch(); mm->encode(encoded); } @@ -67,10 +69,12 @@ class MMDSMap : public Message { // marshalling void decode_payload() { int off = 0; + ::_decode(fsid, payload, off); ::_decode(epoch, payload, off); ::_decode(encoded, payload, off); } void encode_payload() { + ::_encode(fsid, payload); ::_encode(epoch, payload); ::_encode(encoded, payload); } diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index af942681bba..ed6dee85739 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -604,7 +604,7 @@ void MDSMonitor::bcast_latest_mds() void MDSMonitor::send_full(entity_inst_t dest) { dout(11) << "send_full to " << dest << dendl; - mon->messenger->send_message(new MMDSMap(&mdsmap), dest); + mon->messenger->send_message(new MMDSMap(mon->monmap->fsid, &mdsmap), dest); } void MDSMonitor::send_to_waiting()