zlib: remove g_ceph_context/g_conf from compressor plugin

Signed-off-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
Casey Bodley 2017-07-10 13:20:08 -04:00
parent c7e869c431
commit ec188a9dad
3 changed files with 6 additions and 4 deletions

View File

@ -44,7 +44,7 @@ public:
}
#endif
if (compressor == 0 || has_isal != isal) {
compressor = std::make_shared<ZlibCompressor>(isal);
compressor = std::make_shared<ZlibCompressor>(cct, isal);
has_isal = isal;
}
*cs = compressor;

View File

@ -22,7 +22,7 @@
#include <zlib.h>
// -----------------------------------------------------------------------------
#define dout_context g_ceph_context
#define dout_context cct
#define dout_subsys ceph_subsys_compressor
#undef dout_prefix
#define dout_prefix _prefix(_dout)
@ -59,7 +59,7 @@ int ZlibCompressor::zlib_compress(const bufferlist &in, bufferlist &out)
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit2(&strm, g_conf->compressor_zlib_level, Z_DEFLATED, ZLIB_DEFAULT_WIN_SIZE, ZLIB_MEMORY_LEVEL, Z_DEFAULT_STRATEGY);
ret = deflateInit2(&strm, cct->_conf->compressor_zlib_level, Z_DEFLATED, ZLIB_DEFAULT_WIN_SIZE, ZLIB_MEMORY_LEVEL, Z_DEFAULT_STRATEGY);
if (ret != Z_OK) {
dout(1) << "Compression init error: init return "
<< ret << " instead of Z_OK" << dendl;

View File

@ -21,8 +21,10 @@
class ZlibCompressor : public Compressor {
bool isal_enabled;
CephContext *const cct;
public:
ZlibCompressor(bool isal) : Compressor(COMP_ALG_ZLIB, "zlib"), isal_enabled(isal) {}
ZlibCompressor(CephContext *cct, bool isal)
: Compressor(COMP_ALG_ZLIB, "zlib"), isal_enabled(isal), cct(cct) {}
int compress(const bufferlist &in, bufferlist &out) override;
int decompress(const bufferlist &in, bufferlist &out) override;