Blame SOURCES/dmpd-thin_check-Under-populated-nodes-are-now-non-fatal.patch

944f5b
 .../data-structures/btree_damage_visitor.h         | 22 +++++++++++-----
944f5b
 thin-provisioning/device_tree.cc                   | 11 +++++---
944f5b
 thin-provisioning/device_tree.h                    |  6 +++--
944f5b
 thin-provisioning/mapping_tree.cc                  | 30 +++++++++++++---------
944f5b
 thin-provisioning/mapping_tree.h                   | 25 ++++++++++++------
944f5b
 thin-provisioning/metadata_dumper.cc               | 16 ++++++------
944f5b
 thin-provisioning/thin_check.cc                    |  6 ++---
944f5b
 7 files changed, 73 insertions(+), 43 deletions(-)
944f5b
944f5b
diff --git a/persistent-data/data-structures/btree_damage_visitor.h b/persistent-data/data-structures/btree_damage_visitor.h
944f5b
index 1ff16a8..60e25d9 100644
944f5b
--- a/persistent-data/data-structures/btree_damage_visitor.h
944f5b
+++ b/persistent-data/data-structures/btree_damage_visitor.h
944f5b
@@ -159,10 +159,12 @@ namespace persistent_data {
944f5b
 			typedef boost::optional<run64> maybe_run64;
944f5b
 
944f5b
 			btree_damage_visitor(ValueVisitor &value_visitor,
944f5b
-					     DamageVisitor &damage_visitor)
944f5b
+					     DamageVisitor &damage_visitor,
944f5b
+                                             bool ignore_non_fatal)
944f5b
 				: avoid_repeated_visits_(true),
944f5b
 				  value_visitor_(value_visitor),
