#include <errno.h>
#include <dlfcn.h>
+#include "ceph_ver.h"
#include "ErasureCodePlugin.h"
#include "common/errno.h"
#include "include/str_list.h"
#define PLUGIN_PREFIX "libec_"
#define PLUGIN_SUFFIX ".so"
#define PLUGIN_INIT_FUNCTION "__erasure_code_init"
+#define PLUGIN_VERSION_FUNCTION "__erasure_code_version"
ErasureCodePluginRegistry ErasureCodePluginRegistry::singleton;
return plugin->factory(parameters, erasure_code);
}
+static const char *an_older_version() {
+ return "an older version";
+}
+
int ErasureCodePluginRegistry::load(const std::string &plugin_name,
const std::string &directory,
ErasureCodePlugin **plugin,
return -EIO;
}
+ const char * (*erasure_code_version)() =
+ (const char *(*)())dlsym(library, PLUGIN_VERSION_FUNCTION);
+ if (erasure_code_version == NULL)
+ erasure_code_version = an_older_version;
+ if (erasure_code_version() != string(CEPH_GIT_NICE_VER)) {
+ ss << "expected plugin " << fname << " version " << CEPH_GIT_NICE_VER
+ << " but it claims to be " << erasure_code_version() << " instead";
+ dlclose(library);
+ return -EXDEV;
+ }
+
int (*erasure_code_init)(const char *, const char *) =
(int (*)(const char *, const char *))dlsym(library, PLUGIN_INIT_FUNCTION);
if (erasure_code_init) {
#include "ErasureCodeInterface.h"
extern "C" {
+ const char *__erasure_code_version();
int __erasure_code_init(char *plugin_name, char *directory);
}
liberasure_code_la_SOURCES = \
erasure-code/ErasureCodePlugin.cc
-
+erasure-code/ErasureCodePlugin.cc: ./ceph_ver.h
if LINUX
liberasure_code_la_LIBADD = -ldl
endif # LINUX
*/
// -----------------------------------------------------------------------------
+#include "ceph_ver.h"
#include "common/debug.h"
#include "erasure-code/ErasureCodePlugin.h"
#include "ErasureCodeIsa.h"
// -----------------------------------------------------------------------------
+const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
+
int __erasure_code_init(char *plugin_name, char *directory)
{
ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
erasure-code/isa/ErasureCodePluginIsa.cc \
erasure-code/isa/xor_op.cc
+erasure-code/isa/ErasureCodePluginIsa.cc: ./ceph_ver.h
+
libec_isa_la_SOURCES = ${isa_sources}
libec_isa_la_CFLAGS = ${AM_CFLAGS} -I $(srcdir)/erasure-code/isa/isa-l/include/
*
*/
+#include "ceph_ver.h"
#include "common/debug.h"
#include "erasure-code/ErasureCodePlugin.h"
#include "ErasureCodeJerasure.h"
extern int gfp_is_composite[];
}
+const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
+
int __erasure_code_init(char *plugin_name, char *directory)
{
ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
*
*/
+#include "ceph_ver.h"
#include "common/debug.h"
#include "arch/probe.h"
#include "arch/intel.h"
}
};
+const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
+
int __erasure_code_init(char *plugin_name, char *directory)
{
ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
erasure-code/jerasure/ErasureCodePluginJerasure.cc \
erasure-code/jerasure/ErasureCodeJerasure.cc
+erasure-code/jerasure/ErasureCodePluginJerasure.cc: ./ceph_ver.h
+
libec_jerasure_generic_la_SOURCES = ${jerasure_sources}
libec_jerasure_generic_la_CFLAGS = ${AM_CFLAGS} \
-I$(srcdir)/erasure-code/jerasure/gf-complete/include \
libec_jerasure_la_LDFLAGS += -export-symbols-regex '.*__erasure_code_.*'
endif
+erasure-code/jerasure/ErasureCodePluginSelectJerasure.cc: ./ceph_ver.h
+
erasure_codelib_LTLIBRARIES += libec_jerasure.la
#include <unistd.h>
+#include "ceph_ver.h"
#include "erasure-code/ErasureCodePlugin.h"
#include "ErasureCodeExample.h"
}
};
+const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
+
int __erasure_code_init(char *plugin_name, char *directory)
{
ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
*/
#include <errno.h>
-#include "erasure-code/ErasureCodePlugin.h"
+#include "ceph_ver.h"
-int __erasure_code_init(char *plugin_name, char *directory)
+extern "C" const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
+
+extern "C" int __erasure_code_init(char *plugin_name, char *directory)
{
return -ESRCH;
}
*
*/
-#include "erasure-code/ErasureCodePlugin.h"
+#include "ceph_ver.h"
-int __erasure_code_init(char *plugin_name, char *directory)
+extern "C" const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
+
+extern "C" int __erasure_code_init(char *plugin_name, char *directory)
{
return 0;
}
*/
#include <unistd.h>
-#include "erasure-code/ErasureCodePlugin.h"
+#include "ceph_ver.h"
+
+extern "C" const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
int __erasure_code_init(char *plugin_name, char *directory)
{
+#include "ceph_ver.h"
+
// missing int __erasure_code_init(char *plugin_name, char *directory) {}
-// avoid warnings about library containing no symbols
-int __this_is_an_used_variable_to_avoid_warnings;
+extern "C" const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
+
--- /dev/null
+// missing __erasure_code_version
+
+int __this_is_an_used_variable_to_avoid_warnings;
bin_DEBUGPROGRAMS += ceph_erasure_code
libec_example_la_SOURCES = test/erasure-code/ErasureCodePluginExample.cc
+test/erasure-code/ErasureCodePluginExample.cc: ./ceph_ver.h
libec_example_la_CFLAGS = ${AM_CFLAGS}
libec_example_la_CXXFLAGS= ${AM_CXXFLAGS}
libec_example_la_LIBADD = $(LIBCRUSH) $(PTHREAD_LIBS) $(EXTRALIBS)
erasure_codelib_LTLIBRARIES += libec_example.la
libec_missing_entry_point_la_SOURCES = test/erasure-code/ErasureCodePluginMissingEntryPoint.cc
+test/erasure-code/ErasureCodePluginMissingEntryPoint.cc: ./ceph_ver.h
libec_missing_entry_point_la_CFLAGS = ${AM_CFLAGS}
libec_missing_entry_point_la_CXXFLAGS= ${AM_CXXFLAGS}
libec_missing_entry_point_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS)
libec_missing_entry_point_la_LDFLAGS = ${AM_LDFLAGS} -export-symbols-regex '.*__erasure_code_.*'
erasure_codelib_LTLIBRARIES += libec_missing_entry_point.la
+libec_missing_version_la_SOURCES = test/erasure-code/ErasureCodePluginMissingVersion.cc
+libec_missing_version_la_CFLAGS = ${AM_CFLAGS}
+libec_missing_version_la_CXXFLAGS= ${AM_CXXFLAGS}
+libec_missing_version_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS)
+libec_missing_version_la_LDFLAGS = ${AM_LDFLAGS} -export-symbols-regex '.*__erasure_code_.*'
+erasure_codelib_LTLIBRARIES += libec_missing_version.la
+
libec_hangs_la_SOURCES = test/erasure-code/ErasureCodePluginHangs.cc
+test/erasure-code/ErasureCodePluginHangs.cc: ./ceph_ver.h
libec_hangs_la_CFLAGS = ${AM_CFLAGS}
libec_hangs_la_CXXFLAGS= ${AM_CXXFLAGS}
libec_hangs_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS)
erasure_codelib_LTLIBRARIES += libec_hangs.la
libec_fail_to_initialize_la_SOURCES = test/erasure-code/ErasureCodePluginFailToInitialize.cc
+test/erasure-code/ErasureCodePluginFailToInitialize.cc: ./ceph_ver.h
libec_fail_to_initialize_la_CFLAGS = ${AM_CFLAGS}
libec_fail_to_initialize_la_CXXFLAGS= ${AM_CXXFLAGS}
libec_fail_to_initialize_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS)
erasure_codelib_LTLIBRARIES += libec_fail_to_initialize.la
libec_fail_to_register_la_SOURCES = test/erasure-code/ErasureCodePluginFailToRegister.cc
+test/erasure-code/ErasureCodePluginFailToRegister.cc: ./ceph_ver.h
libec_fail_to_register_la_CFLAGS = ${AM_CFLAGS}
libec_fail_to_register_la_CXXFLAGS= ${AM_CXXFLAGS}
libec_fail_to_register_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS)
erasure_codelib_LTLIBRARIES += libec_fail_to_register.la
libec_test_jerasure_sse4_la_SOURCES = test/erasure-code/TestJerasurePluginSSE4.cc
+test/erasure-code/TestJerasurePluginSSE4.cc: ./ceph_ver.h
libec_test_jerasure_sse4_la_CFLAGS = ${AM_CFLAGS}
libec_test_jerasure_sse4_la_CXXFLAGS= ${AM_CXXFLAGS}
libec_test_jerasure_sse4_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS)
erasure_codelib_LTLIBRARIES += libec_test_jerasure_sse4.la
libec_test_jerasure_sse3_la_SOURCES = test/erasure-code/TestJerasurePluginSSE3.cc
+test/erasure-code/TestJerasurePluginSSE3.cc: ./ceph_ver.h
libec_test_jerasure_sse3_la_CFLAGS = ${AM_CFLAGS}
libec_test_jerasure_sse3_la_CXXFLAGS= ${AM_CXXFLAGS}
libec_test_jerasure_sse3_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS)
erasure_codelib_LTLIBRARIES += libec_test_jerasure_sse3.la
libec_test_jerasure_generic_la_SOURCES = test/erasure-code/TestJerasurePluginGeneric.cc
+test/erasure-code/TestJerasurePluginGeneric.cc: ./ceph_ver.h
libec_test_jerasure_generic_la_CFLAGS = ${AM_CFLAGS}
libec_test_jerasure_generic_la_CXXFLAGS= ${AM_CXXFLAGS}
libec_test_jerasure_generic_la_LIBADD = $(PTHREAD_LIBS) $(EXTRALIBS)
EXPECT_FALSE(erasure_code);
EXPECT_EQ(-EIO, instance.factory("invalid", parameters, &erasure_code, ss));
EXPECT_FALSE(erasure_code);
+ EXPECT_EQ(-EXDEV, instance.factory("missing_version", parameters,
+ &erasure_code, ss));
+ EXPECT_FALSE(erasure_code);
EXPECT_EQ(-ENOENT, instance.factory("missing_entry_point", parameters,
&erasure_code, ss));
EXPECT_FALSE(erasure_code);
*
*/
-#include "erasure-code/ErasureCodePlugin.h"
+#include "ceph_ver.h"
-int __erasure_code_init(char *plugin_name, char *directory)
+extern "C" const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
+
+extern "C" int __erasure_code_init(char *plugin_name, char *directory)
{
return -111;
}
*
*/
-#include "erasure-code/ErasureCodePlugin.h"
+#include "ceph_ver.h"
-int __erasure_code_init(char *plugin_name, char *directory)
+extern "C" const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
+
+extern "C" int __erasure_code_init(char *plugin_name, char *directory)
{
return -333;
}
*
*/
-#include "erasure-code/ErasureCodePlugin.h"
+#include "ceph_ver.h"
-int __erasure_code_init(char *plugin_name, char *directory)
+extern "C" const char *__erasure_code_version() { return CEPH_GIT_NICE_VER; }
+
+extern "C" int __erasure_code_init(char *plugin_name, char *directory)
{
return -444;
}