From d447a80815e5fe72ef96c2506d4f78e507204047 Mon Sep 17 00:00:00 2001 From: Bassam Tabbara Date: Fri, 4 Nov 2016 18:10:08 -0700 Subject: [PATCH] embedded: Add RADOS classes to embedded cephd library RADOS classes can now be statically compiled and added to the embedded cephd library. The RADOS ClassHandler now has an option to skip calling dlclose just like PluginRegistry. All RADOS classes where changed to use a CLS_INIT macro that will either use __cls_init or classname_cls_init. this enables the static compiling of all RADOS classes in a single library. Also global method definitions where moved to inside cls_init. Also added a few aconfig defines including WITH_EMBEDDED, WITH_CEPHFS, WITH_RBD, and WITH_KVS. Note that WITH_RBD was not defined before and the ceph-dencoder was broken when it was turned on. Signed-off-by: Bassam Tabbara --- src/CMakeLists.txt | 2 + src/ceph_osd.cc | 1 + src/cls/CMakeLists.txt | 142 +++++++++++++++------ src/cls/cephfs/cls_cephfs.cc | 13 +- src/cls/hello/cls_hello.cc | 20 +-- src/cls/journal/cls_journal.cc | 52 ++++---- src/cls/lock/cls_lock.cc | 20 +-- src/cls/log/cls_log.cc | 14 +-- src/cls/lua/cls_lua.cc | 10 +- src/cls/numops/cls_numops.cc | 10 +- src/cls/rbd/cls_rbd.cc | 168 ++++++++++++------------- src/cls/refcount/cls_refcount.cc | 14 +-- src/cls/replica_log/cls_replica_log.cc | 12 +- src/cls/rgw/cls_rgw.cc | 74 +++++------ src/cls/statelog/cls_statelog.cc | 14 +-- src/cls/timeindex/cls_timeindex.cc | 12 +- src/cls/user/cls_user.cc | 16 +-- src/cls/version/cls_version.cc | 16 +-- src/cls_acl.cc | 10 +- src/cls_crypto.cc | 11 +- src/include/config-h.in.cmake | 13 ++ src/key_value_store/CMakeLists.txt | 5 + src/key_value_store/cls_kvs.cc | 27 ++-- src/libcephd/CMakeLists.txt | 5 +- src/libcephd/libcephd.cc | 71 +++++++++++ src/objclass/objclass.h | 15 +++ src/osd/ClassHandler.cc | 8 ++ src/osd/ClassHandler.h | 6 +- 28 files changed, 478 insertions(+), 303 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e49d2a2bd37..33f7ae95487 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -629,6 +629,8 @@ endif(${WITH_RADOSGW}) if(WITH_RBD) set(DENCODER_EXTRALIBS ${DENCODER_EXTRALIBS} + rbd_types + cls_rbd_client rbd_replay_types) if(LINUX) list(APPEND dencoder_srcs diff --git a/src/ceph_osd.cc b/src/ceph_osd.cc index 404fcd430a3..db1e4a9a143 100644 --- a/src/ceph_osd.cc +++ b/src/ceph_osd.cc @@ -92,6 +92,7 @@ static void usage() #ifdef BUILDING_FOR_EMBEDDED void cephd_preload_embedded_plugins(); +void cephd_preload_rados_classes(OSD *osd); extern "C" int cephd_osd(int argc, const char **argv) #else int main(int argc, const char **argv) diff --git a/src/cls/CMakeLists.txt b/src/cls/CMakeLists.txt index 9741f369739..8387e4c3bb5 100644 --- a/src/cls/CMakeLists.txt +++ b/src/cls/CMakeLists.txt @@ -1,152 +1,220 @@ ## Rados object classes set(cls_dir ${CMAKE_INSTALL_LIBDIR}/rados-classes) +set(cls_embedded_srcs) # cls_hello -add_library(cls_hello SHARED hello/cls_hello.cc) +set(cls_hello_srcs hello/cls_hello.cc) +add_library(cls_hello SHARED ${cls_hello_srcs}) set_target_properties(cls_hello PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_hello DESTINATION ${cls_dir}) +list(APPEND cls_embedded_srcs ${cls_hello_srcs}) # cls_numops -add_library(cls_numops SHARED numops/cls_numops.cc) +set(cls_numops_srcs numops/cls_numops.cc) +add_library(cls_numops SHARED ${cls_numops_srcs}) set_target_properties(cls_numops PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_numops DESTINATION ${cls_dir}) +set(cls_numops_client_srcs numops/cls_numops_client.cc) +add_library(cls_numops_client STATIC ${cls_numops_client_srcs}) + +list(APPEND cls_embedded_srcs ${cls_numops_srcs} ${cls_numops_client_srcs}) + # cls_rbd if (WITH_RBD) - add_library(cls_rbd SHARED rbd/cls_rbd.cc rbd/cls_rbd_types.cc) + set(cls_rbd_srcs rbd/cls_rbd.cc rbd/cls_rbd_types.cc) + add_library(cls_rbd SHARED ${cls_rbd_srcs}) set_target_properties(cls_rbd PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_rbd DESTINATION ${cls_dir}) - add_library(cls_rbd_client STATIC rbd/cls_rbd_client.cc rbd/cls_rbd_types.cc) + set(cls_rbd_client_srcs rbd/cls_rbd_client.cc rbd/cls_rbd_types.cc) + add_library(cls_rbd_client STATIC ${cls_rbd_client_srcs}) target_link_libraries(cls_rbd_client cls_lock_client) + + list(APPEND cls_embedded_srcs ${cls_rbd_srcs} ${cls_rbd_client_srcs}) endif (WITH_RBD) # cls_lock -add_library(cls_lock SHARED lock/cls_lock.cc) +set(cls_lock_srcs lock/cls_lock.cc) +add_library(cls_lock SHARED ${cls_lock_srcs}) set_target_properties(cls_lock PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_lock DESTINATION ${cls_dir}) -add_library(cls_lock_client STATIC +set(cls_lock_client_srcs lock/cls_lock_client.cc lock/cls_lock_types.cc lock/cls_lock_ops.cc) +add_library(cls_lock_client STATIC ${cls_lock_client_srcs}) + +list(APPEND cls_embedded_srcs ${cls_lock_srcs} ${cls_lock_client_srcs}) # cls_refcount -add_library(cls_refcount SHARED +set(cls_refcount_srcs refcount/cls_refcount.cc refcount/cls_refcount_ops.cc ${CMAKE_SOURCE_DIR}/src/common/ceph_json.cc) +add_library(cls_refcount SHARED ${cls_refcount_srcs}) target_link_libraries(cls_refcount json_spirit) set_target_properties(cls_refcount PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_refcount DESTINATION ${cls_dir}) -add_library(cls_refcount_client STATIC +set(cls_refcount_client_srcs refcount/cls_refcount_client.cc refcount/cls_refcount_ops.cc) +add_library(cls_refcount_client STATIC ${cls_refcount_client_srcs}) + +list(APPEND cls_embedded_srcs ${cls_refcount_srcs} ${cls_refcount_client_srcs}) # cls_version -add_library(cls_version SHARED version/cls_version.cc) +set(cls_version_srcs version/cls_version.cc) +add_library(cls_version SHARED ${cls_version_srcs}) set_target_properties(cls_version PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_version DESTINATION ${cls_dir}) -add_library(cls_version_client STATIC +set(cls_version_client_srcs version/cls_version_client.cc version/cls_version_types.cc) +add_library(cls_version_client STATIC ${cls_version_client_srcs}) + +list(APPEND cls_embedded_srcs ${cls_version_srcs} ${cls_version_client_srcs}) # cls_log -add_library(cls_log SHARED log/cls_log.cc) +set(cls_log_srcs log/cls_log.cc) +add_library(cls_log SHARED ${cls_log_srcs}) set_target_properties(cls_log PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_log DESTINATION ${cls_dir}) -add_library(cls_log_client STATIC log/cls_log_client.cc) +set(cls_log_client_srcs log/cls_log_client.cc) +add_library(cls_log_client STATIC ${cls_log_client_srcs}) + +list(APPEND cls_embedded_srcs ${cls_log_srcs} ${cls_log_client_srcs}) # cls_statelog -add_library(cls_statelog SHARED statelog/cls_statelog.cc) +set(cls_statelog_srcs statelog/cls_statelog.cc) +add_library(cls_statelog SHARED ${cls_statelog_srcs}) set_target_properties(cls_statelog PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_statelog DESTINATION ${cls_dir}) -add_library(cls_statelog_client STATIC statelog/cls_statelog_client.cc) +set(cls_statelog_client_srcs statelog/cls_statelog_client.cc) +add_library(cls_statelog_client STATIC ${cls_statelog_client_srcs}) + +list(APPEND cls_embedded_srcs ${cls_statelog_srcs} ${cls_statelog_client_srcs}) # cls_timeindex -add_library(cls_timeindex SHARED timeindex/cls_timeindex.cc) +set(cls_timeindex_srcs timeindex/cls_timeindex.cc) +add_library(cls_timeindex SHARED ${cls_timeindex_srcs}) set_target_properties(cls_timeindex PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_timeindex DESTINATION ${cls_dir}) -add_library(cls_timeindex_client STATIC timeindex/cls_timeindex_client.cc) +set(cls_timeindex_client_srcs timeindex/cls_timeindex_client.cc) +add_library(cls_timeindex_client STATIC ${cls_timeindex_client_srcs}) + +list(APPEND cls_embedded_srcs ${cls_timeindex_srcs} ${cls_timeindex_client_srcs}) # cls_replica_log -add_library(cls_replica_log SHARED replica_log/cls_replica_log.cc) +set(cls_replica_log_srcs replica_log/cls_replica_log.cc) +add_library(cls_replica_log SHARED ${cls_replica_log_srcs}) set_target_properties(cls_replica_log PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_replica_log DESTINATION ${cls_dir}) -add_library(cls_replica_log_client STATIC +set(cls_replica_log_client_srcs replica_log/cls_replica_log_types.cc replica_log/cls_replica_log_ops.cc replica_log/cls_replica_log_client.cc) +add_library(cls_replica_log_client STATIC ${cls_replica_log_client_srcs}) + +list(APPEND cls_embedded_srcs ${cls_replica_log_srcs} ${cls_replica_log_client_srcs}) # cls_user -add_library(cls_user SHARED user/cls_user.cc) +set(cls_user_srcs user/cls_user.cc) +add_library(cls_user SHARED ${cls_user_srcs}) set_target_properties(cls_user PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_user DESTINATION ${cls_dir}) -add_library(cls_user_client STATIC +set(cls_user_client_srcs user/cls_user_client.cc user/cls_user_types.cc user/cls_user_ops.cc) +add_library(cls_user_client STATIC ${cls_user_client_srcs}) + +list(APPEND cls_embedded_srcs ${cls_user_srcs} ${cls_user_client_srcs}) # cls_journal -add_library(cls_journal SHARED +set(cls_journal_srcs journal/cls_journal.cc journal/cls_journal_types.cc) +add_library(cls_journal SHARED ${cls_journal_srcs}) set_target_properties(cls_journal PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_journal DESTINATION ${cls_dir}) -add_library(cls_journal_client STATIC +set(cls_journal_client_srcs journal/cls_journal_client.cc journal/cls_journal_types.cc) +add_library(cls_journal_client STATIC ${cls_journal_client_srcs}) + +list(APPEND cls_embedded_srcs ${cls_journal_srcs} ${cls_journal_client_srcs}) # cls_rgw if (WITH_RADOSGW) - add_library(cls_rgw SHARED + set(cls_rgw_srcs rgw/cls_rgw.cc rgw/cls_rgw_ops.cc rgw/cls_rgw_types.cc ${CMAKE_SOURCE_DIR}/src/common/ceph_json.cc) + add_library(cls_rgw SHARED ${cls_rgw_srcs}) target_link_libraries(cls_rgw json_spirit) set_target_properties(cls_rgw PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_rgw DESTINATION ${cls_dir}) - add_library(cls_rgw_client STATIC + set(cls_rgw_client_srcs rgw/cls_rgw_client.cc rgw/cls_rgw_types.cc rgw/cls_rgw_ops.cc) + add_library(cls_rgw_client STATIC ${cls_rgw_client_srcs}) + + list(APPEND cls_embedded_srcs ${cls_rgw_srcs} ${cls_rgw_client_srcs}) endif (WITH_RADOSGW) # cls_cephfs if (WITH_CEPHFS) - add_library(cls_cephfs SHARED + set(cls_cephfs_srcs cephfs/cls_cephfs.cc) + add_library(cls_cephfs SHARED ${cls_cephfs_srcs}) set_target_properties(cls_cephfs PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_cephfs DESTINATION ${cls_dir}) - add_library(cls_cephfs_client STATIC + set(cls_cephfs_client_srcs cephfs/cls_cephfs_client.cc) -endif (WITH_CEPHFS) + add_library(cls_cephfs_client STATIC ${cls_cephfs_client_srcs}) -add_library(cls_numops_client STATIC numops/cls_numops_client.cc) + list(APPEND cls_embedded_srcs ${cls_cephfs_srcs} ${cls_cephfs_client_srcs}) +endif (WITH_CEPHFS) -add_library(cls_lua SHARED +# cls_lua +set(cls_lua_srcs lua/cls_lua.cc - lua/lua_bufferlist.cc -) + lua/lua_bufferlist.cc) +add_library(cls_lua SHARED ${cls_lua_srcs}) set_target_properties(cls_lua PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_lua DESTINATION ${cls_dir}) target_link_libraries(cls_lua liblua - json_spirit -) - -add_library(cls_lua_client STATIC - lua/cls_lua_client.cc -) + json_spirit) + +set(cls_lua_client_srcs + lua/cls_lua_client.cc) +add_library(cls_lua_client STATIC ${cls_lua_client_srcs}) + +list(APPEND cls_embedded_srcs ${cls_lua_srcs} ${cls_lua_client_srcs}) + +if(WITH_EMBEDDED) + include(MergeStaticLibraries) + list(REMOVE_DUPLICATES cls_embedded_srcs) + add_library(cephd_cls_base STATIC ${cls_embedded_srcs}) + # while not necessary this seems to bring in the lua's include directories + # so that cls_lua srcs build correctly + target_link_libraries(cephd_cls_base liblua) + set_target_properties(cephd_cls_base PROPERTIES COMPILE_DEFINITIONS BUILDING_FOR_EMBEDDED) + merge_static_libraries(cephd_cls cephd_cls_base liblua) +endif() diff --git a/src/cls/cephfs/cls_cephfs.cc b/src/cls/cephfs/cls_cephfs.cc index 6e81a53e986..3537f68450b 100644 --- a/src/cls/cephfs/cls_cephfs.cc +++ b/src/cls/cephfs/cls_cephfs.cc @@ -22,11 +22,7 @@ #include "cls_cephfs.h" CLS_VER(1,0) -CLS_NAME(cephfs_size_scan) - -cls_handle_t h_class; -cls_method_handle_t h_accumulate_inode_metadata; - +CLS_NAME(cephfs) std::ostream &operator<<(std::ostream &out, const ObjCeiling &in) @@ -195,11 +191,14 @@ PGLSFilter *inode_tag_filter() * We do two things here: we register the new class, and then register * all of the class's methods. */ -void __cls_init() +CLS_INIT(cephfs) { // this log message, at level 0, will always appear in the ceph-osd // log file. - CLS_LOG(0, "loading cephfs_size_scan"); + CLS_LOG(0, "loading cephfs"); + + cls_handle_t h_class; + cls_method_handle_t h_accumulate_inode_metadata; cls_register("cephfs", &h_class); cls_register_cxx_method(h_class, "accumulate_inode_metadata", diff --git a/src/cls/hello/cls_hello.cc b/src/cls/hello/cls_hello.cc index 2751d3c0a76..d181d3fab60 100644 --- a/src/cls/hello/cls_hello.cc +++ b/src/cls/hello/cls_hello.cc @@ -39,15 +39,6 @@ CLS_VER(1,0) CLS_NAME(hello) -cls_handle_t h_class; -cls_method_handle_t h_say_hello; -cls_method_handle_t h_record_hello; -cls_method_handle_t h_replay; -cls_method_handle_t h_writes_dont_return_data; -cls_method_handle_t h_turn_it_to_11; -cls_method_handle_t h_bad_reader; -cls_method_handle_t h_bad_writer; - /** * say hello - a "read" method that does not depend on the object * @@ -298,12 +289,21 @@ PGLSFilter *hello_filter() * We do two things here: we register the new class, and then register * all of the class's methods. */ -void __cls_init() +CLS_INIT(hello) { // this log message, at level 0, will always appear in the ceph-osd // log file. CLS_LOG(0, "loading cls_hello"); + cls_handle_t h_class; + cls_method_handle_t h_say_hello; + cls_method_handle_t h_record_hello; + cls_method_handle_t h_replay; + cls_method_handle_t h_writes_dont_return_data; + cls_method_handle_t h_turn_it_to_11; + cls_method_handle_t h_bad_reader; + cls_method_handle_t h_bad_writer; + cls_register("hello", &h_class); // There are two flags we specify for methods: diff --git a/src/cls/journal/cls_journal.cc b/src/cls/journal/cls_journal.cc index 2682926d57a..ffa18c3c56f 100644 --- a/src/cls/journal/cls_journal.cc +++ b/src/cls/journal/cls_journal.cc @@ -15,28 +15,6 @@ CLS_VER(1, 0) CLS_NAME(journal) -cls_handle_t h_class; -cls_method_handle_t h_journal_create; -cls_method_handle_t h_journal_get_order; -cls_method_handle_t h_journal_get_splay_width; -cls_method_handle_t h_journal_get_pool_id; -cls_method_handle_t h_journal_get_minimum_set; -cls_method_handle_t h_journal_set_minimum_set; -cls_method_handle_t h_journal_get_active_set; -cls_method_handle_t h_journal_set_active_set; -cls_method_handle_t h_journal_get_client; -cls_method_handle_t h_journal_client_register; -cls_method_handle_t h_journal_client_update_data; -cls_method_handle_t h_journal_client_update_state; -cls_method_handle_t h_journal_client_unregister; -cls_method_handle_t h_journal_client_commit; -cls_method_handle_t h_journal_client_list; -cls_method_handle_t h_journal_get_next_tag_tid; -cls_method_handle_t h_journal_get_tag; -cls_method_handle_t h_journal_tag_create; -cls_method_handle_t h_journal_tag_list; -cls_method_handle_t h_journal_object_guard_append; - namespace { static const uint64_t MAX_KEYS_READ = 64; @@ -1132,16 +1110,32 @@ int journal_object_guard_append(cls_method_context_t hctx, bufferlist *in, return 0; } -#if __GNUC__ >= 4 - #define CEPH_CLS_API __attribute__ ((visibility ("default"))) -#else - #define CEPH_CLS_API -#endif - -void CEPH_CLS_API __cls_init() +CLS_INIT(journal) { CLS_LOG(20, "Loaded journal class!"); + cls_handle_t h_class; + cls_method_handle_t h_journal_create; + cls_method_handle_t h_journal_get_order; + cls_method_handle_t h_journal_get_splay_width; + cls_method_handle_t h_journal_get_pool_id; + cls_method_handle_t h_journal_get_minimum_set; + cls_method_handle_t h_journal_set_minimum_set; + cls_method_handle_t h_journal_get_active_set; + cls_method_handle_t h_journal_set_active_set; + cls_method_handle_t h_journal_get_client; + cls_method_handle_t h_journal_client_register; + cls_method_handle_t h_journal_client_update_data; + cls_method_handle_t h_journal_client_update_state; + cls_method_handle_t h_journal_client_unregister; + cls_method_handle_t h_journal_client_commit; + cls_method_handle_t h_journal_client_list; + cls_method_handle_t h_journal_get_next_tag_tid; + cls_method_handle_t h_journal_get_tag; + cls_method_handle_t h_journal_tag_create; + cls_method_handle_t h_journal_tag_list; + cls_method_handle_t h_journal_object_guard_append; + cls_register("journal", &h_class); /// methods for journal.$journal_id objects diff --git a/src/cls/lock/cls_lock.cc b/src/cls/lock/cls_lock.cc index 179c1d3f2bc..14e3b0dcdd4 100644 --- a/src/cls/lock/cls_lock.cc +++ b/src/cls/lock/cls_lock.cc @@ -38,15 +38,6 @@ using namespace rados::cls::lock; CLS_VER(1,0) CLS_NAME(lock) -cls_handle_t h_class; -cls_method_handle_t h_lock_op; -cls_method_handle_t h_unlock_op; -cls_method_handle_t h_break_lock; -cls_method_handle_t h_get_info; -cls_method_handle_t h_list_locks; -cls_method_handle_t h_assert_locked; -cls_method_handle_t h_set_cookie; - #define LOCK_PREFIX "lock." typedef struct lock_info_s { @@ -601,10 +592,19 @@ int set_cookie(cls_method_context_t hctx, bufferlist *in, bufferlist *out) return 0; } -void __cls_init() +CLS_INIT(lock) { CLS_LOG(20, "Loaded lock class!"); + cls_handle_t h_class; + cls_method_handle_t h_lock_op; + cls_method_handle_t h_unlock_op; + cls_method_handle_t h_break_lock; + cls_method_handle_t h_get_info; + cls_method_handle_t h_list_locks; + cls_method_handle_t h_assert_locked; + cls_method_handle_t h_set_cookie; + cls_register("lock", &h_class); cls_register_cxx_method(h_class, "lock", CLS_METHOD_RD | CLS_METHOD_WR | CLS_METHOD_PROMOTE, diff --git a/src/cls/log/cls_log.cc b/src/cls/log/cls_log.cc index 89745bb8bb7..a53149ce3b3 100644 --- a/src/cls/log/cls_log.cc +++ b/src/cls/log/cls_log.cc @@ -20,12 +20,6 @@ CLS_VER(1,0) CLS_NAME(log) -cls_handle_t h_class; -cls_method_handle_t h_log_add; -cls_method_handle_t h_log_list; -cls_method_handle_t h_log_trim; -cls_method_handle_t h_log_info; - static string log_index_prefix = "1_"; @@ -312,10 +306,16 @@ static int cls_log_info(cls_method_context_t hctx, bufferlist *in, bufferlist *o return 0; } -void __cls_init() +CLS_INIT(log) { CLS_LOG(1, "Loaded log class!"); + cls_handle_t h_class; + cls_method_handle_t h_log_add; + cls_method_handle_t h_log_list; + cls_method_handle_t h_log_trim; + cls_method_handle_t h_log_info; + cls_register("log", &h_class); /* log */ diff --git a/src/cls/lua/cls_lua.cc b/src/cls/lua/cls_lua.cc index 57707094968..1e15b4ed6fe 100644 --- a/src/cls/lua/cls_lua.cc +++ b/src/cls/lua/cls_lua.cc @@ -15,10 +15,6 @@ CLS_VER(1,0) CLS_NAME(lua) -cls_handle_t h_class; -cls_method_handle_t h_eval_json; -cls_method_handle_t h_eval_bufferlist; - /* * Jump point for recovering from Lua panic. */ @@ -1036,10 +1032,14 @@ static int eval_bufferlist(cls_method_context_t hctx, bufferlist *in, bufferlist return eval_generic(hctx, in, out, BUFFERLIST_ENC); } -void __cls_init() +CLS_INIT(lua) { CLS_LOG(20, "Loaded lua class!"); + cls_handle_t h_class; + cls_method_handle_t h_eval_json; + cls_method_handle_t h_eval_bufferlist; + cls_register("lua", &h_class); cls_register_cxx_method(h_class, "eval_json", diff --git a/src/cls/numops/cls_numops.cc b/src/cls/numops/cls_numops.cc index a9823bcab80..a4023b934c8 100644 --- a/src/cls/numops/cls_numops.cc +++ b/src/cls/numops/cls_numops.cc @@ -33,10 +33,6 @@ CLS_VER(1,0) CLS_NAME(numops) -cls_handle_t h_class; -cls_method_handle_t h_add; -cls_method_handle_t h_mul; - static int add(cls_method_context_t hctx, bufferlist *in, bufferlist *out) { string key, diff_str; @@ -147,10 +143,14 @@ static int mul(cls_method_context_t hctx, bufferlist *in, bufferlist *out) return cls_cxx_map_set_val(hctx, key, &new_value); } -void __cls_init() +CLS_INIT(numops) { CLS_LOG(20, "loading cls_numops"); + cls_handle_t h_class; + cls_method_handle_t h_add; + cls_method_handle_t h_mul; + cls_register("numops", &h_class); cls_register_cxx_method(h_class, "add", diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc index 1d53d4a2ab5..c9850fea1d0 100644 --- a/src/cls/rbd/cls_rbd.cc +++ b/src/cls/rbd/cls_rbd.cc @@ -64,89 +64,6 @@ CLS_VER(2,0) CLS_NAME(rbd) -cls_handle_t h_class; -cls_method_handle_t h_create; -cls_method_handle_t h_get_features; -cls_method_handle_t h_set_features; -cls_method_handle_t h_get_size; -cls_method_handle_t h_set_size; -cls_method_handle_t h_get_parent; -cls_method_handle_t h_set_parent; -cls_method_handle_t h_get_protection_status; -cls_method_handle_t h_set_protection_status; -cls_method_handle_t h_get_stripe_unit_count; -cls_method_handle_t h_set_stripe_unit_count; -cls_method_handle_t h_get_flags; -cls_method_handle_t h_set_flags; -cls_method_handle_t h_remove_parent; -cls_method_handle_t h_add_child; -cls_method_handle_t h_remove_child; -cls_method_handle_t h_get_children; -cls_method_handle_t h_get_snapcontext; -cls_method_handle_t h_get_object_prefix; -cls_method_handle_t h_get_data_pool; -cls_method_handle_t h_get_snapshot_name; -cls_method_handle_t h_get_snapshot_namespace; -cls_method_handle_t h_snapshot_add; -cls_method_handle_t h_snapshot_remove; -cls_method_handle_t h_snapshot_rename; -cls_method_handle_t h_get_all_features; -cls_method_handle_t h_copyup; -cls_method_handle_t h_get_id; -cls_method_handle_t h_set_id; -cls_method_handle_t h_dir_get_id; -cls_method_handle_t h_dir_get_name; -cls_method_handle_t h_dir_list; -cls_method_handle_t h_dir_add_image; -cls_method_handle_t h_dir_remove_image; -cls_method_handle_t h_dir_rename_image; -cls_method_handle_t h_object_map_load; -cls_method_handle_t h_object_map_save; -cls_method_handle_t h_object_map_resize; -cls_method_handle_t h_object_map_update; -cls_method_handle_t h_object_map_snap_add; -cls_method_handle_t h_object_map_snap_remove; -cls_method_handle_t h_metadata_set; -cls_method_handle_t h_metadata_remove; -cls_method_handle_t h_metadata_list; -cls_method_handle_t h_metadata_get; -cls_method_handle_t h_snapshot_get_limit; -cls_method_handle_t h_snapshot_set_limit; -cls_method_handle_t h_old_snapshots_list; -cls_method_handle_t h_old_snapshot_add; -cls_method_handle_t h_old_snapshot_remove; -cls_method_handle_t h_old_snapshot_rename; -cls_method_handle_t h_mirror_uuid_get; -cls_method_handle_t h_mirror_uuid_set; -cls_method_handle_t h_mirror_mode_get; -cls_method_handle_t h_mirror_mode_set; -cls_method_handle_t h_mirror_peer_list; -cls_method_handle_t h_mirror_peer_add; -cls_method_handle_t h_mirror_peer_remove; -cls_method_handle_t h_mirror_peer_set_client; -cls_method_handle_t h_mirror_peer_set_cluster; -cls_method_handle_t h_mirror_image_list; -cls_method_handle_t h_mirror_image_get_image_id; -cls_method_handle_t h_mirror_image_get; -cls_method_handle_t h_mirror_image_set; -cls_method_handle_t h_mirror_image_remove; -cls_method_handle_t h_mirror_image_status_set; -cls_method_handle_t h_mirror_image_status_remove; -cls_method_handle_t h_mirror_image_status_get; -cls_method_handle_t h_mirror_image_status_list; -cls_method_handle_t h_mirror_image_status_get_summary; -cls_method_handle_t h_mirror_image_status_remove_down; -cls_method_handle_t h_group_create; -cls_method_handle_t h_group_dir_list; -cls_method_handle_t h_group_dir_add; -cls_method_handle_t h_group_dir_remove; -cls_method_handle_t h_group_image_remove; -cls_method_handle_t h_group_image_list; -cls_method_handle_t h_group_image_set; -cls_method_handle_t h_image_add_group; -cls_method_handle_t h_image_remove_group; -cls_method_handle_t h_image_get_group; - #define RBD_MAX_KEYS_READ 64 #define RBD_SNAP_KEY_PREFIX "snapshot_" #define RBD_DIR_ID_KEY_PREFIX "id_" @@ -4797,10 +4714,93 @@ int image_get_group(cls_method_context_t hctx, return 0; } -void __cls_init() +CLS_INIT(rbd) { CLS_LOG(20, "Loaded rbd class!"); + cls_handle_t h_class; + cls_method_handle_t h_create; + cls_method_handle_t h_get_features; + cls_method_handle_t h_set_features; + cls_method_handle_t h_get_size; + cls_method_handle_t h_set_size; + cls_method_handle_t h_get_parent; + cls_method_handle_t h_set_parent; + cls_method_handle_t h_get_protection_status; + cls_method_handle_t h_set_protection_status; + cls_method_handle_t h_get_stripe_unit_count; + cls_method_handle_t h_set_stripe_unit_count; + cls_method_handle_t h_get_flags; + cls_method_handle_t h_set_flags; + cls_method_handle_t h_remove_parent; + cls_method_handle_t h_add_child; + cls_method_handle_t h_remove_child; + cls_method_handle_t h_get_children; + cls_method_handle_t h_get_snapcontext; + cls_method_handle_t h_get_object_prefix; + cls_method_handle_t h_get_data_pool; + cls_method_handle_t h_get_snapshot_name; + cls_method_handle_t h_get_snapshot_namespace; + cls_method_handle_t h_snapshot_add; + cls_method_handle_t h_snapshot_remove; + cls_method_handle_t h_snapshot_rename; + cls_method_handle_t h_get_all_features; + cls_method_handle_t h_copyup; + cls_method_handle_t h_get_id; + cls_method_handle_t h_set_id; + cls_method_handle_t h_dir_get_id; + cls_method_handle_t h_dir_get_name; + cls_method_handle_t h_dir_list; + cls_method_handle_t h_dir_add_image; + cls_method_handle_t h_dir_remove_image; + cls_method_handle_t h_dir_rename_image; + cls_method_handle_t h_object_map_load; + cls_method_handle_t h_object_map_save; + cls_method_handle_t h_object_map_resize; + cls_method_handle_t h_object_map_update; + cls_method_handle_t h_object_map_snap_add; + cls_method_handle_t h_object_map_snap_remove; + cls_method_handle_t h_metadata_set; + cls_method_handle_t h_metadata_remove; + cls_method_handle_t h_metadata_list; + cls_method_handle_t h_metadata_get; + cls_method_handle_t h_snapshot_get_limit; + cls_method_handle_t h_snapshot_set_limit; + cls_method_handle_t h_old_snapshots_list; + cls_method_handle_t h_old_snapshot_add; + cls_method_handle_t h_old_snapshot_remove; + cls_method_handle_t h_old_snapshot_rename; + cls_method_handle_t h_mirror_uuid_get; + cls_method_handle_t h_mirror_uuid_set; + cls_method_handle_t h_mirror_mode_get; + cls_method_handle_t h_mirror_mode_set; + cls_method_handle_t h_mirror_peer_list; + cls_method_handle_t h_mirror_peer_add; + cls_method_handle_t h_mirror_peer_remove; + cls_method_handle_t h_mirror_peer_set_client; + cls_method_handle_t h_mirror_peer_set_cluster; + cls_method_handle_t h_mirror_image_list; + cls_method_handle_t h_mirror_image_get_image_id; + cls_method_handle_t h_mirror_image_get; + cls_method_handle_t h_mirror_image_set; + cls_method_handle_t h_mirror_image_remove; + cls_method_handle_t h_mirror_image_status_set; + cls_method_handle_t h_mirror_image_status_remove; + cls_method_handle_t h_mirror_image_status_get; + cls_method_handle_t h_mirror_image_status_list; + cls_method_handle_t h_mirror_image_status_get_summary; + cls_method_handle_t h_mirror_image_status_remove_down; + cls_method_handle_t h_group_create; + cls_method_handle_t h_group_dir_list; + cls_method_handle_t h_group_dir_add; + cls_method_handle_t h_group_dir_remove; + cls_method_handle_t h_group_image_remove; + cls_method_handle_t h_group_image_list; + cls_method_handle_t h_group_image_set; + cls_method_handle_t h_image_add_group; + cls_method_handle_t h_image_remove_group; + cls_method_handle_t h_image_get_group; + cls_register("rbd", &h_class); cls_register_cxx_method(h_class, "create", CLS_METHOD_RD | CLS_METHOD_WR, diff --git a/src/cls/refcount/cls_refcount.cc b/src/cls/refcount/cls_refcount.cc index f5598aeea94..9a196c9770d 100644 --- a/src/cls/refcount/cls_refcount.cc +++ b/src/cls/refcount/cls_refcount.cc @@ -19,12 +19,6 @@ CLS_VER(1,0) CLS_NAME(refcount) -cls_handle_t h_class; -cls_method_handle_t h_refcount_get; -cls_method_handle_t h_refcount_put; -cls_method_handle_t h_refcount_set; -cls_method_handle_t h_refcount_read; - #define REFCOUNT_ATTR "refcount" @@ -227,10 +221,16 @@ static int cls_rc_refcount_read(cls_method_context_t hctx, bufferlist *in, buffe return 0; } -void __cls_init() +CLS_INIT(refcount) { CLS_LOG(1, "Loaded refcount class!"); + cls_handle_t h_class; + cls_method_handle_t h_refcount_get; + cls_method_handle_t h_refcount_put; + cls_method_handle_t h_refcount_set; + cls_method_handle_t h_refcount_read; + cls_register("refcount", &h_class); /* refcount */ diff --git a/src/cls/replica_log/cls_replica_log.cc b/src/cls/replica_log/cls_replica_log.cc index 1083b8adc38..bc8f088715f 100644 --- a/src/cls/replica_log/cls_replica_log.cc +++ b/src/cls/replica_log/cls_replica_log.cc @@ -18,11 +18,6 @@ CLS_VER(1, 0) CLS_NAME(replica_log) -cls_handle_t h_class; -cls_method_handle_t h_replica_log_set; -cls_method_handle_t h_replica_log_delete; -cls_method_handle_t h_replica_log_get; - static const string replica_log_prefix = "rl_"; static const string replica_log_bounds = replica_log_prefix + "bounds"; @@ -136,10 +131,15 @@ static int cls_replica_log_get(cls_method_context_t hctx, return 0; } -void __cls_init() +CLS_INIT(replica_log) { CLS_LOG(1, "Loaded replica log class!"); + cls_handle_t h_class; + cls_method_handle_t h_replica_log_set; + cls_method_handle_t h_replica_log_delete; + cls_method_handle_t h_replica_log_get; + cls_register("replica_log", &h_class); cls_register_cxx_method(h_class, "set", CLS_METHOD_RD | CLS_METHOD_WR, diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index 3fe55676ac1..9873590487b 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -22,42 +22,6 @@ CLS_VER(1,0) CLS_NAME(rgw) -cls_handle_t h_class; -cls_method_handle_t h_rgw_bucket_init_index; -cls_method_handle_t h_rgw_bucket_set_tag_timeout; -cls_method_handle_t h_rgw_bucket_list; -cls_method_handle_t h_rgw_bucket_check_index; -cls_method_handle_t h_rgw_bucket_rebuild_index; -cls_method_handle_t h_rgw_bucket_update_stats; -cls_method_handle_t h_rgw_bucket_prepare_op; -cls_method_handle_t h_rgw_bucket_complete_op; -cls_method_handle_t h_rgw_bucket_link_olh; -cls_method_handle_t h_rgw_bucket_unlink_instance_op; -cls_method_handle_t h_rgw_bucket_read_olh_log; -cls_method_handle_t h_rgw_bucket_trim_olh_log; -cls_method_handle_t h_rgw_bucket_clear_olh; -cls_method_handle_t h_rgw_obj_remove; -cls_method_handle_t h_rgw_obj_store_pg_ver; -cls_method_handle_t h_rgw_obj_check_attrs_prefix; -cls_method_handle_t h_rgw_obj_check_mtime; -cls_method_handle_t h_rgw_bi_get_op; -cls_method_handle_t h_rgw_bi_put_op; -cls_method_handle_t h_rgw_bi_list_op; -cls_method_handle_t h_rgw_bi_log_list_op; -cls_method_handle_t h_rgw_dir_suggest_changes; -cls_method_handle_t h_rgw_user_usage_log_add; -cls_method_handle_t h_rgw_user_usage_log_read; -cls_method_handle_t h_rgw_user_usage_log_trim; -cls_method_handle_t h_rgw_gc_set_entry; -cls_method_handle_t h_rgw_gc_list; -cls_method_handle_t h_rgw_gc_remove; -cls_method_handle_t h_rgw_lc_set_entry; -cls_method_handle_t h_rgw_lc_rm_entry; -cls_method_handle_t h_rgw_lc_get_next_entry; -cls_method_handle_t h_rgw_lc_put_head; -cls_method_handle_t h_rgw_lc_get_head; -cls_method_handle_t h_rgw_lc_list_entries; - #define BI_PREFIX_CHAR 0x80 @@ -3507,10 +3471,46 @@ static int rgw_cls_lc_get_head(cls_method_context_t hctx, bufferlist *in, buffe return 0; } -void __cls_init() +CLS_INIT(rgw) { CLS_LOG(1, "Loaded rgw class!"); + cls_handle_t h_class; + cls_method_handle_t h_rgw_bucket_init_index; + cls_method_handle_t h_rgw_bucket_set_tag_timeout; + cls_method_handle_t h_rgw_bucket_list; + cls_method_handle_t h_rgw_bucket_check_index; + cls_method_handle_t h_rgw_bucket_rebuild_index; + cls_method_handle_t h_rgw_bucket_update_stats; + cls_method_handle_t h_rgw_bucket_prepare_op; + cls_method_handle_t h_rgw_bucket_complete_op; + cls_method_handle_t h_rgw_bucket_link_olh; + cls_method_handle_t h_rgw_bucket_unlink_instance_op; + cls_method_handle_t h_rgw_bucket_read_olh_log; + cls_method_handle_t h_rgw_bucket_trim_olh_log; + cls_method_handle_t h_rgw_bucket_clear_olh; + cls_method_handle_t h_rgw_obj_remove; + cls_method_handle_t h_rgw_obj_store_pg_ver; + cls_method_handle_t h_rgw_obj_check_attrs_prefix; + cls_method_handle_t h_rgw_obj_check_mtime; + cls_method_handle_t h_rgw_bi_get_op; + cls_method_handle_t h_rgw_bi_put_op; + cls_method_handle_t h_rgw_bi_list_op; + cls_method_handle_t h_rgw_bi_log_list_op; + cls_method_handle_t h_rgw_dir_suggest_changes; + cls_method_handle_t h_rgw_user_usage_log_add; + cls_method_handle_t h_rgw_user_usage_log_read; + cls_method_handle_t h_rgw_user_usage_log_trim; + cls_method_handle_t h_rgw_gc_set_entry; + cls_method_handle_t h_rgw_gc_list; + cls_method_handle_t h_rgw_gc_remove; + cls_method_handle_t h_rgw_lc_set_entry; + cls_method_handle_t h_rgw_lc_rm_entry; + cls_method_handle_t h_rgw_lc_get_next_entry; + cls_method_handle_t h_rgw_lc_put_head; + cls_method_handle_t h_rgw_lc_get_head; + cls_method_handle_t h_rgw_lc_list_entries; + cls_register("rgw", &h_class); /* bucket index */ diff --git a/src/cls/statelog/cls_statelog.cc b/src/cls/statelog/cls_statelog.cc index f2cbbf79672..5a43da1a6a6 100644 --- a/src/cls/statelog/cls_statelog.cc +++ b/src/cls/statelog/cls_statelog.cc @@ -19,12 +19,6 @@ CLS_VER(1,0) CLS_NAME(statelog) -cls_handle_t h_class; -cls_method_handle_t h_statelog_add; -cls_method_handle_t h_statelog_list; -cls_method_handle_t h_statelog_remove; -cls_method_handle_t h_statelog_check_state; - static string statelog_index_by_client_prefix = "1_"; static string statelog_index_by_object_prefix = "2_"; @@ -301,10 +295,16 @@ static int cls_statelog_check_state(cls_method_context_t hctx, bufferlist *in, b return 0; } -void __cls_init() +CLS_INIT(statelog) { CLS_LOG(1, "Loaded log class!"); + cls_handle_t h_class; + cls_method_handle_t h_statelog_add; + cls_method_handle_t h_statelog_list; + cls_method_handle_t h_statelog_remove; + cls_method_handle_t h_statelog_check_state; + cls_register("statelog", &h_class); /* log */ diff --git a/src/cls/timeindex/cls_timeindex.cc b/src/cls/timeindex/cls_timeindex.cc index 3300362a3ee..dead05b6815 100644 --- a/src/cls/timeindex/cls_timeindex.cc +++ b/src/cls/timeindex/cls_timeindex.cc @@ -20,11 +20,6 @@ CLS_VER(1,0) CLS_NAME(timeindex) -cls_handle_t h_class; -cls_method_handle_t h_timeindex_add; -cls_method_handle_t h_timeindex_list; -cls_method_handle_t h_timeindex_trim; - static const size_t MAX_LIST_ENTRIES = 1000; static const size_t MAX_TRIM_ENTRIES = 1000; @@ -254,10 +249,15 @@ static int cls_timeindex_trim(cls_method_context_t hctx, return 0; } -void __cls_init() +CLS_INIT(timeindex) { CLS_LOG(1, "Loaded timeindex class!"); + cls_handle_t h_class; + cls_method_handle_t h_timeindex_add; + cls_method_handle_t h_timeindex_list; + cls_method_handle_t h_timeindex_trim; + cls_register("timeindex", &h_class); /* timeindex */ diff --git a/src/cls/user/cls_user.cc b/src/cls/user/cls_user.cc index 91e8f8fb212..e3759e2bc44 100644 --- a/src/cls/user/cls_user.cc +++ b/src/cls/user/cls_user.cc @@ -17,13 +17,6 @@ CLS_VER(1,0) CLS_NAME(user) -cls_handle_t h_class; -cls_method_handle_t h_user_set_buckets_info; -cls_method_handle_t h_user_complete_stats_sync; -cls_method_handle_t h_user_remove_bucket; -cls_method_handle_t h_user_list_buckets; -cls_method_handle_t h_user_get_header; - static int write_entry(cls_method_context_t hctx, const string& key, const cls_user_bucket_entry& entry) { bufferlist bl; @@ -370,10 +363,17 @@ static int cls_user_get_header(cls_method_context_t hctx, bufferlist *in, buffer return 0; } -void __cls_init() +CLS_INIT(user) { CLS_LOG(1, "Loaded user class!"); + cls_handle_t h_class; + cls_method_handle_t h_user_set_buckets_info; + cls_method_handle_t h_user_complete_stats_sync; + cls_method_handle_t h_user_remove_bucket; + cls_method_handle_t h_user_list_buckets; + cls_method_handle_t h_user_get_header; + cls_register("user", &h_class); /* log */ diff --git a/src/cls/version/cls_version.cc b/src/cls/version/cls_version.cc index 307ec3396d1..e6a12a18cac 100644 --- a/src/cls/version/cls_version.cc +++ b/src/cls/version/cls_version.cc @@ -20,13 +20,6 @@ CLS_VER(1,0) CLS_NAME(version) -cls_handle_t h_class; -cls_method_handle_t h_version_set; -cls_method_handle_t h_version_inc; -cls_method_handle_t h_version_inc_conds; -cls_method_handle_t h_version_read; -cls_method_handle_t h_version_check_conds; - #define VERSION_ATTR "ceph.objclass.version" @@ -223,10 +216,17 @@ static int cls_version_read(cls_method_context_t hctx, bufferlist *in, bufferlis return 0; } -void __cls_init() +CLS_INIT(version) { CLS_LOG(1, "Loaded version class!"); + cls_handle_t h_class; + cls_method_handle_t h_version_set; + cls_method_handle_t h_version_inc; + cls_method_handle_t h_version_inc_conds; + cls_method_handle_t h_version_read; + cls_method_handle_t h_version_check_conds; + cls_register("version", &h_class); /* version */ diff --git a/src/cls_acl.cc b/src/cls_acl.cc index db0cdac2e23..5c751c5abfb 100644 --- a/src/cls_acl.cc +++ b/src/cls_acl.cc @@ -16,10 +16,6 @@ CLS_VER(1,0) CLS_NAME(acl) -cls_handle_t h_class; -cls_method_handle_t h_get; -cls_method_handle_t h_set; - int get_method(cls_method_context_t ctx, char *indata, int datalen, char **outdata, int *outdatalen) { @@ -46,10 +42,14 @@ int set_method(cls_method_context_t ctx, char *indata, int datalen, return 0; } -void __cls_init() +CLS_INIT(acl) { cls_log("Loaded acl class!"); + cls_handle_t h_class; + cls_method_handle_t h_get; + cls_method_handle_t h_set; + cls_register("acl", &h_class); cls_register_method(h_class, "get", CLS_METHOD_RD, get_method, &h_get); cls_register_method(h_class, "set", CLS_METHOD_WR, set_method, &h_set); diff --git a/src/cls_crypto.cc b/src/cls_crypto.cc index db940041017..ef92accb614 100644 --- a/src/cls_crypto.cc +++ b/src/cls_crypto.cc @@ -13,11 +13,6 @@ CLS_VER(1,0) CLS_NAME(crypto) -cls_handle_t h_class; - -cls_method_handle_t h_md5; -cls_method_handle_t h_sha1; - int md5_method(cls_method_context_t ctx, char *indata, int datalen, char **outdata, int *outdatalen) { @@ -64,10 +59,14 @@ int sha1_method(cls_method_context_t ctx, char *indata, int datalen, return 0; } -void __cls_init() +CLS_INIT(crypto) { cls_log("Loaded crypto class!"); + cls_handle_t h_class; + cls_method_handle_t h_md5; + cls_method_handle_t h_sha1; + cls_register("crypto", &h_class); cls_register_method(h_class, "md5", CLS_METHOD_RD, md5_method, &h_md5); cls_register_method(h_class, "sha1", CLS_METHOD_RD, sha1_method, &h_sha1); diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index 983fe368405..dd92974c449 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -126,9 +126,22 @@ /* Accelio conditional compilation */ #cmakedefine HAVE_XIO + /* AsyncMessenger RDMA conditional compilation */ #cmakedefine HAVE_RDMA +/* define if embedded enabled */ +#cmakedefine WITH_EMBEDDED + +/* define if cephfs enabled */ +#cmakedefine WITH_CEPHFS + +/* define if rbd enabled */ +#cmakedefine WITH_RBD + +/* define if key-value-store is enabled */ +#cmakedefine WITH_KVS + /* define if radosgw enabled */ #cmakedefine WITH_RADOSGW diff --git a/src/key_value_store/CMakeLists.txt b/src/key_value_store/CMakeLists.txt index babfb6bc4c8..525697d8b91 100644 --- a/src/key_value_store/CMakeLists.txt +++ b/src/key_value_store/CMakeLists.txt @@ -2,3 +2,8 @@ set(kvs_srcs cls_kvs.cc) add_library(cls_kvs SHARED ${kvs_srcs}) set_target_properties(cls_kvs PROPERTIES VERSION "1.0.0" SOVERSION "1") install(TARGETS cls_kvs DESTINATION ${CMAKE_INSTALL_LIBDIR}/rados-classes) + +if(WITH_EMBEDDED) + add_library(cephd_cls_kvs STATIC ${kvs_srcs}) + set_target_properties(cephd_cls_kvs PROPERTIES COMPILE_DEFINITIONS BUILDING_FOR_EMBEDDED) +endif() diff --git a/src/key_value_store/cls_kvs.cc b/src/key_value_store/cls_kvs.cc index 841f56fa833..2a6f3ab67bd 100644 --- a/src/key_value_store/cls_kvs.cc +++ b/src/key_value_store/cls_kvs.cc @@ -13,19 +13,6 @@ #include -cls_handle_t h_class; -cls_method_handle_t h_get_idata_from_key; -cls_method_handle_t h_get_next_idata; -cls_method_handle_t h_get_prev_idata; -cls_method_handle_t h_read_many; -cls_method_handle_t h_check_writable; -cls_method_handle_t h_assert_size_in_bound; -cls_method_handle_t h_omap_insert; -cls_method_handle_t h_create_with_omap; -cls_method_handle_t h_omap_remove; -cls_method_handle_t h_maybe_read_for_balance; - - /** * finds the index_data where a key belongs. * @@ -644,10 +631,22 @@ static int maybe_read_for_balance_op(cls_method_context_t hctx, } -void __cls_init() +CLS_INIT(kvs) { CLS_LOG(20, "Loaded assert condition class!"); + cls_handle_t h_class; + cls_method_handle_t h_get_idata_from_key; + cls_method_handle_t h_get_next_idata; + cls_method_handle_t h_get_prev_idata; + cls_method_handle_t h_read_many; + cls_method_handle_t h_check_writable; + cls_method_handle_t h_assert_size_in_bound; + cls_method_handle_t h_omap_insert; + cls_method_handle_t h_create_with_omap; + cls_method_handle_t h_omap_remove; + cls_method_handle_t h_maybe_read_for_balance; + cls_register("kvs", &h_class); cls_register_cxx_method(h_class, "get_idata_from_key", CLS_METHOD_RD, diff --git a/src/libcephd/CMakeLists.txt b/src/libcephd/CMakeLists.txt index 9ba77fd9527..25d90c2dee3 100644 --- a/src/libcephd/CMakeLists.txt +++ b/src/libcephd/CMakeLists.txt @@ -11,11 +11,10 @@ set(merge_libs cephd_base cephd_compressor cephd_ec + cephd_cls + cephd_cls_kvs cephd_rados cephd_rbd - cls_journal_client - cls_lock_client - cls_rbd_client common common_utf8 erasure_code diff --git a/src/libcephd/libcephd.cc b/src/libcephd/libcephd.cc index 4a75e433c4d..6adf4d3fa8e 100644 --- a/src/libcephd/libcephd.cc +++ b/src/libcephd/libcephd.cc @@ -18,6 +18,27 @@ #include "include/cephd/libcephd.h" #include "global/global_context.h" #include "global/global_init.h" +#include "objclass/objclass.h" +#include "osd/OSD.h" +#include "osd/ClassHandler.h" + +// forward declarations of RADOS class init functions +CLS_INIT(cephfs); +CLS_INIT(hello); +CLS_INIT(journal); +CLS_INIT(kvs); +CLS_INIT(lock); +CLS_INIT(log); +CLS_INIT(lua); +CLS_INIT(numops); +CLS_INIT(rbd); +CLS_INIT(refcount); +CLS_INIT(replica_log); +CLS_INIT(rgw); +CLS_INIT(statelog); +CLS_INIT(timeindex); +CLS_INIT(user); +CLS_INIT(version); extern "C" void cephd_version(int *pmajor, int *pminor, int *ppatch) { @@ -150,6 +171,56 @@ void cephd_preload_embedded_plugins() } } +void cephd_preload_rados_classes(OSD *osd) +{ + // intialize RADOS classes + { + ClassHandler *class_handler = osd->class_handler; + Mutex::Locker l(class_handler->mutex); + +#ifdef WITH_CEPHFS + class_handler->add_embedded_class("cephfs"); + cephfs_cls_init(); +#endif + class_handler->add_embedded_class("hello"); + hello_cls_init(); + class_handler->add_embedded_class("journal"); + journal_cls_init(); +#ifdef WITH_KVS + class_handler->add_embedded_class("kvs"); + kvs_cls_init(); +#endif + class_handler->add_embedded_class("lock"); + lock_cls_init(); + class_handler->add_embedded_class("log"); + log_cls_init(); + class_handler->add_embedded_class("lua"); + lua_cls_init(); + class_handler->add_embedded_class("numops"); + numops_cls_init(); +#ifdef WITH_RBD + class_handler->add_embedded_class("rbd"); + rbd_cls_init(); +#endif + class_handler->add_embedded_class("refcount"); + refcount_cls_init(); + class_handler->add_embedded_class("replica_log"); + replica_log_cls_init(); +#ifdef WITH_RADOSGW + class_handler->add_embedded_class("rgw"); + rgw_cls_init(); +#endif + class_handler->add_embedded_class("statelog"); + statelog_cls_init(); + class_handler->add_embedded_class("timeindex"); + timeindex_cls_init(); + class_handler->add_embedded_class("user"); + user_cls_init(); + class_handler->add_embedded_class("version"); + version_cls_init(); + } +} + extern "C" int cephd_mon(int argc, const char **argv); extern "C" int cephd_osd(int argc, const char **argv); diff --git a/src/objclass/objclass.h b/src/objclass/objclass.h index f6eac06109f..7cdb25b9678 100644 --- a/src/objclass/objclass.h +++ b/src/objclass/objclass.h @@ -13,9 +13,16 @@ struct obj_list_watch_response_t; +#if __GNUC__ >= 4 + #define CEPH_CLS_API __attribute__ ((visibility ("default"))) +#else + #define CEPH_CLS_API +#endif + extern "C" { #endif +#ifndef BUILDING_FOR_EMBEDDED #define CLS_VER(maj,min) \ int __cls_ver__## maj ## _ ##min = 0; \ int __cls_ver_maj = maj; \ @@ -24,6 +31,14 @@ int __cls_ver_min = min; #define CLS_NAME(name) \ int __cls_name__## name = 0; \ const char *__cls_name = #name; +#define CLS_INIT(name) \ +void CEPH_CLS_API __cls_init() +#else +#define CLS_VER(maj,min) +#define CLS_NAME(name) +#define CLS_INIT(name) \ +void CEPH_CLS_API name##_cls_init() +#endif #define CLS_METHOD_RD 0x1 /// method executes read operations #define CLS_METHOD_WR 0x2 /// method executes write operations diff --git a/src/osd/ClassHandler.cc b/src/osd/ClassHandler.cc index 045683b780e..23afdfad5b4 100644 --- a/src/osd/ClassHandler.cc +++ b/src/osd/ClassHandler.cc @@ -26,6 +26,14 @@ #define CLS_SUFFIX ".so" +void ClassHandler::add_embedded_class(const string& cname) +{ + assert(mutex.is_locked()); + ClassData *cls = _get_class(cname, false); + assert(cls->status == ClassData::CLASS_UNKNOWN); + cls->status = ClassData::CLASS_INITIALIZING; +} + int ClassHandler::open_class(const string& cname, ClassData **pcls) { Mutex::Locker lock(mutex); diff --git a/src/osd/ClassHandler.h b/src/osd/ClassHandler.h index 3cca309a12c..9b71e97a47a 100644 --- a/src/osd/ClassHandler.h +++ b/src/osd/ClassHandler.h @@ -100,7 +100,6 @@ public: }; private: - Mutex mutex; map classes; ClassData *_get_class(const string& cname, bool check_allowed); @@ -110,10 +109,13 @@ private: const std::string& list); public: + Mutex mutex; + explicit ClassHandler(CephContext *cct_) : cct(cct_), mutex("ClassHandler") {} - + int open_all_classes(); + void add_embedded_class(const string& cname); int open_class(const string& cname, ClassData **pcls); ClassData *register_class(const char *cname); -- 2.39.5