944f5b
-				  damage_visitor_(damage_visitor) {
944f5b
+				  damage_visitor_(damage_visitor),
944f5b
+				  ignore_non_fatal_(ignore_non_fatal) {
944f5b
 			}
944f5b
 
944f5b
 			bool visit_internal(node_location const &loc,
944f5b
@@ -231,7 +233,7 @@ namespace persistent_data {
944f5b
 				else if (!checker_.check_block_nr(n) ||
944f5b
 					 !checker_.check_value_size(n) ||
944f5b
 					 !checker_.check_max_entries(n) ||
944f5b
-					 !checker_.check_nr_entries(n, loc.is_sub_root()) ||
944f5b
+                                         !check_nr_entries(loc, n) ||
944f5b
 					 !checker_.check_ordered_keys(n) ||
944f5b
 					 !checker_.check_parent_key(n, loc.is_sub_root() ? boost::optional<uint64_t>() : loc.key)) {
944f5b
 					report_damage(checker_.get_last_error_string());
944f5b
@@ -255,7 +257,7 @@ namespace persistent_data {
944f5b
 				else if (!checker_.check_block_nr(n) ||
944f5b
 					 !checker_.check_value_size(n) ||
944f5b
 					 !checker_.check_max_entries(n) ||
944f5b
-					 !checker_.check_nr_entries(n, loc.is_sub_root()) ||
944f5b
+					 !check_nr_entries(loc, n) ||
944f5b
 					 !checker_.check_ordered_keys(n) ||
944f5b
 					 !checker_.check_parent_key(n, loc.is_sub_root() ? boost::optional<uint64_t>() : loc.key) ||
944f5b
 					 !checker_.check_leaf_key(n, last_leaf_key_[loc.level()])) {
944f5b
@@ -353,6 +355,12 @@ namespace persistent_data {
944f5b
 					maybe_issue_damage(*old_path);
944f5b
 			}
944f5b
 
944f5b
+			template <typename ValueTraits2>
944f5b
+			bool check_nr_entries(node_location const &loc,
944f5b
+					      btree_detail::node_ref<ValueTraits2> const &n) {
944f5b
+				return ignore_non_fatal_ || checker_.check_nr_entries(n, loc.is_sub_root());
944f5b
+			}
944f5b
+
944f5b
 			//--------------------------------
944f5b
 
944f5b
 			bool avoid_repeated_visits_;
944f5b
@@ -367,15 +375,17 @@ namespace persistent_data {
944f5b
 			path_tracker path_tracker_;
944f5b
 			damage_tracker dt_;
944f5b
 			std::list<std::string> damage_reasons_;
944f5b
+			bool ignore_non_fatal_;
944f5b
 		};
944f5b
 	}
944f5b
 
944f5b
 	template <unsigned Levels, typename ValueTraits, typename ValueVisitor, typename DamageVisitor>
944f5b
 	void btree_visit_values(btree<Levels, ValueTraits> const &tree,
944f5b
 				ValueVisitor &value_visitor,
944f5b
-				DamageVisitor &damage_visitor) {
944f5b
+				DamageVisitor &damage_visitor,
944f5b
+                                bool ignore_non_fatal = false) {
944f5b
 		btree_detail::btree_damage_visitor<ValueVisitor, DamageVisitor, Levels, ValueTraits>
944f5b
-			v(value_visitor, damage_visitor);
944f5b
+			v(value_visitor, damage_visitor, ignore_non_fatal);
944f5b
 		tree.visit_depth_first(v);
944f5b
 	}
944f5b
 }
944f5b
diff --git a/thin-provisioning/device_tree.cc b/thin-provisioning/device_tree.cc
944f5b
index 4837cb7..8ae16f7 100644
944f5b
--- a/thin-provisioning/device_tree.cc
944f5b
+++ b/thin-provisioning/device_tree.cc
944f5b
@@ -89,18 +89,21 @@ namespace thin_provisioning {
944f5b
 void
944f5b
 thin_provisioning::walk_device_tree(device_tree const &tree,
944f5b
 				    device_tree_detail::device_visitor &vv,
944f5b
-				    device_tree_detail::damage_visitor &dv)
944f5b
+				    device_tree_detail::damage_visitor &dv,
944f5b
+                                    bool ignore_non_fatal)
944f5b
 {
944f5b
 	visitor_adapter av(vv);
944f5b
 	ll_damage_visitor ll_dv(dv);
944f5b
-	btree_visit_values(tree, av, ll_dv);
944f5b
+	btree_visit_values(tree, av, ll_dv, ignore_non_fatal);
944f5b
 }
944f5b
 
944f5b
 void
944f5b
-thin_provisioning::check_device_tree(device_tree const &tree, damage_visitor &visitor)
944f5b
+thin_provisioning::check_device_tree(device_tree const &tree,
944f5b
+                                     damage_visitor &visitor,
944f5b
+                                     bool ignore_non_fatal)
944f5b
 {
944f5b
 	noop_visitor vv;
944f5b
-	walk_device_tree(tree, vv, visitor);
944f5b
+	walk_device_tree(tree, vv, visitor, ignore_non_fatal);
944f5b
 }
944f5b
 
944f5b
 //----------------------------------------------------------------
944f5b
diff --git a/thin-provisioning/device_tree.h b/thin-provisioning/device_tree.h
944f5b
index ec0f9f2..980f1a9 100644
944f5b
--- a/thin-provisioning/device_tree.h
944f5b
+++ b/thin-provisioning/device_tree.h
944f5b
@@ -74,9 +74,11 @@ namespace thin_provisioning {
944f5b
 
944f5b
 	void walk_device_tree(device_tree const &tree,
944f5b
 			      device_tree_detail::device_visitor &dev_v,
944f5b
-			      device_tree_detail::damage_visitor &dv;;
944f5b
+			      device_tree_detail::damage_visitor &dv,
944f5b
+                              bool ignore_non_fatal = false);
944f5b
 	void check_device_tree(device_tree const &tree,
944f5b
-			       device_tree_detail::damage_visitor &visitor);
944f5b
+			       device_tree_detail::damage_visitor &visitor,
944f5b
+                               bool ignore_non_fatal = false);
944f5b
 }
944f5b
 
944f5b
 //----------------------------------------------------------------
944f5b
diff --git a/thin-provisioning/mapping_tree.cc b/thin-provisioning/mapping_tree.cc
944f5b
index 5b69fe9..6c82095 100644
944f5b
--- a/thin-provisioning/mapping_tree.cc
944f5b
+++ b/thin-provisioning/mapping_tree.cc
944f5b
@@ -220,54 +220,60 @@ namespace {
944f5b
 void
944f5b
 thin_provisioning::walk_mapping_tree(dev_tree const &tree,
944f5b
 				     mapping_tree_detail::device_visitor &dev_v,
944f5b
-				     mapping_tree_detail::damage_visitor &dv)
944f5b
+				     mapping_tree_detail::damage_visitor &dv,
944f5b
+                                     bool ignore_non_fatal)
944f5b
 {
944f5b
 	dev_tree_damage_visitor ll_dv(dv);
944f5b
-	btree_visit_values(tree, dev_v, ll_dv);
944f5b
+	btree_visit_values(tree, dev_v, ll_dv, ignore_non_fatal);
944f5b
 }
944f5b
 
944f5b
 void
944f5b
 thin_provisioning::check_mapping_tree(dev_tree const &tree,
944f5b
-				      mapping_tree_detail::damage_visitor &visitor)
944f5b
+				      mapping_tree_detail::damage_visitor &visitor,
944f5b
+                                      bool ignore_non_fatal)
944f5b
 {
944f5b
 	noop_block_visitor dev_v;
944f5b
-	walk_mapping_tree(tree, dev_v, visitor);
944f5b
+	walk_mapping_tree(tree, dev_v, visitor, ignore_non_fatal);
944f5b
 }
944f5b
 
944f5b
 void
944f5b
 thin_provisioning::walk_mapping_tree(mapping_tree const &tree,
944f5b
 				     mapping_tree_detail::mapping_visitor &mv,
944f5b
-				     mapping_tree_detail::damage_visitor &dv)
944f5b
+				     mapping_tree_detail::damage_visitor &dv,
944f5b
+                                     bool ignore_non_fatal)
944f5b
 {
944f5b
 	mapping_tree_damage_visitor ll_dv(dv);
944f5b
-	btree_visit_values(tree, mv, ll_dv);
944f5b
+	btree_visit_values(tree, mv, ll_dv, ignore_non_fatal);
944f5b
 }
944f5b
 
944f5b
 void
944f5b
 thin_provisioning::check_mapping_tree(mapping_tree const &tree,
944f5b
-				      mapping_tree_detail::damage_visitor &visitor)
944f5b
+				      mapping_tree_detail::damage_visitor &visitor,
944f5b
+                                      bool ignore_non_fatal)
944f5b
 {
944f5b
 	noop_block_time_visitor mv;
944f5b
-	walk_mapping_tree(tree, mv, visitor);
944f5b
+	walk_mapping_tree(tree, mv, visitor, ignore_non_fatal);
944f5b
 }
