From: Patrick Donnelly Date: Thu, 28 Jan 2021 23:02:33 +0000 (-0800) Subject: mgr: add ceph sqlite VFS X-Git-Tag: v17.1.0~2521^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=52446d00f647533f24e412dc8685a28d246bbdf2;p=ceph.git mgr: add ceph sqlite VFS Configure to use g_ceph_context and obtain the RADOS entity address for blocklisting. Signed-off-by: Patrick Donnelly --- diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index 39aa5bbc4279..5c1d3d41d506 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -363,6 +363,9 @@ /* 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 diff --git a/src/mgr/CMakeLists.txt b/src/mgr/CMakeLists.txt index f2187407a88a..55147af4fc6b 100644 --- a/src/mgr/CMakeLists.txt +++ b/src/mgr/CMakeLists.txt @@ -33,6 +33,9 @@ if(WITH_MGR) mgr_commands.cc $) 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 diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index b8e1ec8e4aaa..6e2ea4670350 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -13,6 +13,8 @@ #include +#include + #include "osdc/Objecter.h" #include "client/Client.h" #include "common/errno.h" @@ -21,6 +23,10 @@ #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;