]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: move selectiong of csum/crr out of for loop 11823/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 8 Nov 2016 08:54:04 +0000 (16:54 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 9 Nov 2016 00:27:55 +0000 (08:27 +0800)
We don't have to trace the csum/compression_required_ration option changing
at such a small granularity, which costs too much.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index f7142ab252f52f6d75ed1c3d1e7745cc9b32c9dd..44fee736888589ae2e861053d3f9499f9449da21 100644 (file)
@@ -7785,6 +7785,32 @@ int BlueStore::_do_alloc_write(
     });
   }
 
+  auto crr = select_option(
+    "compression_required_ratio",
+    g_conf->bluestore_compression_required_ratio,
+    [&]() {
+      double val;
+      if(coll->pool_opts.get(pool_opts_t::COMPRESSION_REQUIRED_RATIO, &val)) {
+        return boost::optional<double>(val);
+      }
+      return boost::optional<double>();
+    }
+  );
+
+  // checksum
+  int csum = csum_type.load();
+  csum = select_option(
+    "csum_type",
+    csum,
+    [&]() {
+      int val;
+      if(coll->pool_opts.get(pool_opts_t::CSUM_TYPE, &val)) {
+        return  boost::optional<int>(val);
+      }
+      return boost::optional<int>();
+    }
+  );
+
   for (auto& wi : wctx->writes) {
     BlobRef b = wi.b;
     bluestore_blob_t& dblob = b->dirty_blob();
@@ -7815,18 +7841,6 @@ int BlueStore::_do_alloc_write(
       compressed_bl.claim_append(t);
       uint64_t rawlen = compressed_bl.length();
       uint64_t newlen = P2ROUNDUP(rawlen, min_alloc_size);
-
-      auto crr = select_option(
-       "compression_required_ratio",
-       g_conf->bluestore_compression_required_ratio,
-       [&]() {
-         double val;
-         if(coll->pool_opts.get(pool_opts_t::COMPRESSION_REQUIRED_RATIO, &val)) {
-           return boost::optional<double>(val);
-         }
-         return boost::optional<double>();
-       }
-      );
       uint64_t want_len_raw = final_length * crr;
       uint64_t want_len = P2ROUNDUP(want_len_raw, min_alloc_size);
       if (newlen <= want_len && newlen < final_length) {
@@ -7892,20 +7906,6 @@ int BlueStore::_do_alloc_write(
       dblob.extents.push_back(e);
     }
 
-    // checksum
-    int csum = csum_type.load();
-    csum = select_option(
-      "csum_type",
-      csum, 
-      [&]() {
-        int val;
-        if(coll->pool_opts.get(pool_opts_t::CSUM_TYPE, &val)) {
-         return  boost::optional<int>(val);
-        }
-        return boost::optional<int>();
-      }
-    );
-
     dout(20) << __func__ << " blob " << *b
             << " csum_type " << Checksummer::get_csum_type_string(csum)
             << " csum_order " << csum_order