From 5beb99e17a6fd683e83f7e7e0fd3660bfc272f0e Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Wed, 16 Nov 2016 14:33:30 +0800 Subject: [PATCH 1/2] os/bluestore: avoid unnecessary call to init_csum() We have to initiate CSumType from 1, which represents CSUM_NONE, to be aligned with OSDMnitor's pool_opts_t handling. So we have to explicitly check against CSUM_NONE to skip init_csum(), which will set FLAG_CSUM and alloc memory for csum_data and thus shall be avoided whenever it is possible. Signed-off-by: xie xingguo --- src/os/bluestore/BlueStore.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 140a8e62bd250..ca886c607595c 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7906,7 +7906,7 @@ int BlueStore::_do_alloc_write( << " csum_length 0x" << std::hex << csum_length << std::dec << dendl; - if (csum) { + if (csum != Checksummer::CSUM_NONE) { dblob.init_csum(csum, csum_order, csum_length); dblob.calc_csum(b_off, *l); } From eedb3f4b6bc1f24d0c40000c8d46ab7344edc069 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Wed, 16 Nov 2016 12:26:16 +0800 Subject: [PATCH 2/2] os/bluestore: more readability improvements Signed-off-by: xie xingguo --- src/os/bluestore/BlueStore.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index ca886c607595c..37e24107b7c99 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7524,19 +7524,16 @@ void BlueStore::_do_write_small( blp.copy(length, bl); // look for an existing mutable blob we can use - BlobRef b = 0; - boost::intrusive::set::iterator ep = - o->extent_map.seek_lextent(offset); + auto ep = o->extent_map.seek_lextent(offset); if (ep != o->extent_map.extent_map.begin()) { --ep; - b = ep->blob; - if (ep->logical_offset - ep->blob_offset + - b->get_blob().get_ondisk_length() <= offset) { + if (ep->blob_end() <= offset) { ++ep; } } + BlobRef b; while (ep != o->extent_map.extent_map.end()) { - if (ep->logical_offset >= ep->blob_offset + end) { + if (ep->blob_start() >= end) { break; } b = ep->blob; @@ -7551,7 +7548,7 @@ void BlueStore::_do_write_small( ++ep; continue; } - uint64_t bstart = ep->logical_offset - ep->blob_offset; + uint64_t bstart = ep->blob_start(); dout(20) << __func__ << " considering " << *b << " bstart 0x" << std::hex << bstart << std::dec << dendl; @@ -7992,7 +7989,7 @@ void BlueStore::_wctx_finish( } } delete &lo; - if (b->id >= 0 && b->get_ref_map().empty()) { + if (b->is_spanning() && b->get_ref_map().empty()) { dout(20) << __func__ << " spanning_blob_map removing empty " << *b << dendl; auto it = o->extent_map.spanning_blob_map.find(b->id);