]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: add ceph sqlite VFS
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 28 Jan 2021 23:02:33 +0000 (15:02 -0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 19 Mar 2021 15:52:56 +0000 (08:52 -0700)
Configure to use g_ceph_context and obtain the RADOS entity address for
blocklisting.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/include/config-h.in.cmake
src/mgr/CMakeLists.txt
src/mgr/Mgr.cc

index 39aa5bbc42799b7f26c0ff692ae22622510a19c5..5c1d3d41d506bd899db897fa43cc86a28c723716 100644 (file)
 /* Define if RBD QCOW migration format is enabled */
 #cmakedefine WITH_RBD_MIGRATION_FORMAT_QCOW_V1
 
+/* Define if libcephsqlite is enabled */
+#cmakedefine WITH_LIBCEPHSQLITE
+
 /* Define if RWL is enabled */
 #cmakedefine WITH_RBD_RWL
 
index f2187407a88a83456f17e54b34485edcee96573b..55147af4fc6ba6db6efa668633bdae5757f81c32 100644 (file)
@@ -33,6 +33,9 @@ if(WITH_MGR)
     mgr_commands.cc
     $<TARGET_OBJECTS:mgr_cap_obj>)
   add_executable(ceph-mgr ${mgr_srcs})
+  if(WITH_LIBCEPHSQLITE)
+    target_link_libraries(ceph-mgr cephsqlite SQLite3::SQLite3)
+  endif()
   target_link_libraries(ceph-mgr
     osdc client heap_profiler
     global-static ceph-common
index b8e1ec8e4aaad3c1cb2bf8deca0cd9923377d1a7..6e2ea467035048816645b719bb4a7f517fe1ecee 100644 (file)
@@ -13,6 +13,8 @@
 
 #include <Python.h>
 
+#include <sqlite3.h>
+
 #include "osdc/Objecter.h"
 #include "client/Client.h"
 #include "common/errno.h"
 #include "global/global_context.h"
 #include "global/signal_handler.h"
 
+#ifdef WITH_LIBCEPHSQLITE
+#  include "include/libcephsqlite.h"
+#endif
+
 #include "mgr/MgrContext.h"
 
 #include "DaemonServer.h"
@@ -353,6 +359,32 @@ void Mgr::init()
     "Dump mgr status");
   ceph_assert(r == 0);
 
+#ifdef WITH_LIBCEPHSQLITE
+  dout(4) << "Using sqlite3 version: " << sqlite3_libversion() << dendl;
+  /* See libcephsqlite.h for rationale of this code. */
+  sqlite3_auto_extension((void (*)())sqlite3_cephsqlite_init);
+  {
+    sqlite3* db = nullptr;
+    if (int rc = sqlite3_open_v2(":memory:", &db, SQLITE_OPEN_READWRITE, nullptr); rc == SQLITE_OK) {
+      sqlite3_close(db);
+    } else {
+      derr << "could not open sqlite3: " << rc << dendl;
+      ceph_abort();
+    }
+  }
+  {
+    char *ident = nullptr;
+    if (int rc = cephsqlite_setcct(g_ceph_context, &ident); rc < 0) {
+      derr << "could not set libcephsqlite cct: " << rc << dendl;
+      ceph_abort();
+    }
+    entity_addrvec_t addrv;
+    addrv.parse(ident);
+    ident = (char*)realloc(ident, 0);
+    py_module_registry->register_client("libcephsqlite", addrv);
+  }
+#endif
+
   dout(4) << "Complete." << dendl;
   initializing = false;
   initialized = true;