From 8006e1817388b55489cbdff222015505a379d347 Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Mon, 22 Jun 2020 15:01:25 +0800 Subject: [PATCH] [thin_pool] Fix the number of mapped blocks --- thin-provisioning/thin_pool.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/thin-provisioning/thin_pool.cc b/thin-provisioning/thin_pool.cc index 3bdc9e7..3a34ba8 100644 --- a/thin-provisioning/thin_pool.cc +++ b/thin-provisioning/thin_pool.cc @@ -72,13 +72,16 @@ thin::insert(block_address thin_block, block_address data_block) { uint64_t key[2] = {dev_, thin_block}; - ++details_.mapped_blocks_; - changed_ = true; - mapping_tree_detail::block_time bt; bt.block_ = data_block; bt.time_ = pool_.get_time(); - return pool_.md_->mappings_->insert(key, bt); + bool inserted = pool_.md_->mappings_->insert(key, bt); + + changed_ = true; + if (inserted) + ++details_.mapped_blocks_; + + return inserted; } void