From be22981a7d9dd87e24fe6faa8eec5430c0dab54d Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Tue, 8 Oct 2013 11:00:05 +0100 Subject: [PATCH] [ache_check] hint array damage reporting --- caching/cache_check.cc | 28 ++++++++++++++++++++++------ caching/hint_array.cc | 2 +- caching/hint_array.h | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/caching/cache_check.cc b/caching/cache_check.cc index b660e01..304037b 100644 --- a/caching/cache_check.cc +++ b/caching/cache_check.cc @@ -94,7 +94,7 @@ namespace { } virtual void visit(mapping_array_damage::missing_mappings const &d) { - out() << "missing mappings:" << end_message(); + out() << "missing mappings " << d.keys_ << ":" << end_message(); { nested_output::nest _ = push(); out() << d.get_desc() << end_message(); @@ -116,13 +116,27 @@ namespace { mplus_error(FATAL); } + + using reporter_base::get_error; }; - class hint_reporter : public reporter_base { + class hint_reporter : public hint_array_damage::damage_visitor, reporter_base { public: hint_reporter(nested_output &o) : reporter_base(o) { } + + virtual void visit(hint_array_damage::missing_hints const &d) { + out() << "missing mappings " << d.keys_ << ":" << end_message(); + { + nested_output::nest _ = push(); + out() << d.get_desc() << end_message(); + } + + mplus_error(FATAL); + } + + using reporter_base::get_error; }; //-------------------------------- @@ -167,8 +181,6 @@ namespace { } error_state metadata_check(block_manager<>::ptr bm, flags const &fs) { - error_state err = NO_ERROR; - nested_output out(cerr, 2); if (fs.quiet_) out.disable(); @@ -194,7 +206,7 @@ namespace { { nested_output::nest _ = out.push(); mapping_array ma(tm, mapping_array::ref_counter(), sb.mapping_root, sb.cache_blocks); - // check_mapping_array(ma, mapping_rep); + check_mapping_array(ma, mapping_rep); } } @@ -202,10 +214,14 @@ namespace { out << "examining hint array" << end_message(); { nested_output::nest _ = out.push(); + hint_array ha(tm, sb.policy_hint_size, sb.hint_root, sb.cache_blocks); + ha.check(hint_rep); } } - return err; + return combine_errors(sb_rep.get_error(), + combine_errors(mapping_rep.get_error(), + hint_rep.get_error())); } int check(string const &path, flags const &fs) { diff --git a/caching/hint_array.cc b/caching/hint_array.cc index 0b95e48..effbd08 100644 --- a/caching/hint_array.cc +++ b/caching/hint_array.cc @@ -257,7 +257,7 @@ hint_array::grow(unsigned new_nr_entries, vector const &value) } void -hint_array::check_hint_array(hint_array_damage::damage_visitor &visitor) +hint_array::check(hint_array_damage::damage_visitor &visitor) { check_hints_(width_, impl_, visitor); } diff --git a/caching/hint_array.h b/caching/hint_array.h index e8483ac..fc9194e 100644 --- a/caching/hint_array.h +++ b/caching/hint_array.h @@ -65,7 +65,7 @@ namespace caching { void set_hint(unsigned index, vector const &data); void grow(unsigned new_nr_entries, vector const &value); - void check_hint_array(hint_array_damage::damage_visitor &visitor); + void check(hint_array_damage::damage_visitor &visitor); private: unsigned width_;