From: Jason Dillaman Date: Thu, 1 Oct 2015 02:37:05 +0000 (-0400) Subject: librados: conditionally initialize the tracepoint provider X-Git-Tag: v0.94.6~44^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bf34b3657339dc40c7939fcdddaf2b7ae78c82ad;p=ceph.git librados: conditionally initialize the tracepoint provider Signed-off-by: Jason Dillaman (cherry picked from commit 6368c281b53d6175a564725b85516de4b6ae54de) --- diff --git a/src/librados/librados.cc b/src/librados/librados.cc index 49813aa1e96..39598013e45 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -18,6 +18,7 @@ #include "common/errno.h" #include "common/ceph_argparse.h" #include "common/common_init.h" +#include "common/TracepointProvider.h" #include "include/rados/librados.h" #include "include/rados/librados.hpp" #include "include/types.h" @@ -61,6 +62,12 @@ using std::runtime_error; #define RADOS_LIST_MAX_ENTRIES 1024 +namespace { + +TracepointProvider::Traits tracepoint_traits("librados_tp.so", "rados_tracing"); + +} // anonymous namespace + /* * Structure of this file * @@ -2171,10 +2178,9 @@ librados::ObjectOperation::~ObjectOperation() } ///////////////////////////// C API ////////////////////////////// -static -int rados_create_common(rados_t *pcluster, - const char * const clustername, - CephInitParameters *iparams) + +static CephContext *rados_create_cct(const char * const clustername, + CephInitParameters *iparams) { // missing things compared to global_init: // g_ceph_context, g_conf, g_lockdep, signal handlers @@ -2184,26 +2190,27 @@ int rados_create_common(rados_t *pcluster, cct->_conf->parse_env(); // environment variables override cct->_conf->apply_changes(NULL); - librados::RadosClient *radosp = new librados::RadosClient(cct); - *pcluster = (void *)radosp; - - cct->put(); - return 0; + TracepointProvider::initialize(cct); + return cct; } extern "C" int rados_create(rados_t *pcluster, const char * const id) { - tracepoint(librados, rados_create_enter, id); CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT); if (id) { iparams.name.set(CEPH_ENTITY_TYPE_CLIENT, id); } - int retval = rados_create_common(pcluster, "ceph", &iparams); - tracepoint(librados, rados_create_exit, retval, *pcluster); - return retval; + CephContext *cct = rados_create_cct("ceph", &iparams); + + tracepoint(librados, rados_create_enter, id); + *pcluster = reinterpret_cast(new librados::RadosClient(cct)); + tracepoint(librados, rados_create_exit, 0, *pcluster); + + cct->put(); + return 0; } -// as above, but +// as above, but // 1) don't assume 'client.'; name is a full type.id namestr // 2) allow setting clustername // 3) flags is for future expansion (maybe some of the global_init() @@ -2212,16 +2219,21 @@ extern "C" int rados_create(rados_t *pcluster, const char * const id) extern "C" int rados_create2(rados_t *pcluster, const char *const clustername, const char * const name, uint64_t flags) { - tracepoint(librados, rados_create2_enter, clustername, name, flags); // client is assumed, but from_str will override + int retval = 0; CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT); if (!name || !iparams.name.from_str(name)) { - tracepoint(librados, rados_create2_exit, -EINVAL, *pcluster); - return -EINVAL; + retval = -EINVAL; } - int retval = rados_create_common(pcluster, clustername, &iparams); + CephContext *cct = rados_create_cct(clustername, &iparams); + tracepoint(librados, rados_create2_enter, clustername, name, flags); + if (retval == 0) { + *pcluster = reinterpret_cast(new librados::RadosClient(cct)); + } tracepoint(librados, rados_create2_exit, retval, *pcluster); + + cct->put(); return retval; } @@ -2231,8 +2243,10 @@ extern "C" int rados_create2(rados_t *pcluster, const char *const clustername, */ extern "C" int rados_create_with_context(rados_t *pcluster, rados_config_t cct_) { - tracepoint(librados, rados_create_with_context_enter, cct_); CephContext *cct = (CephContext *)cct_; + TracepointProvider::initialize(cct); + + tracepoint(librados, rados_create_with_context_enter, cct_); librados::RadosClient *radosp = new librados::RadosClient(cct); *pcluster = (void *)radosp; tracepoint(librados, rados_create_with_context_exit, 0, *pcluster);