]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: release compressor if comp_mode turned out to be none 10201/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 8 Jul 2016 07:21:57 +0000 (15:21 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 8 Jul 2016 12:44:42 +0000 (20:44 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index 978a020fea74e72576eeddfd63bcb69b40d8aa99..c2fa342e3bea76071b167949a8eec6df812b69c6 100644 (file)
@@ -1429,42 +1429,48 @@ 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;
-    }
+  if (g_conf->bluestore_compression == "force") {
+    comp_mode = COMP_FORCE;
+  } else if (g_conf->bluestore_compression == "aggressive") {
+    comp_mode = COMP_AGGRESSIVE;
+  } else if (g_conf->bluestore_compression == "passive") {
+    comp_mode = COMP_PASSIVE;
+  } else if (g_conf->bluestore_compression == "none") {
+    comp_mode = 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;
+    comp_mode = COMP_NONE;
+  }
+
+  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;
+      }
     }
   }
-  comp_mode = m;
   dout(10) << __func__ << " mode " << get_comp_mode_name(comp_mode)
           << " alg " << (compressor ? compressor->get_type() : "(none)")
           << dendl;