From b957a518f34d768ffc06404bf6f4c30bb69312d0 Mon Sep 17 00:00:00 2001 From: Bassam Tabbara Date: Fri, 27 Jan 2017 12:42:28 -0800 Subject: [PATCH] compressor/zstd: add zstd to embedded ceph Signed-off-by: Bassam Tabbara --- src/compressor/zstd/CompressionPluginZstd.cc | 29 +++---------- src/compressor/zstd/CompressionPluginZstd.h | 43 ++++++++++++++++++++ src/libcephd/libcephd.cc | 8 ++++ src/test/libcephd/CMakeLists.txt | 2 +- 4 files changed, 57 insertions(+), 25 deletions(-) create mode 100644 src/compressor/zstd/CompressionPluginZstd.h diff --git a/src/compressor/zstd/CompressionPluginZstd.cc b/src/compressor/zstd/CompressionPluginZstd.cc index 2170dbd7e6c..321b3dd96f6 100644 --- a/src/compressor/zstd/CompressionPluginZstd.cc +++ b/src/compressor/zstd/CompressionPluginZstd.cc @@ -12,32 +12,11 @@ * */ -#include - -// ----------------------------------------------------------------------------- +#include "acconfig.h" #include "ceph_ver.h" -#include "compressor/CompressionPlugin.h" -#include "ZstdCompressor.h" -// ----------------------------------------------------------------------------- - -class CompressionPluginZstd : public CompressionPlugin { +#include "CompressionPluginZstd.h" -public: - - explicit CompressionPluginZstd(CephContext* cct) : CompressionPlugin(cct) - {} - - virtual int factory(CompressorRef *cs, - std::ostream *ss) - { - if (compressor == 0) { - ZstdCompressor *interface = new ZstdCompressor(); - compressor = CompressorRef(interface); - } - *cs = compressor; - return 0; - } -}; +#ifndef BUILDING_FOR_EMBEDDED // ----------------------------------------------------------------------------- @@ -56,3 +35,5 @@ int __ceph_plugin_init(CephContext *cct, return instance->add(type, name, new CompressionPluginZstd(cct)); } + +#endif // !BUILDING_FOR_EMBEDDED diff --git a/src/compressor/zstd/CompressionPluginZstd.h b/src/compressor/zstd/CompressionPluginZstd.h new file mode 100644 index 00000000000..59c52cfeeae --- /dev/null +++ b/src/compressor/zstd/CompressionPluginZstd.h @@ -0,0 +1,43 @@ +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2015 Mirantis, Inc. + * + * Author: Alyona Kiseleva + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + */ + +#ifndef CEPH_COMPRESSION_PLUGIN_ZSTD_H +#define CEPH_COMPRESSION_PLUGIN_ZSTD_H + +// ----------------------------------------------------------------------------- +#include "ceph_ver.h" +#include "compressor/CompressionPlugin.h" +#include "ZstdCompressor.h" +// ----------------------------------------------------------------------------- + +class CompressionPluginZstd : public CompressionPlugin { + +public: + + explicit CompressionPluginZstd(CephContext* cct) : CompressionPlugin(cct) + {} + + virtual int factory(CompressorRef *cs, + std::ostream *ss) + { + if (compressor == 0) { + ZstdCompressor *interface = new ZstdCompressor(); + compressor = CompressorRef(interface); + } + *cs = compressor; + return 0; + } +}; + +#endif diff --git a/src/libcephd/libcephd.cc b/src/libcephd/libcephd.cc index c653879d6c9..71b0767f03c 100644 --- a/src/libcephd/libcephd.cc +++ b/src/libcephd/libcephd.cc @@ -7,6 +7,7 @@ #include "common/PluginRegistry.h" #include "compressor/snappy/CompressionPluginSnappy.h" #include "compressor/zlib/CompressionPluginZlib.h" +#include "compressor/zstd/CompressionPluginZstd.h" #include "erasure-code/ErasureCodePlugin.h" #if __x86_64__ && defined(HAVE_BETTER_YASM_ELF64) #include "erasure-code/isa/ErasureCodePluginIsa.h" @@ -168,6 +169,13 @@ void cephd_preload_embedded_plugins() delete plugin; } assert(r == 0); + + plugin = new CompressionPluginZstd(g_ceph_context); + r = reg->add("compressor", "zstd", plugin); + if (r == -EEXIST) { + delete plugin; + } + assert(r == 0); } } diff --git a/src/test/libcephd/CMakeLists.txt b/src/test/libcephd/CMakeLists.txt index 60a28cbb812..8aa253562c4 100644 --- a/src/test/libcephd/CMakeLists.txt +++ b/src/test/libcephd/CMakeLists.txt @@ -16,7 +16,7 @@ add_executable(ceph_test_cephd_api_misc set_target_properties(ceph_test_cephd_api_misc PROPERTIES COMPILE_FLAGS ${UNITTEST_CXX_FLAGS}) target_link_libraries(ceph_test_cephd_api_misc - cephd global ${UNITTEST_LIBS} cephdtest z snappy) + cephd global ${UNITTEST_LIBS} cephdtest z snappy ceph_zstd) install(TARGETS ceph_test_cephd_api_misc -- 2.47.3