From 93300b45c05db96485dc4be1084b3121e938225a Mon Sep 17 00:00:00 2001 From: Shraddha Agrawal Date: Fri, 24 Jul 2026 13:51:36 +0530 Subject: [PATCH] src/crimson/osd: statically link the ISA plugin in crimson-osd Problem: Before this change, when the ISA plugin (classic build, dlopen'd), would try to log, it'd segfault due to null g_ceph_context. We need a way to make logging work for EC plugins in crimson. Solution: By building the ISA plugin WITH_CRIMSON, its logging is routed to seastar's logger, solving the issue. It is not build separately and dlopen'd like in classic because doing so would require the plugin to have its own seastar logger copy, an undesirable outcome. It is a statically built library in the crimson-osd binary, and thus it shares the single seastar logger. The library is linked with --whole-archive so the self-registration constructor is not dropped. Signed-off-by: Shraddha Agrawal --- src/crimson/CMakeLists.txt | 12 ++++++++++++ src/erasure-code/isa/ErasureCodePluginIsa.cc | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/crimson/CMakeLists.txt b/src/crimson/CMakeLists.txt index 2a97044226b2..e0fe354fd0f2 100644 --- a/src/crimson/CMakeLists.txt +++ b/src/crimson/CMakeLists.txt @@ -209,3 +209,15 @@ add_subdirectory(admin) add_subdirectory(os) add_subdirectory(osd) add_subdirectory(tools) + +if(WITH_EC_ISA_PLUGIN) + add_library(ec_isa_crimson STATIC + ${PROJECT_SOURCE_DIR}/src/erasure-code/isa/ErasureCodeIsa.cc + ${PROJECT_SOURCE_DIR}/src/erasure-code/isa/ErasureCodeIsaTableCache.cc + ${PROJECT_SOURCE_DIR}/src/erasure-code/isa/ErasureCodePluginIsa.cc + $) + target_link_libraries(ec_isa_crimson PUBLIC ISAL::ISAL crimson::cflags) + target_compile_definitions(ec_isa_crimson INTERFACE WITH_EC_ISA_PLUGIN) + target_link_libraries(crimson-osd + -Wl,--whole-archive ec_isa_crimson -Wl,--no-whole-archive) +endif() diff --git a/src/erasure-code/isa/ErasureCodePluginIsa.cc b/src/erasure-code/isa/ErasureCodePluginIsa.cc index 7904f407d7cf..817d9bd3af3d 100644 --- a/src/erasure-code/isa/ErasureCodePluginIsa.cc +++ b/src/erasure-code/isa/ErasureCodePluginIsa.cc @@ -81,7 +81,13 @@ int __erasure_code_init(char *plugin_name, char *directory) auto plugin = std::make_unique(); int r = instance.add(plugin_name, plugin.get()); if (r == 0) { - plugin.release(); + plugin.release(); } return r; } + +#ifdef WITH_CRIMSON +[[maybe_unused]] static int _isa_builtin = + ceph::ErasureCodePluginRegistry::register_builtin( + "isa", []{ return new ErasureCodePluginIsa(); }); +#endif -- 2.47.3