From 6863db6f8682995f2d50458d7ec9dd22d52166e4 Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Wed, 10 Aug 2016 23:40:48 +0800 Subject: [PATCH] [thin] fix duplicated counting of mapped blocks in restore emitter --- persistent-data/data-structures/btree.h | 2 +- persistent-data/data-structures/btree.tcc | 4 +++- thin-provisioning/restore_emitter.cc | 5 ++--- thin-provisioning/thin_pool.cc | 2 +- thin-provisioning/thin_pool.h | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/persistent-data/data-structures/btree.h b/persistent-data/data-structures/btree.h index b91fb20..9e85a36 100644 --- a/persistent-data/data-structures/btree.h +++ b/persistent-data/data-structures/btree.h @@ -322,7 +322,7 @@ namespace persistent_data { maybe_pair lookup_le(key const &key) const; maybe_pair lookup_ge(key const &key) const; - void insert(key const &key, typename ValueTraits::value_type const &value); + bool insert(key const &key, typename ValueTraits::value_type const &value); void remove(key const &key); void set_root(block_address root); diff --git a/persistent-data/data-structures/btree.tcc b/persistent-data/data-structures/btree.tcc index 3fc96e4..ce49a30 100644 --- a/persistent-data/data-structures/btree.tcc +++ b/persistent-data/data-structures/btree.tcc @@ -498,7 +498,7 @@ namespace persistent_data { } template - void + bool btree:: insert(key const &key, typename ValueTraits::value_type const &value) @@ -531,6 +531,8 @@ namespace persistent_data { n.set_value(index, value); root_ = spine.get_root(); + + return need_insert; } template diff --git a/thin-provisioning/restore_emitter.cc b/thin-provisioning/restore_emitter.cc index c16eb70..46b7f92 100644 --- a/thin-provisioning/restore_emitter.cc +++ b/thin-provisioning/restore_emitter.cc @@ -136,10 +136,9 @@ namespace { mapping_tree_detail::block_time bt; bt.block_ = data_block; bt.time_ = time; - current_mapping_->insert(key, bt); + current_device_details_.mapped_blocks_ += + static_cast(current_mapping_->insert(key, bt)); md_->data_sm_->inc(data_block); - - current_device_details_.mapped_blocks_ += 1; } private: diff --git a/thin-provisioning/thin_pool.cc b/thin-provisioning/thin_pool.cc index 1abaa57..d133711 100644 --- a/thin-provisioning/thin_pool.cc +++ b/thin-provisioning/thin_pool.cc @@ -50,7 +50,7 @@ thin::lookup(block_address thin_block) return pool_->md_->mappings_->lookup(key); } -void +bool thin::insert(block_address thin_block, block_address data_block) { uint64_t key[2] = {dev_, thin_block}; diff --git a/thin-provisioning/thin_pool.h b/thin-provisioning/thin_pool.h index 66ae307..0c6b156 100644 --- a/thin-provisioning/thin_pool.h +++ b/thin-provisioning/thin_pool.h @@ -39,7 +39,7 @@ namespace thin_provisioning { thin_dev_t get_dev_t() const; maybe_address lookup(block_address thin_block); - void insert(block_address thin_block, block_address data_block); + bool insert(block_address thin_block, block_address data_block); void remove(block_address thin_block); void set_snapshot_time(uint32_t time);