]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
embedded: Add RADOS classes to embedded cephd library
authorBassam Tabbara <bassam.tabbara@quantum.com>
Sat, 5 Nov 2016 01:10:08 +0000 (18:10 -0700)
committerBassam Tabbara <bassam.tabbara@quantum.com>
Tue, 29 Nov 2016 07:48:02 +0000 (23:48 -0800)
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 <bassam.tabbara@quantum.com>
28 files changed:
src/CMakeLists.txt
src/ceph_osd.cc
src/cls/CMakeLists.txt
src/cls/cephfs/cls_cephfs.cc
src/cls/hello/cls_hello.cc
src/cls/journal/cls_journal.cc
src/cls/lock/cls_lock.cc
src/cls/log/cls_log.cc
src/cls/lua/cls_lua.cc
src/cls/numops/cls_numops.cc
src/cls/rbd/cls_rbd.cc
src/cls/refcount/cls_refcount.cc
src/cls/replica_log/cls_replica_log.cc
src/cls/rgw/cls_rgw.cc
src/cls/statelog/cls_statelog.cc
src/cls/timeindex/cls_timeindex.cc
src/cls/user/cls_user.cc
src/cls/version/cls_version.cc
src/cls_acl.cc
src/cls_crypto.cc
src/include/config-h.in.cmake
src/key_value_store/CMakeLists.txt
src/key_value_store/cls_kvs.cc
src/libcephd/CMakeLists.txt
src/libcephd/libcephd.cc
src/objclass/objclass.h
src/osd/ClassHandler.cc
src/osd/ClassHandler.h

index e49d2a2bd371676a3ef6bd603ee5d4e84e963a83..33f7ae95487436e8206dd6f9430d5b69693e70a5 100644 (file)
@@ -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
index 404fcd430a3a1de8214210e431c49c4a83e3ad66..db1e4a9a143c628fe0592a6f9915ccd95f2a27d8 100644 (file)
@@ -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)
index 9741f3697391ba32d5060357aa97bc279dcbacad..8387e4c3bb58edfbee8713a392d96c62a9741027 100644 (file)
 ## 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()
index 6e81a53e98666b6bd62da49a73afd3a43c40e294..3537f68450b970beab1516ff0e5847f86a7d8f22 100644 (file)
 #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",
index 2751d3c0a76934f34cf7da3b2516ff0093ebe81a..d181d3fab60bc41f8f7e2583786047004b67cb39 100644 (file)
 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:
index 2682926d57a4e35ca9e5d9200973a15a18d39118..ffa18c3c56f7a56803ebdbd490a9d36201730e78 100644 (file)
 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
index 179c1d3f2bc124a6ce5330e9ed6e00414f99bbfb..14e3b0dcdd420f1bbeb59acec54f44afb5347905 100644 (file)
@@ -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,
index 89745bb8bb73a95703fb9a99b7390bd16244141f..a53149ce3b3794af1e4479ff1b9d8f5359b2c045 100644 (file)
 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 */
index 57707094968ddec05705a3e6ab1dad1111579ece..1e15b4ed6fe11e0f948b94c2295b31fcd63be7b9 100644 (file)
 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",
index a9823bcab80d4cce33a15ac5ff9ac4d2cd0a6c34..a4023b934c8294ebe698a5e5d7b654214614fe28 100644 (file)
 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",
index 1d53d4a2ab548029e33d0c9564078d38e214360b..c9850fea1d05578a8933207045df3a1344f135dc 100644 (file)
 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,
index f5598aeea94049cd74b7286396353c7ebfa05657..9a196c9770d2d3d6245207c5c49a27524c42f46d 100644 (file)
 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 */
index 1083b8adc38bdeb8e18594982d8cc34652144f1c..bc8f088715fd523f845aec97a580d426d95c1aad 100644 (file)
 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,
index 3fe55676ac1bf8431f15f930da94eea8203e5282..9873590487bc29245e4c877bb737253894d8268d 100644 (file)
 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 */
index f2cbbf79672ef10370f2d440b74ba2867c3f79ec..5a43da1a6a69289aaa5a5e92c196872dcbbdc4d9 100644 (file)
 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 */
index 3300362a3ee497b7a898d6e89ee27c3c4e0642f7..dead05b68151d3a0374bced344ff0b869b6cc974 100644 (file)
 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 */
index 91e8f8fb21236794cf15752027cee823eba55787..e3759e2bc44db1ec9b244e1c59baede5339ebd27 100644 (file)
 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 */
index 307ec3396d1a727e5f9e77950e978311cab4c0dd..e6a12a18cac51d113b50f7d21af571f0c470feb1 100644 (file)
 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 */
index db0cdac2e230ea84e091a2d451a1d6d0829de3f8..5c751c5abfb6789cc016a527e78c6b7829b315e4 100644 (file)
 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);
index db940041017ed88432930ae8e16d7f1f7ccdddcc..ef92accb6142a902b4ea7d55dbc61bdacf20c1fd 100644 (file)
 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);
index 983fe3684057dd93a645ab5940c363ef8e429e44..dd92974c4492c23166ac257fadc88d2e3ce154ec 100644 (file)
 /* 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
 
index babfb6bc4c8c2677eb0f2eb8385159115fb79de1..525697d8b91243ae2e37e9eabedfd39d1945a1e3 100644 (file)
@@ -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()
index 841f56fa833c979fb040f472b3945691736845f1..2a6f3ab67bdd152bc68baedcb68e0046331ec7ad 100644 (file)
 #include <climits>
 
 
-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,
index 9ba77fd95279b3be2fa205f5700d380f976a0654..25d90c2dee31a4105d502ce8045a1d5503f9d9ee 100644 (file)
@@ -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
index 4a75e433c4d4c150f064f764e82e35ce529ff0c6..6adf4d3fa8e6e76918dc24ebe0920d60baa838e0 100644 (file)
 #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);
 
index f6eac06109f0fde783a58ea3e659401ac1459335..7cdb25b9678ed0d781d96a8c680d140b05419691 100644 (file)
 
 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
index 045683b780e0fb07791922b8d8226e39571db6d4..23afdfad5b4da34d466dfea0681c8f45cb5403ca 100644 (file)
 #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);
index 3cca309a12c608268335a5523b955ef56ec626eb..9b71e97a47acfaf7997fb13d4a05d5f3e23aebb9 100644 (file)
@@ -100,7 +100,6 @@ public:
   };
 
 private:
-  Mutex mutex;
   map<string, ClassData> 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);