]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Add MDataPing.
authorMatt Benjamin <matt@cohortfs.com>
Tue, 23 Dec 2014 20:45:16 +0000 (15:45 -0500)
committerMatt Benjamin <matt@cohortfs.com>
Wed, 14 Jan 2015 21:42:03 +0000 (16:42 -0500)
This message type is used for Messenger testing.

Signed-off-by: Matt Benjamin <matt@cohortfs.com>
src/messages/MDataPing.h [new file with mode: 0644]
src/msg/Message.cc
src/msg/Message.h

diff --git a/src/messages/MDataPing.h b/src/messages/MDataPing.h
new file mode 100644 (file)
index 0000000..91588d6
--- /dev/null
@@ -0,0 +1,92 @@
+// -*- 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 CEPH_MDATAPING_H
+#define CEPH_MDATAPING_H
+
+#if defined(HAVE_XIO)
+
+#include "msg/Message.h"
+#include "messages/MPing.h"
+extern "C" {
+#include "libxio.h"
+}
+
+typedef void (*mdata_hook_func)(struct xio_mempool_obj *mp);
+
+
+class MDataPing : public Message {
+
+ public:
+
+  static const int HEAD_VERSION = 1;
+  static const int COMPAT_VERSION = 1;
+
+  std::string tag;
+  uint32_t counter;
+  mdata_hook_func mdata_hook;
+  struct xio_mempool_obj mp;
+  bool free_data;
+
+  MDataPing()
+    : Message(MSG_DATA_PING, HEAD_VERSION, COMPAT_VERSION),
+      mdata_hook(NULL),
+      free_data(false)
+  {}
+
+  struct xio_mempool_obj *get_mp()
+    {
+      return &mp;
+    }
+
+  void set_rdma_hook(mdata_hook_func hook)
+    {
+      mdata_hook = hook;
+    }
+
+private:
+  ~MDataPing()
+    {
+      if (mdata_hook)
+       mdata_hook(&mp);
+
+      if (free_data)  {
+       const std::list<buffer::ptr>& buffers = data.buffers();
+       list<bufferptr>::const_iterator pb;
+       for (pb = buffers.begin(); pb != buffers.end(); ++pb) {
+         free((void*) pb->c_str());
+       }
+      }
+    }
+
+public:
+  void decode_payload() {
+    bufferlist::iterator p = payload.begin();
+    ::decode(tag, p);
+    ::decode(counter, p);
+  }
+  void encode_payload(uint64_t features) {
+    ::encode(tag, payload);
+    ::encode(counter, payload);
+  }
+
+  const char *get_type_name() const { return "data_ping"; }
+
+  void print(ostream& out) const {
+    out << get_type_name() << " " << tag << " " << counter;
+  }
+};
+
+#endif /* HAVE_XIO */
+#endif /* CEPH_MDATAPING_H */
index f103602a8b1027d0e85d1878b9a8115b9ed42623..3df071d27992838752ebd1897192b6afe39bc3e5 100644 (file)
@@ -90,7 +90,7 @@ using namespace std;
 #include "messages/MMonGetVersion.h"
 #include "messages/MMonGetVersionReply.h"
 #include "messages/MMonHealth.h"
-
+#include "messages/MDataPing.h"
 #include "messages/MAuth.h"
 #include "messages/MAuthReply.h"
 #include "messages/MMonSubscribe.h"
@@ -696,7 +696,11 @@ Message *decode_message(CephContext *cct, int crcflags,
   case MSG_MON_HEALTH:
     m = new MMonHealth();
     break;
-
+#if defined(HAVE_XIO)
+  case MSG_DATA_PING:
+    m = new MDataPing();
+    break;
+#endif
     // -- simple messages without payload --
 
   case CEPH_MSG_SHUTDOWN:
index 0d45c2dc8f8747cd2550b951cbf257c08ad63b98..62e65886cadd41b78c459e48c128f99c04309562 100644 (file)
 #define MSG_CRC_DATA           1
 #define MSG_CRC_HEADER         2
 
+// Xio Testing
+#define MSG_DATA_PING            0x602
 
 // ======================================================