improve reference count tracking
This commit is contained in:
parent
52f03b7542
commit
fce7e99d9a
@ -76,20 +76,24 @@ namespace persistent_data {
|
||||
|
||||
void visit_internal(unsigned level, bool is_root,
|
||||
btree_detail::node_ref<uint64_traits, BlockSize> const &n) {
|
||||
counter_.inc(n.get_location());
|
||||
check_duplicate_block(n.get_location());
|
||||
check_block_nr(n);
|
||||
check_max_entries(n);
|
||||
check_nr_entries(n, is_root);
|
||||
|
||||
for (unsigned i = 0; i < n.get_nr_entries(); i++)
|
||||
counter_.inc(n.value_at(i));
|
||||
}
|
||||
|
||||
void visit_internal_leaf(unsigned level, bool is_root,
|
||||
btree_detail::node_ref<uint64_traits, BlockSize> const &n) {
|
||||
counter_.inc(n.get_location());
|
||||
check_duplicate_block(n.get_location());
|
||||
check_block_nr(n);
|
||||
check_max_entries(n);
|
||||
check_nr_entries(n, is_root);
|
||||
|
||||
for (unsigned i = 0; i < n.get_nr_entries(); i++)
|
||||
counter_.inc(n.value_at(i));
|
||||
}
|
||||
|
||||
void visit_leaf(unsigned level, bool is_root,
|
||||
|
18
metadata.cc
18
metadata.cc
@ -328,22 +328,20 @@ metadata::device_exists(thin_dev_t dev) const
|
||||
}
|
||||
|
||||
namespace {
|
||||
// FIXME: this doesn't check for non-zero counts in the sm that are
|
||||
// actually zero.
|
||||
optional<error_set::ptr>
|
||||
check_ref_counts(string const &desc, block_counter const &actual,
|
||||
check_ref_counts(string const &desc, block_counter const &counts,
|
||||
space_map::ptr sm) {
|
||||
error_set::ptr errors(new error_set(desc));
|
||||
|
||||
bool bad = false;
|
||||
block_counter::count_map const &counts = actual.get_counts();
|
||||
block_counter::count_map::const_iterator it, end = counts.end();
|
||||
for (it = counts.begin(); it != end; ++it) {
|
||||
uint32_t ref_count = sm->get_count(it->first);
|
||||
if (ref_count != it->second) {
|
||||
for (block_address b = 0; b < sm->get_nr_blocks(); b++) {
|
||||
uint32_t actual = sm->get_count(b);
|
||||
uint32_t expected = counts.get_count(b);
|
||||
|
||||
if (actual != expected) {
|
||||
ostringstream out;
|
||||
out << it->first << ": was " << ref_count
|
||||
<< ", expected " << it->second;
|
||||
out << b << ": was " << actual
|
||||
<< ", expected " << expected;
|
||||
errors->add_child(out.str());
|
||||
bad = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user