944f5b
 
944f5b
 void
944f5b
 thin_provisioning::walk_mapping_tree(single_mapping_tree const &tree,
944f5b
 				     uint64_t dev_id,
944f5b
 				     mapping_tree_detail::mapping_visitor &mv,
944f5b
-				     mapping_tree_detail::damage_visitor &dv)
944f5b
+				     mapping_tree_detail::damage_visitor &dv,
944f5b
+                                     bool ignore_non_fatal)
944f5b
 {
944f5b
 	single_mapping_tree_damage_visitor ll_dv(dv, dev_id);
944f5b
-	btree_visit_values(tree, mv, ll_dv);
944f5b
+	btree_visit_values(tree, mv, ll_dv, ignore_non_fatal);
944f5b
 }
944f5b
 
944f5b
 void
944f5b
 thin_provisioning::check_mapping_tree(single_mapping_tree const &tree,
944f5b
 				      uint64_t dev_id,
944f5b
-				      mapping_tree_detail::damage_visitor &visitor)
944f5b
+				      mapping_tree_detail::damage_visitor &visitor,
944f5b
+                                      bool ignore_non_fatal)
944f5b
 {
944f5b
 	noop_block_time_visitor mv;
944f5b
-	walk_mapping_tree(tree, dev_id, mv, visitor);
944f5b
+	walk_mapping_tree(tree, dev_id, mv, visitor, ignore_non_fatal);
944f5b
 }
944f5b
 
944f5b
 //----------------------------------------------------------------
