]> git.proxmox.com Git - ceph.git/blob - ceph/src/compressor/zlib/CompressionPluginZlib.h
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / compressor / zlib / CompressionPluginZlib.h
1 /*
2 * Ceph - scalable distributed file system
3 *
4 * Copyright (C) 2015 Mirantis, Inc.
5 *
6 * Author: Alyona Kiseleva <akiselyova@mirantis.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 */
14
15 #ifndef CEPH_COMPRESSION_PLUGIN_ZLIB_H
16 #define CEPH_COMPRESSION_PLUGIN_ZLIB_H
17
18 // -----------------------------------------------------------------------------
19 #include "arch/probe.h"
20 #include "arch/intel.h"
21 #include "arch/arm.h"
22 #include "common/ceph_context.h"
23 #include "compressor/CompressionPlugin.h"
24 #include "ZlibCompressor.h"
25
26 // -----------------------------------------------------------------------------
27
28 class CompressionPluginZlib : public ceph::CompressionPlugin {
29 public:
30 bool has_isal = false;
31
32 explicit CompressionPluginZlib(CephContext *cct) : CompressionPlugin(cct)
33 {}
34
35 int factory(CompressorRef *cs,
36 std::ostream *ss) override
37 {
38 bool isal = false;
39 #if defined(__i386__) || defined(__x86_64__)
40 // other arches or lack of support result in isal = false
41 if (cct->_conf->compressor_zlib_isal) {
42 ceph_arch_probe();
43 isal = (ceph_arch_intel_pclmul && ceph_arch_intel_sse41);
44 }
45 #elif defined(__aarch64__)
46 if (cct->_conf->compressor_zlib_isal) {
47 ceph_arch_probe();
48 isal = (ceph_arch_aarch64_pmull && ceph_arch_neon);
49 }
50 #endif
51 if (compressor == 0 || has_isal != isal) {
52 compressor = std::make_shared<ZlibCompressor>(cct, isal);
53 has_isal = isal;
54 }
55 *cs = compressor;
56 return 0;
57 }
58 };
59
60 #endif