Skip to content

Commit

Permalink
os/bluestore: release compressor if comp_mode turned out to be none
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 Jul 8, 2016
1 parent 11e0c7c commit 20cd3a4
Showing 1 changed file with 43 additions and 33 deletions.
76 changes: 43 additions & 33 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -1429,42 +1429,52 @@ void BlueStore::_set_compression()
comp_min_blob_size = g_conf->bluestore_compression_min_blob_size;
comp_max_blob_size = g_conf->bluestore_compression_max_blob_size;

const char *alg = 0;
if (g_conf->bluestore_compression_algorithm == "snappy") {
alg = "snappy";
} else if (g_conf->bluestore_compression_algorithm == "zlib") {
alg = "zlib";
} else if (g_conf->bluestore_compression_algorithm.length()) {
derr << __func__ << " unrecognized compression algorithm '"
<< g_conf->bluestore_compression_algorithm << "'" << dendl;
}
if (alg) {
compressor = Compressor::create(cct, alg);
if (!compressor) {
derr << __func__ << " unable to initialize " << alg << " compressor"
<< dendl;
}
CompressionMode m;

if (g_conf->bluestore_compression == "force") {
m = COMP_FORCE;
} else if (g_conf->bluestore_compression == "aggressive") {
m = COMP_AGGRESSIVE;
} else if (g_conf->bluestore_compression == "passive") {
m = COMP_PASSIVE;
} else if (g_conf->bluestore_compression == "none") {
m = COMP_NONE;
} else {
compressor = nullptr;
}
CompressionMode m = COMP_NONE;
if (compressor) {
if (g_conf->bluestore_compression == "force") {
m = COMP_FORCE;
} else if (g_conf->bluestore_compression == "aggressive") {
m = COMP_AGGRESSIVE;
} else if (g_conf->bluestore_compression == "passive") {
m = COMP_PASSIVE;
} else if (g_conf->bluestore_compression == "none") {
m = COMP_NONE;
} else {
derr << __func__ << " unrecognized value '"
<< g_conf->bluestore_compression
<< "' for bluestore_compression, reverting to 'none'" << dendl;
m = COMP_NONE;
}
derr << __func__ << " unrecognized value '"
<< g_conf->bluestore_compression
<< "' for bluestore_compression, reverting to 'none'"
<< dendl;
m = COMP_NONE;
}

comp_mode = m;
compressor = nullptr;

if (comp_mode != COMP_NONE) {
const char *alg = 0;
if (g_conf->bluestore_compression_algorithm == "snappy") {
alg = "snappy";
} else if (g_conf->bluestore_compression_algorithm == "zlib") {
alg = "zlib";
} else if (g_conf->bluestore_compression_algorithm.length()) {
derr << __func__ << " unrecognized compression algorithm '"
<< g_conf->bluestore_compression_algorithm << "'"
<< ", reverting compression mode to 'none'"
<< dendl;
comp_mode = COMP_NONE;
}

if (alg) {
compressor = Compressor::create(cct, alg);
if (!compressor) {
derr << __func__ << " unable to initialize " << alg << " compressor"
<< ", reverting compression mode to 'none'"
<< dendl;
comp_mode = COMP_NONE;
}
}
}

dout(10) << __func__ << " mode " << get_comp_mode_name(comp_mode)
<< " alg " << (compressor ? compressor->get_type() : "(none)")
<< dendl;
Expand Down

0 comments on commit 20cd3a4

Please sign in to comment.