From 9f3965aef3f1ddf706119d7b2f5540c799f2da0e Mon Sep 17 00:00:00 2001 From: Qiaowei Ren Date: Fri, 29 Dec 2017 12:50:20 +0800 Subject: [PATCH] compressor: add QAT support This patch adds new QATzip plugin to support QAT for compression. QATZip is a user space library which builds on top of the Intel QAT (QuickAssist Technology) user space library, to provide extended accelerated compression and decompression services by offloading the actual compression and decompression request(s) to the hardware QAT accelerators, which are more efficient in terms of cost and power than general purpose CPUs for those specific compute-intensive workloads. Based on QAT accelerators, QATZip can support several compression algorithm, including deflate, snappy, lz4, etc.. Signed-off-by: Qiaowei Ren --- CMakeLists.txt | 6 + cmake/modules/Findqatzip.cmake | 17 +++ src/CMakeLists.txt | 3 + src/common/legacy_config_opts.h | 2 + src/common/options.cc | 4 + src/compressor/CMakeLists.txt | 8 +- src/compressor/Compressor.h | 8 + src/compressor/QatAccel.cc | 141 ++++++++++++++++++ src/compressor/QatAccel.h | 35 +++++ src/compressor/lz4/CompressionPluginLZ4.h | 2 +- src/compressor/lz4/LZ4Compressor.h | 22 ++- .../snappy/CompressionPluginSnappy.h | 2 +- src/compressor/snappy/SnappyCompressor.h | 22 ++- src/compressor/zlib/CompressionPluginZlib.h | 1 - src/compressor/zlib/ZlibCompressor.cc | 13 ++ src/compressor/zlib/ZlibCompressor.h | 10 +- src/include/config-h.in.cmake | 3 + src/test/compressor/test_compression.cc | 75 ++++++++++ 18 files changed, 367 insertions(+), 7 deletions(-) create mode 100644 cmake/modules/Findqatzip.cmake create mode 100644 src/compressor/QatAccel.cc create mode 100644 src/compressor/QatAccel.h diff --git a/CMakeLists.txt b/CMakeLists.txt index bc4cb19bce0ca..d86acfd68b616 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,6 +258,12 @@ endif() option(WITH_BLUEFS "libbluefs library" OFF) +option(WITH_QATZIP "Enable QATZIP" OFF) +if(WITH_QATZIP) + find_package(qatzip REQUIRED) + set(HAVE_QATZIP ${QATZIP_FOUND}) +endif(WITH_QATZIP) + # needs mds and? XXX option(WITH_LIBCEPHFS "libcephfs client library" ON) diff --git a/cmake/modules/Findqatzip.cmake b/cmake/modules/Findqatzip.cmake new file mode 100644 index 0000000000000..3a593228dd010 --- /dev/null +++ b/cmake/modules/Findqatzip.cmake @@ -0,0 +1,17 @@ +# - Find Qatzip +# Find the qatzip compression library and includes +# +# QATZIP_INCLUDE_DIR - where to find qatzip.h, etc. +# QATZIP_LIBRARIES - List of libraries when using qatzip. +# QATZIP_FOUND - True if qatzip found. + +find_path(QATZIP_INCLUDE_DIR NAMES qatzip.h) + +find_library(QATZIP_LIBRARIES NAMES qatzip) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(qatzip DEFAULT_MSG QATZIP_LIBRARIES QATZIP_INCLUDE_DIR) + +mark_as_advanced( + QATZIP_LIBRARIES + QATZIP_INCLUDE_DIR) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 874e7f3ae12dd..a5b975e66a0e7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -648,6 +648,9 @@ endif() if(NOT WITH_SYSTEM_BOOST) list(APPEND ceph_common_deps ${ZLIB_LIBRARIES}) endif() +if(HAVE_QATZIP) + list(APPEND ceph_common_deps ${QATZIP_LIBRARIES}) +endif() set_source_files_properties(${CMAKE_SOURCE_DIR}/src/ceph_ver.c ${CMAKE_SOURCE_DIR}/src/common/version.cc diff --git a/src/common/legacy_config_opts.h b/src/common/legacy_config_opts.h index 69fbc51c1935e..981bd20197283 100644 --- a/src/common/legacy_config_opts.h +++ b/src/common/legacy_config_opts.h @@ -94,6 +94,8 @@ OPTION(xio_max_send_inline, OPT_INT) // xio maximum threshold to send inline OPTION(compressor_zlib_isal, OPT_BOOL) OPTION(compressor_zlib_level, OPT_INT) //regular zlib compression level, not applicable to isa-l optimized version +OPTION(qat_compressor_enabled, OPT_BOOL) + OPTION(plugin_crypto_accelerator, OPT_STR) OPTION(mempool_debug, OPT_BOOL) diff --git a/src/common/options.cc b/src/common/options.cc index e5b3d2de839f1..8ad7db20fb88c 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -776,6 +776,10 @@ std::vector