From 5d28c05dc324227967b902ae8ccb18e781b35487 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 4 Aug 2015 15:14:02 +0100 Subject: [PATCH] [thin_check] detail and mapping trees weren't being counted properly for the metadata snap. This could result in block counts being unexpectedly non zero. --- thin-provisioning/thin_check.cc | 39 +++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/thin-provisioning/thin_check.cc b/thin-provisioning/thin_check.cc index 9e46af4..f14ee37 100644 --- a/thin-provisioning/thin_check.cc +++ b/thin-provisioning/thin_check.cc @@ -169,23 +169,9 @@ namespace { bool clear_needs_check_flag_on_success; }; - error_state check_space_map_counts(flags const &fs, nested_output &out, - superblock_detail::superblock &sb, - block_manager<>::ptr bm, - transaction_manager::ptr tm) { - block_counter bc; - - // Count the superblock - bc.inc(superblock_detail::SUPERBLOCK_LOCATION); - - // Count the metadata snap, if present - if (sb.metadata_snap_ != superblock_detail::SUPERBLOCK_LOCATION) { - bc.inc(sb.metadata_snap_); - - superblock_detail::superblock snap = read_superblock(bm, sb.metadata_snap_); - bc.inc(snap.data_mapping_root_); - bc.inc(snap.device_details_root_); - } + void count_trees(transaction_manager::ptr tm, + superblock_detail::superblock &sb, + block_counter &bc) { // Count the device tree { @@ -202,6 +188,25 @@ namespace { mapping_tree_detail::block_traits::ref_counter(tm->get_sm())); count_btree_blocks(mtree, bc, vc); } + } + + error_state check_space_map_counts(flags const &fs, nested_output &out, + superblock_detail::superblock &sb, + block_manager<>::ptr bm, + transaction_manager::ptr tm) { + block_counter bc; + + // Count the superblock + bc.inc(superblock_detail::SUPERBLOCK_LOCATION); + count_trees(tm, sb, bc); + + // Count the metadata snap, if present + if (sb.metadata_snap_ != superblock_detail::SUPERBLOCK_LOCATION) { + bc.inc(sb.metadata_snap_); + + superblock_detail::superblock snap = read_superblock(bm, sb.metadata_snap_); + count_trees(tm, snap, bc); + } // Count the metadata space map {