From 06fa26853d865b9190e6a73c24bbff08fe0d6713 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 14 Feb 2012 17:03:00 -0800 Subject: [PATCH] librados: use rados_config_t typedef instead of CephContext Signed-off-by: Sage Weil --- src/include/rados/librados.h | 33 +++++++++++++++++++++++---------- src/librados.cc | 11 ++++++----- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h index 5d16f94a7ce46..7fb06455c9f4d 100644 --- a/src/include/rados/librados.h +++ b/src/include/rados/librados.h @@ -50,8 +50,6 @@ enum { /** @endcond */ /** @} */ -struct CephContext; - /** * @typedef rados_t * @@ -63,6 +61,19 @@ struct CephContext; */ typedef void *rados_t; +/** + * @tyepdef rados_config_t + * + * A handle for the ceph configuration context for the rados_t cluster + * instance. This can be used to share configuration context/state + * (e.g., logging configuration) between librados instance. + * + * @warning The config context does not have independent reference + * counting. As such, a rados_config_t handle retrieved from a given + * rados_t is only valid as long as that rados_t. + */ +typedef void *rados_config_t; + /** * @typedef rados_ioctx_t * @@ -182,13 +193,13 @@ int rados_create(rados_t *cluster, const char * const id); /** * Initialize a cluster handle from an existing configuration. * - * Copies all configuration, as retrieved by the C++ API. + * Share configuration state with another rados_t instance. * * @param cluster where to store the handle * @param cct_ the existing configuration to use * @returns 0 on success, negative error code on failure */ -int rados_create_with_context(rados_t *cluster, struct CephContext *cct_); +int rados_create_with_context(rados_t *cluster, rados_config_t cct); /** * Connect to the cluster. @@ -369,12 +380,14 @@ int rados_cluster_stat(rados_t cluster, struct rados_cluster_stat_t *result); int rados_pool_list(rados_t cluster, char *buf, size_t len); /** - * Get CephContext for a rados cluster handle + * Get a configuration handle for a rados cluster handle + * + * This handle is valid only as long as the cluster handle is valid. * * @param cluster cluster handle - * @returns CephContext for this cluster + * @returns config handle for this cluster */ -struct CephContext *rados_cct(rados_t cluster); +rados_config_t rados_cct(rados_t cluster); /** * Create an io context @@ -406,12 +419,12 @@ int rados_ioctx_create(rados_t cluster, const char *pool_name, rados_ioctx_t *io void rados_ioctx_destroy(rados_ioctx_t io); /** - * Get CephContext for a pool handle + * Get configuration hadnle for a pool handle * * @param io pool handle - * @returns CephContext for this cluster + * @returns rados_config_t for this cluster */ -struct CephContext *rados_ioctx_cct(rados_ioctx_t io); +rados_config_t rados_ioctx_cct(rados_ioctx_t io); /** * Get pool usage statistics diff --git a/src/librados.cc b/src/librados.cc index 0540373a2dcbf..86e1ac309a3e2 100644 --- a/src/librados.cc +++ b/src/librados.cc @@ -3437,17 +3437,18 @@ extern "C" int rados_create(rados_t *pcluster, const char * const id) * already called global_init and want to use that particular configuration for * their cluster. */ -extern "C" int rados_create_with_context(rados_t *pcluster, CephContext *cct) +extern "C" int rados_create_with_context(rados_t *pcluster, rados_config_t cct_) { + CephContext *cct = (CephContext *)cct_; librados::RadosClient *radosp = new librados::RadosClient(cct); *pcluster = (void *)radosp; return 0; } -extern "C" CephContext *rados_cct(rados_t cluster) +extern "C" rados_config_t rados_cct(rados_t cluster) { librados::RadosClient *client = (librados::RadosClient *)cluster; - return client->cct; + return (rados_config_t)client->cct; } extern "C" int rados_connect(rados_t cluster) @@ -3631,10 +3632,10 @@ extern "C" int rados_ioctx_pool_stat(rados_ioctx_t io, struct rados_pool_stat_t return 0; } -extern "C" struct CephContext *rados_ioctx_cct(rados_ioctx_t io) +extern "C" rados_config_t rados_ioctx_cct(rados_ioctx_t io) { librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io; - return ctx->client->cct; + return (rados_config_t)ctx->client->cct; } extern "C" void rados_ioctx_snap_set_read(rados_ioctx_t io, rados_snap_t seq) -- 2.39.5