#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"
#define RADOS_LIST_MAX_ENTRIES 1024
+namespace {
+
+TracepointProvider::Traits tracepoint_traits("librados_tp.so", "rados_tracing");
+
+} // anonymous namespace
+
/*
* Structure of this file
*
}
///////////////////////////// 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
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<tracepoint_traits>(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<rados_t>(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()
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<rados_t>(new librados::RadosClient(cct));
+ }
tracepoint(librados, rados_create2_exit, retval, *pcluster);
+
+ cct->put();
return retval;
}
*/
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<tracepoint_traits>(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);