From db81cf379872b39af13a56ccb6ee321b606e78d7 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Tue, 15 Nov 2016 13:59:56 +0800 Subject: [PATCH] os/bluestore: dedup if space overlap truly exists Signed-off-by: xie xingguo --- src/os/bluestore/BlueStore.cc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 76fe88a4d0c..b56201f078b 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -6616,22 +6616,24 @@ void BlueStore::_txc_finalize_kv(TransContext *txc, KeyValueDB::Transaction t) // same region in this transaction. The freelist doesn't like that. // (Actually, the only thing that cares is the BitmapFreelistManager // debug check. But that's important.) - interval_set overlap; interval_set tmp_allocated, tmp_released; interval_set *pallocated = &txc->allocated; interval_set *preleased = &txc->released; if (!txc->allocated.empty() && !txc->released.empty()) { + interval_set overlap; overlap.intersection_of(txc->allocated, txc->released); - tmp_allocated = txc->allocated; - tmp_allocated.subtract(overlap); - tmp_released = txc->released; - tmp_released.subtract(overlap); - dout(20) << __func__ << " overlap 0x" << std::hex << overlap - << ", new allocated 0x" << tmp_allocated - << " released 0x" << tmp_released << std::dec - << dendl; - pallocated = &tmp_allocated; - preleased = &tmp_released; + if (!overlap.empty()) { + tmp_allocated = txc->allocated; + tmp_allocated.subtract(overlap); + tmp_released = txc->released; + tmp_released.subtract(overlap); + dout(20) << __func__ << " overlap 0x" << std::hex << overlap + << ", new allocated 0x" << tmp_allocated + << " released 0x" << tmp_released << std::dec + << dendl; + pallocated = &tmp_allocated; + preleased = &tmp_released; + } } // update freelist with non-overlap sets -- 2.47.3