]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
blkin: add traces to librados and Objecter
authorCasey Bodley <cbodley@redhat.com>
Fri, 23 Oct 2015 13:33:36 +0000 (09:33 -0400)
committerSage Weil <sage@redhat.com>
Fri, 5 May 2017 18:05:24 +0000 (14:05 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/librados/IoCtxImpl.cc
src/librados/IoCtxImpl.h
src/librados/librados.cc
src/osdc/Objecter.cc
src/osdc/Objecter.h

index 29937022acd4528fb3fb33bec593de4203c288f3..61c89f3291511d839cd672f8eaa27ac7cd0deaff 100644 (file)
@@ -816,7 +816,7 @@ int librados::IoCtxImpl::aio_operate(const object_t& oid,
 
 int librados::IoCtxImpl::aio_read(const object_t oid, AioCompletionImpl *c,
                                  bufferlist *pbl, size_t len, uint64_t off,
-                                 uint64_t snapid)
+                                 uint64_t snapid, const blkin_trace_info *info)
 {
   FUNCTRACE();
   if (len > (size_t) INT_MAX)
@@ -832,17 +832,21 @@ int librados::IoCtxImpl::aio_read(const object_t oid, AioCompletionImpl *c,
   c->io = this;
   c->blp = pbl;
 
+  ZTracer::Trace trace;
+  if (info)
+    trace.init("rados read", &objecter->trace_endpoint, info);
+
   Objecter::Op *o = objecter->prepare_read_op(
     oid, oloc,
     off, len, snapid, pbl, 0,
-    oncomplete, &c->objver);
+    oncomplete, &c->objver, nullptr, 0, &trace);
   objecter->op_submit(o, &c->tid);
   return 0;
 }
 
 int librados::IoCtxImpl::aio_read(const object_t oid, AioCompletionImpl *c,
                                  char *buf, size_t len, uint64_t off,
-                                 uint64_t snapid)
+                                 uint64_t snapid, const blkin_trace_info *info)
 {
   FUNCTRACE();
   if (len > (size_t) INT_MAX)
@@ -861,10 +865,14 @@ int librados::IoCtxImpl::aio_read(const object_t oid, AioCompletionImpl *c,
   c->blp = &c->bl;
   c->out_buf = buf;
 
+  ZTracer::Trace trace;
+  if (info)
+    trace.init("rados read", &objecter->trace_endpoint, info);
+
   Objecter::Op *o = objecter->prepare_read_op(
     oid, oloc,
     off, len, snapid, &c->bl, 0,
-    oncomplete, &c->objver);
+    oncomplete, &c->objver, nullptr, 0, &trace);
   objecter->op_submit(o, &c->tid);
   return 0;
 }
@@ -959,7 +967,7 @@ int librados::IoCtxImpl::aio_cmpext(const object_t& oid,
 
 int librados::IoCtxImpl::aio_write(const object_t &oid, AioCompletionImpl *c,
                                   const bufferlist& bl, size_t len,
-                                  uint64_t off)
+                                  uint64_t off, const blkin_trace_info *info)
 {
   FUNCTRACE();
   auto ut = ceph::real_clock::now();
@@ -977,13 +985,17 @@ int librados::IoCtxImpl::aio_write(const object_t &oid, AioCompletionImpl *c,
 #if defined(WITH_LTTNG) && defined(WITH_EVENTTRACE)
   ((C_aio_Complete *) oncomplete)->oid = oid;
 #endif
+  ZTracer::Trace trace;
+  if (info)
+    trace.init("rados write", &objecter->trace_endpoint, info);
+
   c->io = this;
   queue_aio_write(c);
 
   Objecter::Op *o = objecter->prepare_write_op(
     oid, oloc,
     off, len, snapc, bl, ut, 0,
-    oncomplete, &c->objver);
+    oncomplete, &c->objver, nullptr, 0, &trace);
   objecter->op_submit(o, &c->tid);
 
   return 0;
index 92989fc46d92b3438e89bb62ec401020650a17ac..2d2a2201d04eabd6fa43189d72faff43731fb0b6 100644 (file)
@@ -18,6 +18,7 @@
 #include "common/Cond.h"
 #include "common/Mutex.h"
 #include "common/snap_types.h"
+#include "common/zipkin_trace.h"
 #include "include/atomic.h"
 #include "include/types.h"
 #include "include/rados/librados.h"
@@ -186,9 +187,11 @@ struct librados::IoCtxImpl {
   };
 
   int aio_read(const object_t oid, AioCompletionImpl *c,
-              bufferlist *pbl, size_t len, uint64_t off, uint64_t snapid);
+              bufferlist *pbl, size_t len, uint64_t off, uint64_t snapid,
+              const blkin_trace_info *info = nullptr);
   int aio_read(object_t oid, AioCompletionImpl *c,
-              char *buf, size_t len, uint64_t off, uint64_t snapid);
+              char *buf, size_t len, uint64_t off, uint64_t snapid,
+              const blkin_trace_info *info = nullptr);
   int aio_sparse_read(const object_t oid, AioCompletionImpl *c,
                      std::map<uint64_t,uint64_t> *m, bufferlist *data_bl,
                      size_t len, uint64_t off, uint64_t snapid);
