From a00b6c30dbc80b9a03c8c6eccf065d60a1a1a938 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Tue, 6 Jun 2017 10:38:57 +0800 Subject: [PATCH] os/bluestore: reduce overhead when trying to unshard blobs Signed-off-by: xie xingguo --- src/os/bluestore/BlueStore.cc | 39 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index b6d5573adf8..49f958208a5 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -10209,26 +10209,27 @@ int BlueStore::_do_remove( } } - uint32_t b_start = OBJECT_MAX_SIZE; - uint32_t b_end = 0; - for (auto& e : h->extent_map.extent_map) { - const bluestore_blob_t& b = e.blob->get_blob(); - SharedBlob *sb = e.blob->shared_blob.get(); - if (b.is_shared() && - std::find(unshared_blobs.begin(), unshared_blobs.end(), - sb) != unshared_blobs.end()) { - dout(20) << __func__ << " unsharing " << *e.blob << dendl; - bluestore_blob_t& blob = e.blob->dirty_blob(); - blob.clear_flag(bluestore_blob_t::FLAG_SHARED); - if (e.logical_offset < b_start) { - b_start = e.logical_offset; - } - if (e.logical_end() > b_end) { - b_end = e.logical_end(); - } - } - } if (!unshared_blobs.empty()) { + uint32_t b_start = OBJECT_MAX_SIZE; + uint32_t b_end = 0; + for (auto& e : h->extent_map.extent_map) { + const bluestore_blob_t& b = e.blob->get_blob(); + SharedBlob *sb = e.blob->shared_blob.get(); + if (b.is_shared() && + std::find(unshared_blobs.begin(), unshared_blobs.end(), + sb) != unshared_blobs.end()) { + dout(20) << __func__ << " unsharing " << *e.blob << dendl; + bluestore_blob_t& blob = e.blob->dirty_blob(); + blob.clear_flag(bluestore_blob_t::FLAG_SHARED); + if (e.logical_offset < b_start) { + b_start = e.logical_offset; + } + if (e.logical_end() > b_end) { + b_end = e.logical_end(); + } + } + } + h->extent_map.dirty_range(b_start, b_end); txc->write_onode(h); } -- 2.39.5