From: Bassam Tabbara Date: Fri, 27 Jan 2017 20:42:28 +0000 (-0800) Subject: compressor/zstd: add zstd to embedded ceph X-Git-Tag: v12.0.1~477^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b957a518f34d768ffc06404bf6f4c30bb69312d0;p=ceph.git compressor/zstd: add zstd to embedded ceph Signed-off-by: Bassam Tabbara --- diff --git a/src/compressor/zstd/CompressionPluginZstd.cc b/src/compressor/zstd/CompressionPluginZstd.cc index 2170dbd7e6ca..321b3dd96f62 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 000000000000..59c52cfeeaed --- /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 c653879d6c91..71b0767f03c5 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 60a28cbb8128..8aa253562c4b 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