]> git.proxmox.com Git - ceph.git/blame - ceph/src/compressor/zlib/CompressionPluginZlib.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / compressor / zlib / CompressionPluginZlib.h
CommitLineData
7c673cae
FG
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"
7c673cae
FG
22#include "compressor/CompressionPlugin.h"
23#include "ZlibCompressor.h"
24
25// -----------------------------------------------------------------------------
26
27class CompressionPluginZlib : public CompressionPlugin {
28public:
29 bool has_isal = false;
30
31 explicit CompressionPluginZlib(CephContext *cct) : CompressionPlugin(cct)
32 {}
33
34 int factory(CompressorRef *cs,
35 std::ostream *ss) override
36 {
37 bool isal = false;
38#if defined(__i386__) || defined(__x86_64__)
39 // other arches or lack of support result in isal = false
40 if (cct->_conf->compressor_zlib_isal) {
41 ceph_arch_probe();
42 isal = (ceph_arch_intel_pclmul && ceph_arch_intel_sse41);
43 }
44#endif
45 if (compressor == 0 || has_isal != isal) {
224ce89b 46 compressor = std::make_shared<ZlibCompressor>(cct, isal);
7c673cae
FG
47 has_isal = isal;
48 }
49 *cs = compressor;
50 return 0;
51 }
52};
53
54#endif