From: Matt Benjamin Date: Tue, 23 Dec 2014 20:45:16 +0000 (-0500) Subject: Add MDataPing. X-Git-Tag: v0.93~265^2~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=984a3eedabad2f76499a289d4d76ba6bce8908de;p=ceph.git Add MDataPing. This message type is used for Messenger testing. Signed-off-by: Matt Benjamin --- diff --git a/src/messages/MDataPing.h b/src/messages/MDataPing.h new file mode 100644 index 000000000000..91588d65191e --- /dev/null +++ b/src/messages/MDataPing.h @@ -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 + * + * 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 ∓ + } + + 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& buffers = data.buffers(); + list::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 */ diff --git a/src/msg/Message.cc b/src/msg/Message.cc index f103602a8b10..3df071d27992 100644 --- a/src/msg/Message.cc +++ b/src/msg/Message.cc @@ -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: diff --git a/src/msg/Message.h b/src/msg/Message.h index 0d45c2dc8f87..62e65886cadd 100644 --- a/src/msg/Message.h +++ b/src/msg/Message.h @@ -173,6 +173,8 @@ #define MSG_CRC_DATA 1 #define MSG_CRC_HEADER 2 +// Xio Testing +#define MSG_DATA_PING 0x602 // ======================================================