make sure we take the metadata bitmaps into account for the reference counting

This commit is contained in:
Joe Thornber 2011-08-25 16:10:03 +01:00
parent fce7e99d9a
commit 550b8ca35a
3 changed files with 12 additions and 2 deletions

View File

@ -375,6 +375,7 @@ metadata::check()
throw runtime_error(out.str());
}
metadata_sm_->check(metadata_counter);
data_sm_->check(metadata_counter);
errors->add_child(check_ref_counts("Errors in metadata block reference counts",
metadata_counter, metadata_sm_));

View File

@ -192,7 +192,7 @@ namespace thin_provisioning {
tm_ptr tm_;
superblock sb_;
space_map::ptr metadata_sm_;
sm_disk_detail::sm_metadata<MD_BLOCK_SIZE>::ptr metadata_sm_;
sm_disk_detail::sm_disk<MD_BLOCK_SIZE>::ptr data_sm_;
detail_tree details_;
dev_tree mappings_top_level_;

View File

@ -407,6 +407,13 @@ namespace persistent_data {
::memcpy(dest, &d, sizeof(d));
}
void check(block_counter &counter) {
counter.inc(bitmap_root_);
for (unsigned i = 0; i < entries_.size(); i++)
counter.inc(entries_[i].blocknr_);
}
private:
index_entry find_ie(block_address ie_index) const {
return entries_[ie_index];
@ -422,7 +429,9 @@ namespace persistent_data {
metadata_index const *mdi = reinterpret_cast<metadata_index const *>(&rr.data());
for (unsigned i = 0; i < MAX_METADATA_BITMAPS; i++)
unsigned nr_indexes = div_up<block_address>(sm_disk_base<BlockSize>::get_nr_blocks(),
sm_disk_base<BlockSize>::get_entries_per_block());
for (unsigned i = 0; i < nr_indexes; i++)
index_entry_traits::unpack(*(mdi->index + i), entries_[i]);
}