]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs: add ceph_create_from_rados
authorJohn Spray <john.spray@redhat.com>
Fri, 18 Sep 2015 17:26:54 +0000 (18:26 +0100)
committerJohn Spray <john.spray@redhat.com>
Tue, 5 Jan 2016 00:47:53 +0000 (00:47 +0000)
This is for applications that want to use
librados and libcephfs in the same process,
without trying to have two CephContexts

Signed-off-by: John Spray <john.spray@redhat.com>
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index acdfa135ba3018731fda88591bbb3482c00679af..ba55c35f9571ae2d2724264d0719d28a26d65b50 100644 (file)
@@ -158,6 +158,19 @@ int ceph_create(struct ceph_mount_info **cmount, const char * const id);
  */
 int ceph_create_with_context(struct ceph_mount_info **cmount, struct CephContext *conf);
 
+
+typedef void *rados_t;
+
+/**
+ * Create a mount handle from a rados_t, for using libcephfs in the
+ * same process as librados.
+ *
+ * @param cmount the mount info handle to initialize
+ * @param cluster reference to already-initialized librados handle
+ * @returns 0 on success, negative error code on failure
+ */
+int ceph_create_from_rados(struct ceph_mount_info **cmount, rados_t cluster);
+
 /**
  * Initialize the filesystem client (but do not mount the filesystem yet)
  *
index 849b1c0a66505bb9ca040b10194083663ce97d14..5503b88c0440fbdee1b53085c05777a30f04dcf5 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "auth/Crypto.h"
 #include "client/Client.h"
-#include "include/cephfs/libcephfs.h"
+#include "librados/RadosClient.h"
 #include "common/Mutex.h"
 #include "common/ceph_argparse.h"
 #include "common/common_init.h"
@@ -31,6 +31,9 @@
 #include "msg/Messenger.h"
 #include "include/assert.h"
 
+#include "include/cephfs/libcephfs.h"
+
+
 struct ceph_mount_info
 {
 public:
@@ -292,6 +295,15 @@ extern "C" int ceph_create_with_context(struct ceph_mount_info **cmount, CephCon
   return 0;
 }
 
+extern "C" int ceph_create_from_rados(struct ceph_mount_info **cmount,
+    rados_t cluster)
+{
+  auto rados = (librados::RadosClient *) cluster;
+  auto cct = rados->cct;
+  cct->get();
+  return ceph_create_with_context(cmount, cct);
+}
+
 extern "C" int ceph_create(struct ceph_mount_info **cmount, const char * const id)
 {
   CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT);