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

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