@@ -197,7 +200,8 @@ struct librados::IoCtxImpl {
   int aio_cmpext(const object_t& oid, AioCompletionImpl *c,
                      const char *cmp_buf, size_t cmp_len, uint64_t off);
   int aio_write(const object_t &oid, AioCompletionImpl *c,
-               const bufferlist& bl, size_t len, uint64_t off);
+               const bufferlist& bl, size_t len, uint64_t off,
+               const blkin_trace_info *info = nullptr);
   int aio_append(const object_t &oid, AioCompletionImpl *c,
                 const bufferlist& bl, size_t len);
   int aio_write_full(const object_t &oid, AioCompletionImpl *c,
index 271ec3859e0a1bee969e27c4224e0544faa398de..126e82217c944fd0b11de702f9fec41e94649871 100644 (file)
@@ -4546,6 +4546,22 @@ extern "C" int rados_aio_read(rados_ioctx_t io, const char *o,
   return retval;
 }
 
+#ifdef WITH_BLKIN
+extern "C" int rados_aio_read_traced(rados_ioctx_t io, const char *o,
+                                    rados_completion_t completion,
+                                    char *buf, size_t len, uint64_t off,
+                                    struct blkin_trace_info *info)
+{
+  tracepoint(librados, rados_aio_read_enter, io, o, completion, len, off);
+  librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+  object_t oid(o);
+  int retval = ctx->aio_read(oid, (librados::AioCompletionImpl*)completion,
+                             buf, len, off, ctx->snap_seq, info);
+  tracepoint(librados, rados_aio_read_exit, retval);
+  return retval;
+}
+#endif
+
 extern "C" int rados_aio_write(rados_ioctx_t io, const char *o,
                                rados_completion_t completion,
                                const char *buf, size_t len, uint64_t off)
@@ -4563,6 +4579,26 @@ extern "C" int rados_aio_write(rados_ioctx_t io, const char *o,
   return retval;
 }
 
+#ifdef WITH_BLKIN
+extern "C" int rados_aio_write_traced(rados_ioctx_t io, const char *o,
+                                      rados_completion_t completion,
+                                      const char *buf, size_t len, uint64_t off,
+                                      struct blkin_trace_info *info)
+{
+  tracepoint(librados, rados_aio_write_enter, io, o, completion, buf, len, off);
+  if (len > UINT_MAX/2)
+    return -E2BIG;
+  librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+  object_t oid(o);
+  bufferlist bl;
+  bl.append(buf, len);
+  int retval = ctx->aio_write(oid, (librados::AioCompletionImpl*)completion,
+                              bl, len, off, info);
+  tracepoint(librados, rados_aio_write_exit, retval);
+  return retval;
+}
+#endif
+
 extern "C" int rados_aio_append(rados_ioctx_t io, const char *o,
                                rados_completion_t completion,
                                const char *buf, size_t len)
index 75cf64ece1c5d75feca34f4e855165ceba866f2c..bdb189ab5e6d660a2b941eb1c9c06e36989187ce 100644 (file)
@@ -3090,6 +3090,7 @@ MOSDOp *Objecter::_prepare_osd_op(Op *op)
   m->ops = op->ops;
   m->set_mtime(op->mtime);
   m->set_retry_attempt(op->attempts++);
+  m->trace = op->trace;
 
   if (op->priority)
     m->set_priority(op->priority);
index abbc8d8116ce3b476376005782cbbe2099833e49..216443ee609049f8b1289c847bbdda0f3615cc93 100644 (file)
 #include "common/ceph_timer.h"
 #include "common/Finisher.h"
 #include "common/shunique_lock.h"
+#include "common/zipkin_trace.h"
 
 #include "messages/MOSDOp.h"
 #include "osd/OSDMap.h"
 
-
 using namespace std;
 
 class Context;
@@ -1173,6 +1173,7 @@ public:
   Messenger *messenger;
   MonClient *monc;
   Finisher *finisher;
+  ZTracer::Endpoint trace_endpoint;
 private:
   OSDMap    *osdmap;
 public:
@@ -1345,9 +1346,11 @@ public:
     int *data_offset;
 
     osd_reqid_t reqid; // explicitly setting reqid
+    ZTracer::Trace trace;
 
     Op(const object_t& o, const object_locator_t& ol, vector<OSDOp>& op,
-       int f, Context *fin, version_t *ov, int *offset = NULL) :
+       int f, Context *fin, version_t *ov, int *offset = NULL,
+       ZTracer::Trace *parent_trace = nullptr) :
       session(NULL), incarnation(0),
       target(o, ol, f),
       con(NULL),