944f5b
diff --git a/thin-provisioning/mapping_tree.h b/thin-provisioning/mapping_tree.h
944f5b
index ce88ba2..68b5c4b 100644
944f5b
--- a/thin-provisioning/mapping_tree.h
944f5b
+++ b/thin-provisioning/mapping_tree.h
944f5b
@@ -128,23 +128,32 @@ namespace thin_provisioning {
944f5b
 
944f5b
 	void walk_mapping_tree(dev_tree const &tree,
944f5b
 			       mapping_tree_detail::device_visitor &dev_v,
944f5b
-			       mapping_tree_detail::damage_visitor &dv;;
944f5b
-	void check_mapping_tree(dev_tree const &tree,
944f5b
-				mapping_tree_detail::damage_visitor &visitor);
944f5b
+			       mapping_tree_detail::damage_visitor &dv,
944f5b
+                               bool ignore_non_fatal = false);
944f5b
 
944f5b
 	void walk_mapping_tree(mapping_tree const &tree,
944f5b
 			       mapping_tree_detail::mapping_visitor &mv,
944f5b
-			       mapping_tree_detail::damage_visitor &dv;;
944f5b
-	void check_mapping_tree(mapping_tree const &tree,
944f5b
-				mapping_tree_detail::damage_visitor &visitor);
944f5b
+			       mapping_tree_detail::damage_visitor &dv,
944f5b
+                               bool ignore_non_fatal = false);
944f5b
 
944f5b
 	void walk_mapping_tree(single_mapping_tree const &tree,
944f5b
 			       uint64_t dev_id,
944f5b
 			       mapping_tree_detail::mapping_visitor &mv,
944f5b
-			       mapping_tree_detail::damage_visitor &dv;;
944f5b
+			       mapping_tree_detail::damage_visitor &dv,
944f5b
+                               bool ignore_non_fatal = false);
944f5b
+	
944f5b
 	void check_mapping_tree(single_mapping_tree const &tree,
944f5b
 				uint64_t dev_id,
944f5b
-				mapping_tree_detail::damage_visitor &visitor);
944f5b
+				mapping_tree_detail::damage_visitor &visitor,
944f5b
+                                bool ignore_non_fatal = false);
944f5b
+
944f5b
+	void check_mapping_tree(dev_tree const &tree,
944f5b
+				mapping_tree_detail::damage_visitor &visitor,
944f5b
+                                bool ignore_non_fatal = false);
944f5b
+
944f5b
+	void check_mapping_tree(mapping_tree const &tree,
944f5b
+				mapping_tree_detail::damage_visitor &visitor,
944f5b
+                                bool ignore_non_fatal = false);
944f5b
 }
944f5b
 
944f5b
 //----------------------------------------------------------------
