From 506e4aedd4d9e72480cfe2308e920114c7c077b4 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 30 Sep 2016 14:23:32 -0400 Subject: [PATCH] os/bluestore: cosmetic gc cleanups Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 20 ++++++++++++-------- src/os/bluestore/BlueStore.h | 13 +++++++------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 7e4785ebd3115..ec19611733456 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1389,6 +1389,7 @@ ostream& operator<<(ostream& out, const BlueStore::Extent& e) { return out << std::hex << "0x" << e.logical_offset << "~" << e.length << ": 0x" << e.blob_offset << "~" << e.length << std::dec + << " depth " << (int)e.blob_depth << " " << *e.blob; } @@ -7512,7 +7513,7 @@ void BlueStore::_wctx_finish( } } -bool BlueStore::_blobs_need_garbage_collection( +bool BlueStore::_do_write_check_depth( OnodeRef o, uint64_t start_offset, uint64_t end_offset, @@ -7529,16 +7530,16 @@ bool BlueStore::_blobs_need_garbage_collection( *blob_depth = 1; auto hp = o->extent_map.seek_lextent(start_offset); - - if (hp != o->extent_map.extent_map.end() && hp->logical_offset < start_offset && + if (hp != o->extent_map.extent_map.end() && + hp->logical_offset < start_offset && start_offset < hp->logical_offset + hp->length) { depth = hp->blob_depth; head_overlap = true; } auto tp = o->extent_map.seek_lextent(end_offset); - - if (tp != o->extent_map.extent_map.end() && tp->logical_offset < end_offset && + if (tp != o->extent_map.extent_map.end() && + tp->logical_offset < end_offset && end_offset < tp->logical_offset + tp->length) { tail_overlap = true; if (depth < tp->blob_depth) { @@ -7574,6 +7575,10 @@ bool BlueStore::_blobs_need_garbage_collection( *gc_end_offset = tp->logical_offset + tp_prev->length; } } + dout(20) << __func__ << " depth " << (int)depth + << ", gc 0x" << std::hex << *gc_start_offset << "~" + << (*gc_end_offset - *gc_start_offset) + << std::dec << dendl; if (depth >= g_conf->bluestore_gc_max_blob_depth) { return true; } else { @@ -7688,9 +7693,8 @@ int BlueStore::_do_write( << std::dec << dendl; uint64_t gc_start_offset = offset, gc_end_offset = end; - - if (_blobs_need_garbage_collection(o, offset, end, &wctx.blob_depth, - &gc_start_offset, &gc_end_offset) == true) { + if (_do_write_check_depth(o, offset, end, &wctx.blob_depth, + &gc_start_offset, &gc_end_offset)) { // we need garbage collection of blobs. if (offset > gc_start_offset) { bufferlist head_bl; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 16b59ed12ff69..04831ab78604a 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1782,12 +1782,13 @@ private: void _pad_zeros(bufferlist *bl, uint64_t *offset, uint64_t chunk_size); - bool _blobs_need_garbage_collection(OnodeRef o, - uint64_t start_offset, - uint64_t end_offset, - uint8_t *blob_depth, - uint64_t *gc_start_offset, - uint64_t *gc_end_offset); + bool _do_write_check_depth( + OnodeRef o, + uint64_t start_offset, + uint64_t end_offset, + uint8_t *blob_depth, + uint64_t *gc_start_offset, + uint64_t *gc_end_offset); int _do_write(TransContext *txc, CollectionRef &c, -- 2.39.5