@@ -1380,6 +1383,9 @@ public:
 
       if (target.base_oloc.key == o)
        target.base_oloc.key.clear();
+
+      if (parent_trace && parent_trace->valid())
+        trace.init("op", nullptr, parent_trace);
     }
 
     bool operator<(const Op& other) const {
@@ -1967,6 +1973,7 @@ private:
           double mon_timeout,
           double osd_timeout) :
     Dispatcher(cct_), messenger(m), monc(mc), finisher(fin),
+    trace_endpoint("0.0.0.0", 0, "Objecter"),
     osdmap(new OSDMap), initialized(0), last_tid(0), client_inc(-1),
     max_linger_id(0), num_in_flight(0), global_op_flags(0),
     keep_balanced_budget(false), honor_osdmap_full(true), osdmap_full_try(false),
@@ -2350,7 +2357,8 @@ public:
     const object_t& oid, const object_locator_t& oloc,
     uint64_t off, uint64_t len, snapid_t snap, bufferlist *pbl,
     int flags, Context *onfinish, version_t *objver = NULL,
-    ObjectOperation *extra_ops = NULL, int op_flags = 0) {
+    ObjectOperation *extra_ops = NULL, int op_flags = 0,
+    ZTracer::Trace *parent_trace = nullptr) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_READ;
@@ -2360,7 +2368,7 @@ public:
     ops[i].op.extent.truncate_seq = 0;
     ops[i].op.flags = op_flags;
     Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
-                  CEPH_OSD_FLAG_READ, onfinish, objver);
+                  CEPH_OSD_FLAG_READ, onfinish, objver, nullptr, parent_trace);
     o->snapid = snap;
     o->outbl = pbl;
     return o;
@@ -2515,7 +2523,8 @@ public:
     uint64_t off, uint64_t len, const SnapContext& snapc,
     const bufferlist &bl, ceph::real_time mtime, int flags,
     Context *oncommit, version_t *objver = NULL,
-    ObjectOperation *extra_ops = NULL, int op_flags = 0) {
+    ObjectOperation *extra_ops = NULL, int op_flags = 0,
+    ZTracer::Trace *parent_trace = nullptr) {
     vector<OSDOp> ops;
     int i = init_ops(ops, 1, extra_ops);
     ops[i].op.op = CEPH_OSD_OP_WRITE;
@@ -2526,7 +2535,8 @@ public:
     ops[i].indata = bl;
     ops[i].op.flags = op_flags;
     Op *o = new Op(oid, oloc, ops, flags | global_op_flags.read() |
-                  CEPH_OSD_FLAG_WRITE, oncommit, objver);
+                  CEPH_OSD_FLAG_WRITE, oncommit, objver,
+                   nullptr, parent_trace);
     o->mtime = mtime;
     o->snapc = snapc;
     return o;