From: xie xingguo Date: Tue, 8 Nov 2016 08:54:04 +0000 (+0800) Subject: os/bluestore: move selectiong of csum/crr out of for loop X-Git-Tag: v11.1.0~367^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F11823%2Fhead;p=ceph.git os/bluestore: move selectiong of csum/crr out of for loop 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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index f7142ab252f5..44fee7368885 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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(val); + } + return boost::optional(); + } + ); + + // 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(val); + } + return boost::optional(); + } + ); + 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(val); - } - return boost::optional(); - } - ); 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(val); - } - return boost::optional(); - } - ); - dout(20) << __func__ << " blob " << *b << " csum_type " << Checksummer::get_csum_type_string(csum) << " csum_order " << csum_order