messages/MMonCommandAck.h\
messages/MMonElection.h\
messages/MMonGetMap.h\
+ messages/MMonGetVersion.h\
+ messages/MMonGetVersionReply.h\
messages/MMonGlobalID.h\
messages/MMonMap.h\
messages/MMonObserve.h\
#define CEPH_MSG_MON_SUBSCRIBE_ACK 16
#define CEPH_MSG_AUTH 17
#define CEPH_MSG_AUTH_REPLY 18
+#define CEPH_MSG_MON_GET_VERSION 19
+#define CEPH_MSG_MON_GET_VERSION_REPLY 20
/* client <-> mds */
#define CEPH_MSG_MDS_MAP 21
--- /dev/null
+// -*- 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) 2011 New Dream Network
+ *
+ * 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 CEPH_MMONGETVERSION_H
+#define CEPH_MMONGETVERSION_H
+
+#include "msg/Message.h"
+
+#include "include/types.h"
+
+/*
+ * This message is sent to the monitors to verify that the client's
+ * version of the map(s) is the latest available. For example, this
+ * can be used to determine whether a pool actually does not exist, or
+ * if it may have been created but the map was not received yet.
+ */
+class MMonGetVersion : public Message {
+public:
+ MMonGetVersion() : Message(CEPH_MSG_MON_GET_VERSION) {}
+
+ const char *get_type_name() {
+ return "mon_get_version";
+ }
+
+ void print(ostream& o) {
+ o << "mon_get_version(what=" << what << " handle=" << handle << ")";
+ }
+
+ void encode_payload(CephContext *cct) {
+ ::encode(handle, payload);
+ ::encode(what, payload);
+ }
+
+ void decode_payload(CephContext *cct) {
+ bufferlist::iterator p = payload.begin();
+ ::decode(handle, p);
+ ::decode(what, p);
+ }
+
+ tid_t handle;
+ string what;
+
+private:
+ ~MMonGetVersion() {}
+};
+
+#endif
--- /dev/null
+// -*- 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) 2011 New Dream Network
+ *
+ * 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 CEPH_MMONGETVERSIONREPLY_H
+#define CEPH_MMONGETVERSIONREPLY_H
+
+#include "msg/Message.h"
+
+#include "include/types.h"
+
+/*
+ * This message is sent from the monitors to clients in response to a
+ * MMonGetVersion. The latest version of the requested thing is sent
+ * back.
+ */
+class MMonGetVersionReply : public Message {
+public:
+ MMonGetVersionReply() : Message(CEPH_MSG_MON_GET_VERSION_REPLY) {}
+
+ const char *get_type_name() {
+ return "mon_check_map_ack";
+ }
+
+ void print(ostream& o) {
+ o << "mon_check_map_ack(handle=" << handle << " version=" << version << ")";
+ }
+
+ void encode_payload(CephContext *cct) {
+ ::encode(handle, payload);
+ ::encode(version, payload);
+ }
+
+ void decode_payload(CephContext *cct) {
+ bufferlist::iterator p = payload.begin();
+ ::decode(handle, p);
+ ::decode(version, p);
+ }
+
+ tid_t handle;
+ version_t version;
+
+private:
+ ~MMonGetVersionReply() {}
+};
+
+#endif
#include "messages/PaxosServiceMessage.h"
#include "messages/MMonMap.h"
#include "messages/MMonGetMap.h"
+#include "messages/MMonGetVersion.h"
+#include "messages/MMonGetVersionReply.h"
#include "messages/MGenericMessage.h"
#include "messages/MMonCommand.h"
#include "messages/MMonCommandAck.h"
#include "common/DoutStreambuf.h"
#include "common/errno.h"
#include "include/color.h"
+#include "include/ceph_fs.h"
#include "OSDMonitor.h"
#include "MDSMonitor.h"
handle_mon_get_map((MMonGetMap*)m);
break;
+ case CEPH_MSG_MON_GET_VERSION:
+ handle_get_version((MMonGetVersion*)m);
+ break;
+
case MSG_MON_COMMAND:
handle_command((MMonCommand*)m);
break;
m->put();
}
+void Monitor::handle_get_version(MMonGetVersion *m)
+{
+ dout(10) << "handle_get_version " << *m << dendl;
+
+ MonSession *s = (MonSession *)m->get_connection()->get_priv();
+ if (!s) {
+ dout(10) << " no session, dropping" << dendl;
+ m->put();
+ return;
+ }
+
+ MMonGetVersionReply *reply = new MMonGetVersionReply();
+ reply->handle = m->handle;
+
+ if (m->what == "mdsmap") {
+ reply->version = mdsmon()->mdsmap.get_epoch();
+ } else if (m->what == "osdmap") {
+ reply->version = osdmon()->osdmap.get_epoch();
+ } else if (m->what == "monmap") {
+ reply->version = monmap->get_epoch();
+ } else {
+ derr << "invalid map type " << m->what << dendl;
+ }
+
+ messenger->send_message(reply, m->get_source_inst());
+
+ s->put();
+ m->put();
+}
+
bool Monitor::ms_handle_reset(Connection *con)
{
dout(10) << "ms_handle_reset " << con << " " << con->get_peer_addr() << dendl;
class PaxosService;
class MMonGetMap;
+class MMonGetVersion;
class MMonObserve;
class MMonSubscribe;
class MAuthRotating;
// messages
+ void handle_get_version(MMonGetVersion *m);
void handle_subscribe(MMonSubscribe *m);
void handle_mon_get_map(MMonGetMap *m);
void handle_command(class MMonCommand *m);
#include "messages/MMonMap.h"
#include "messages/MMonGetMap.h"
+#include "messages/MMonGetVersion.h"
+#include "messages/MMonGetVersionReply.h"
#include "messages/MAuth.h"
#include "messages/MAuthReply.h"
case CEPH_MSG_MON_GET_MAP:
m = new MMonGetMap;
break;
+ case CEPH_MSG_MON_GET_VERSION:
+ m = new MMonGetVersion();
+ break;
+ case CEPH_MSG_MON_GET_VERSION_REPLY:
+ m = new MMonGetVersionReply();
+ break;
case MSG_OSD_BOOT:
m = new MOSDBoot();