Skip to content

Commit

Permalink
os/bluestore: use global compressor if possible
Browse files Browse the repository at this point in the history
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
  • Loading branch information
xiexingguo committed Sep 3, 2016
1 parent fa2dce8 commit 1fddea4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -3998,14 +3998,19 @@ int BlueStore::_decompress(bufferlist& source, bufferlist* result)
bluestore_compression_header_t chdr;
::decode(chdr, i);
string name = bluestore_blob_t::get_comp_alg_name(chdr.type);
CompressorRef compressor = Compressor::create(cct, name);
if (!compressor.get()) {
CompressorRef cp;
if (compressor != nullptr && compressor->get_type() == name)
cp = compressor;
else
cp = Compressor::create(cct, name);

if (!cp.get()) {
// if compressor isn't available - error, because cannot return
// decompressed data?
derr << __func__ << " can't load decompressor " << chdr.type << dendl;
r = -EIO;
} else {
r = compressor->decompress(i, chdr.length, *result);
r = cp->decompress(i, chdr.length, *result);
if (r < 0) {
derr << __func__ << " decompression failed with exit code " << r << dendl;
r = -EIO;
Expand Down

0 comments on commit 1fddea4

Please sign in to comment.