]> git.proxmox.com Git - ceph.git/blob - ceph/src/compressor/zlib/CompressionPluginZlib.h
0aa641f8bb66b689cbc1326fd1b51c5a7d399c6a
[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/config.h"
23 #include "compressor/CompressionPlugin.h"
24 #include "ZlibCompressor.h"
25
26 // -----------------------------------------------------------------------------
27
28 class CompressionPluginZlib : public 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 #endif
46 if (compressor == 0 || has_isal != isal) {
47 compressor = std::make_shared<ZlibCompressor>(isal);
48 has_isal = isal;
49 }
50 *cs = compressor;
51 return 0;
52 }
53 };
54
55 #endif