944f5b
diff --git a/thin-provisioning/metadata_dumper.cc b/thin-provisioning/metadata_dumper.cc
944f5b
index ce28d2e..9ebc8d8 100644
944f5b
--- a/thin-provisioning/metadata_dumper.cc
944f5b
+++ b/thin-provisioning/metadata_dumper.cc
944f5b
@@ -131,7 +131,7 @@ namespace {
944f5b
 		auto tree = device_tree(tm, root, device_tree_detail::device_details_traits::ref_counter());
944f5b
 
944f5b
 		try {
944f5b
-			walk_device_tree(tree, de, dv);
944f5b
+			walk_device_tree(tree, de, dv, true);
944f5b
 		} catch (...) {
944f5b
 			return optional<set<uint32_t>>();
944f5b
 		}
944f5b
@@ -156,7 +156,7 @@ namespace {
944f5b
 		auto tree = dev_tree(tm, root, mapping_tree_detail::mtree_traits::ref_counter(tm));
944f5b
 
944f5b
 		try {
944f5b
-			walk_mapping_tree(tree, me, mv);
944f5b
+			walk_mapping_tree(tree, me, mv, true);
944f5b
 		} catch (...) {
944f5b
 			return optional<set<uint32_t>>();
944f5b
 		}
944f5b
@@ -722,7 +722,7 @@ namespace {
944f5b
 			// Since we're not mutating the btrees we don't need a real space map
944f5b
 			noop_map::ptr sm(new noop_map);
944f5b
 			single_mapping_tree tree(tm_, subtree_root, mapping_tree_detail::block_time_ref_counter(sm));
944f5b
-			walk_mapping_tree(tree, dev_id, static_cast<mapping_tree_detail::mapping_visitor &>(me), *damage_policy_);
944f5b
+			walk_mapping_tree(tree, dev_id, static_cast<mapping_tree_detail::mapping_visitor &>(me), *damage_policy_, true);
944f5b
 		}
944f5b
 
944f5b
 		dump_options const &opts_;
944f5b
@@ -752,7 +752,7 @@ namespace {
944f5b
 		dump_options opts;
944f5b
 		details_extractor de(opts);
944f5b
 		device_tree_detail::damage_visitor::ptr dd_policy(details_damage_policy(true));
944f5b
-		walk_device_tree(*md.details_, de, *dd_policy);
944f5b
+		walk_device_tree(*md.details_, de, *dd_policy, true);
944f5b
 
944f5b
 		e->begin_superblock("", sb.time_,
944f5b
 				    sb.trans_id_,
944f5b
@@ -765,7 +765,7 @@ namespace {
944f5b
 		{
944f5b
 			mapping_tree_detail::damage_visitor::ptr md_policy(mapping_damage_policy(true));
944f5b
 			mapping_tree_emit_visitor mte(opts, *md.tm_, e, de.get_details(), mapping_damage_policy(true));
944f5b
-			walk_mapping_tree(*md.mappings_top_level_, mte, *md_policy);
944f5b
+			walk_mapping_tree(*md.mappings_top_level_, mte, *md_policy, true);
944f5b
 		}
944f5b
 
944f5b
 		e->end_superblock();
944f5b
@@ -801,7 +801,7 @@ thin_provisioning::metadata_dump(metadata::ptr md, emitter::ptr e, dump_options
944f5b
 {
944f5b
 	details_extractor de(opts);
944f5b
 	device_tree_detail::damage_visitor::ptr dd_policy(details_damage_policy(false));
944f5b
-	walk_device_tree(*md->details_, de, *dd_policy);
944f5b
+	walk_device_tree(*md->details_, de, *dd_policy, true);
944f5b
 
944f5b
 	e->begin_superblock("", md->sb_.time_,
944f5b
 			    md->sb_.trans_id_,
944f5b
@@ -814,7 +814,7 @@ thin_provisioning::metadata_dump(metadata::ptr md, emitter::ptr e, dump_options
944f5b
 	{
944f5b
 		mapping_tree_detail::damage_visitor::ptr md_policy(mapping_damage_policy(false));
944f5b
 		mapping_tree_emit_visitor mte(opts, *md->tm_, e, de.get_details(), mapping_damage_policy(false));
944f5b
-		walk_mapping_tree(*md->mappings_top_level_, mte, *md_policy);
944f5b
+		walk_mapping_tree(*md->mappings_top_level_, mte, *md_policy, true);
944f5b
 	}
944f5b
 
944f5b
 	e->end_superblock();
944f5b
@@ -844,7 +844,7 @@ thin_provisioning::metadata_dump_subtree(metadata::ptr md, emitter::ptr e, bool
944f5b
 				 mapping_tree_detail::block_time_ref_counter(md->data_sm_));
944f5b
 	// FIXME: pass the current device id instead of zero
944f5b
 	walk_mapping_tree(tree, 0, static_cast<mapping_tree_detail::mapping_visitor &>(me),
944f5b
-			  *mapping_damage_policy(repair));
944f5b
+			  *mapping_damage_policy(repair), true);
944f5b
 }
944f5b
 
944f5b
 //----------------------------------------------------------------
944f5b
diff --git a/thin-provisioning/thin_check.cc b/thin-provisioning/thin_check.cc
944f5b
index 6373603..c2612b5 100644
944f5b
--- a/thin-provisioning/thin_check.cc
944f5b
+++ b/thin-provisioning/thin_check.cc
944f5b
@@ -244,7 +244,7 @@ namespace {
944f5b
 				nested_output::nest _ = out.push();
944f5b
 				device_tree dtree(*tm, sb.device_details_root_,
944f5b
 						  device_tree_detail::device_details_traits::ref_counter());
944f5b
-				check_device_tree(dtree, dev_rep);
944f5b
+				check_device_tree(dtree, dev_rep, fs.ignore_non_fatal_errors);
944f5b
 			}
944f5b
 		}
944f5b
 
944f5b
@@ -254,7 +254,7 @@ namespace {
944f5b
 				nested_output::nest _ = out.push();
944f5b
 				dev_tree dtree(*tm, mapping_root(sb, fs),
944f5b
 					       mapping_tree_detail::mtree_traits::ref_counter(*tm));
944f5b
-				check_mapping_tree(dtree, mapping_rep);
944f5b
+				check_mapping_tree(dtree, mapping_rep, fs.ignore_non_fatal_errors);
944f5b
 			}
944f5b
 
944f5b
 		} else if (fs.check_mapping_tree_level2) {
944f5b
@@ -263,7 +263,7 @@ namespace {
944f5b
 				nested_output::nest _ = out.push();
944f5b
 				mapping_tree mtree(*tm, mapping_root(sb, fs),
944f5b
 						   mapping_tree_detail::block_traits::ref_counter(tm->get_sm()));
944f5b
-				check_mapping_tree(mtree, mapping_rep);
944f5b
+				check_mapping_tree(mtree, mapping_rep, fs.ignore_non_fatal_errors);
944f5b
 			}
944f5b
 		}
944f5b