summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCasey Bodley <cbodley@redhat.com>2015-08-17 22:31:10 +0200
committerSage Weil <sage@redhat.com>2017-05-05 19:59:46 +0200
commit612d15bc1b256f33da4b1bacd81351cc5e0ce96f (patch)
treef4aca848ef8cdee9c688f052e9b1fe037d1a5bd6
parentmsg: pass Connection to decode_message (diff)
downloadceph-612d15bc1b256f33da4b1bacd81351cc5e0ce96f.tar.xz
ceph-612d15bc1b256f33da4b1bacd81351cc5e0ce96f.zip
blkin: Messenger integration
Signed-off-by: Casey Bodley <cbodley@redhat.com>
-rw-r--r--src/common/common_init.cc1
-rwxr-xr-xsrc/include/ceph_features.h11
-rw-r--r--src/msg/Message.cc37
-rw-r--r--src/msg/Message.h7
-rw-r--r--src/msg/Messenger.cc23
-rw-r--r--src/msg/Messenger.h19
6 files changed, 96 insertions, 2 deletions
diff --git a/src/common/common_init.cc b/src/common/common_init.cc
index 161af4e5a40..d796e933c4b 100644
--- a/src/common/common_init.cc
+++ b/src/common/common_init.cc
@@ -25,6 +25,7 @@
#include "common/valgrind.h"
#include "common/version.h"
#include "common/strtol.h"
+#include "common/zipkin_trace.h"
#include "include/color.h"
#include <errno.h>
diff --git a/src/include/ceph_features.h b/src/include/ceph_features.h
index 68a55d05d3a..c5578161a93 100755
--- a/src/include/ceph_features.h
+++ b/src/include/ceph_features.h
@@ -161,6 +161,7 @@ DEFINE_CEPH_FEATURE(58, 1, FS_FILE_LAYOUT_V2) // overlap
DEFINE_CEPH_FEATURE(59, 1, FS_BTIME)
DEFINE_CEPH_FEATURE(59, 1, FS_CHANGE_ATTR) // overlap
DEFINE_CEPH_FEATURE(59, 1, MSG_ADDR2) // overlap
+DEFINE_CEPH_FEATURE(60, 1, BLKIN_TRACING) // *do not share this bit*
DEFINE_CEPH_FEATURE(61, 1, RESERVED2) // unused, but slow down!
DEFINE_CEPH_FEATURE(62, 1, RESERVED) // do not use; used as a sentinal
@@ -168,6 +169,15 @@ DEFINE_CEPH_FEATURE_DEPRECATED(63, 1, RESERVED_BROKEN, LUMINOUS) // client-facin
/*
+ * conditionally include blkin in CEPH_FEATURES_ALL/SUPPORTED_DEFAULT
+ */
+#ifdef WITH_BLKIN
+#define CEPH_FEATURES_BLKIN CEPH_FEATURE_BLKIN_TRACING
+#else
+#define CEPH_FEATURES_BLKIN 0
+#endif
+
+/*
* Features supported. Should be everything above.
*/
#define CEPH_FEATURES_ALL \
@@ -227,6 +237,7 @@ DEFINE_CEPH_FEATURE_DEPRECATED(63, 1, RESERVED_BROKEN, LUMINOUS) // client-facin
CEPH_FEATURE_SERVER_LUMINOUS | \
CEPH_FEATURE_RESEND_ON_SPLIT | \
CEPH_FEATURE_RADOS_BACKOFF | \
+ CEPH_FEATURES_BLKIN | \
0ULL)
#define CEPH_FEATURES_SUPPORTED_DEFAULT CEPH_FEATURES_ALL
diff --git a/src/msg/Message.cc b/src/msg/Message.cc
index bac97fc0da9..bcc4ad0425a 100644
--- a/src/msg/Message.cc
+++ b/src/msg/Message.cc
@@ -842,6 +842,43 @@ Message *decode_message(CephContext *cct, int crcflags,
}
+WRITE_RAW_ENCODER(blkin_trace_info)
+
+void Message::encode_trace(bufferlist &bl, uint64_t features) const
+{
+#ifdef WITH_BLKIN
+ if (features & CEPH_FEATURE_BLKIN_TRACING)
+ ::encode(*trace.get_info(), bl);
+#endif
+}
+
+void Message::decode_trace(bufferlist::iterator &p, bool create)
+{
+#ifdef WITH_BLKIN
+ if (!connection)
+ return;
+
+ const auto endpoint = connection->get_messenger()->get_trace_endpoint();
+ blkin_trace_info info = {};
+
+ // only decode a trace if both sides of the connection agree
+ if (connection->has_feature(CEPH_FEATURE_BLKIN_TRACING))
+ ::decode(info, p);
+
+ if (info.trace_id) {
+ trace.init(get_type_name(), endpoint, &info, true);
+ trace.event("decoded trace");
+ } else if (create) { // create a trace even if we didn't get one on the wire
+ trace.init(get_type_name(), endpoint);
+ trace.event("created trace");
+ }
+ trace.keyval("tid", get_tid());
+ trace.keyval("entity type", get_source().type_str());
+ trace.keyval("entity num", get_source().num());
+#endif
+}
+
+
// This routine is not used for ordinary messages, but only when encapsulating a message
// for forwarding and routing. It's also used in a backward compatibility test, which only
// effectively tests backward compability for those functions. To avoid backward compatibility
diff --git a/src/msg/Message.h b/src/msg/Message.h
index c37cd475a73..b3a836c12d4 100644
--- a/src/msg/Message.h
+++ b/src/msg/Message.h
@@ -26,6 +26,7 @@
#include "include/types.h"
#include "include/buffer.h"
#include "common/Throttle.h"
+#include "common/zipkin_trace.h"
#include "msg_types.h"
#include "common/RefCountedObj.h"
@@ -240,6 +241,11 @@ protected:
bi::list_member_hook<> dispatch_q;
public:
+ // zipkin tracing
+ ZTracer::Trace trace;
+ void encode_trace(bufferlist &bl, uint64_t features) const;
+ void decode_trace(bufferlist::iterator &p, bool create = false);
+
class CompletionHook : public Context {
protected:
Message *m;
@@ -297,6 +303,7 @@ protected:
if (byte_throttler)
byte_throttler->put(payload.length() + middle.length() + data.length());
release_message_throttle();
+ trace.event("message destructed");
/* call completion hooks (if any) */
if (completion_hook)
completion_hook->complete(0);
diff --git a/src/msg/Messenger.cc b/src/msg/Messenger.cc
index ca00e0bb5ca..6ab2862dc41 100644
--- a/src/msg/Messenger.cc
+++ b/src/msg/Messenger.cc
@@ -2,7 +2,9 @@
// vim: ts=8 sw=2 smarttab
#include <random>
+#include <netdb.h>
#include "include/Spinlock.h"
+
#include "include/types.h"
#include "Messenger.h"
@@ -48,6 +50,27 @@ Messenger *Messenger::create(CephContext *cct, const string &type,
return nullptr;
}
+void Messenger::set_endpoint_addr(const entity_addr_t& a,
+ const entity_name_t &name)
+{
+ size_t hostlen;
+ if (a.get_family() == AF_INET)
+ hostlen = sizeof(struct sockaddr_in);
+ else if (a.get_family() == AF_INET6)
+ hostlen = sizeof(struct sockaddr_in6);
+ else
+ hostlen = 0;
+
+ if (hostlen) {
+ char buf[NI_MAXHOST] = { 0 };
+ getnameinfo(a.get_sockaddr(), hostlen, buf, sizeof(buf),
+ NULL, 0, NI_NUMERICHOST);
+
+ trace_endpoint.copy_ip(buf);
+ }
+ trace_endpoint.set_port(a.get_port());
+}
+
/*
* Pre-calculate desired software CRC settings. CRC computation may
* be disabled by default for some transports (e.g., those with strong
diff --git a/src/msg/Messenger.h b/src/msg/Messenger.h
index c4df379939a..a186ec3c875 100644
--- a/src/msg/Messenger.h
+++ b/src/msg/Messenger.h
@@ -41,6 +41,10 @@ class Messenger {
private:
list<Dispatcher*> dispatchers;
list <Dispatcher*> fast_dispatchers;
+ ZTracer::Endpoint trace_endpoint;
+
+ void set_endpoint_addr(const entity_addr_t& a,
+ const entity_name_t &name);
protected:
/// the "name" of the local daemon. eg client.99
@@ -136,7 +140,8 @@ public:
* or use the create() function.
*/
Messenger(CephContext *cct_, entity_name_t w)
- : my_inst(),
+ : trace_endpoint("0.0.0.0", 0, "Messenger"),
+ my_inst(),
default_send_priority(CEPH_MSG_PRIO_DEFAULT), started(false),
magic(0),
socket_priority(-1),
@@ -213,9 +218,19 @@ protected:
/**
* set messenger's address
*/
- virtual void set_myaddr(const entity_addr_t& a) { my_inst.addr = a; }
+ virtual void set_myaddr(const entity_addr_t& a) {
+ my_inst.addr = a;
+ set_endpoint_addr(a, my_inst.name);
+ }
public:
/**
+ * @return the zipkin trace endpoint
+ */
+ const ZTracer::Endpoint* get_trace_endpoint() const {
+ return &trace_endpoint;
+ }
+
+ /**
* Retrieve the Messenger's name.
*
* @return A const reference to the name this Messenger