[thin_check] --override-mapping-root
This commit is contained in:
		| @@ -33,6 +33,12 @@ OPTIONS | ||||
|     is needed to fix any issues. After thin_repair succeeded, you may run | ||||
|     thin_check again. | ||||
|  | ||||
|   --override-mapping-root <block>	Specify a mapping root to use. | ||||
|  | ||||
|     Don't use this.  This overrides what's specified in the superblock.  Only | ||||
|     use this if you really understand the metadata format and are trying to | ||||
|     recover damaged metadata. | ||||
|  | ||||
| EXAMPLE | ||||
|   Analyses thin provisioning metadata on logical volume /dev/vg/metadata: | ||||
|  | ||||
|   | ||||
| @@ -20,6 +20,9 @@ | ||||
| #include <getopt.h> | ||||
| #include <libgen.h> | ||||
|  | ||||
| #include <boost/lexical_cast.hpp> | ||||
| #include <boost/optional.hpp> | ||||
|  | ||||
| #include "version.h" | ||||
|  | ||||
| #include "base/application.h" | ||||
| @@ -168,6 +171,7 @@ namespace { | ||||
| 		bool ignore_non_fatal_errors; | ||||
|  | ||||
| 		bool quiet; | ||||
| 		boost::optional<block_address> override_mapping_root; | ||||
| 		bool clear_needs_check_flag_on_success; | ||||
| 	}; | ||||
|  | ||||
| @@ -208,6 +212,11 @@ namespace { | ||||
| 			out << "This looks like XML.  thin_check only checks the binary metadata format." << end_message(); | ||||
| 	} | ||||
|  | ||||
| 	block_address mapping_root(superblock_detail::superblock const &sb, flags const &fs) | ||||
| 	{ | ||||
| 		return fs.override_mapping_root ? *fs.override_mapping_root : sb.data_mapping_root_; | ||||
| 	} | ||||
|  | ||||
| 	error_state metadata_check(string const &path, flags fs) { | ||||
| 		nested_output out(cerr, 2); | ||||
| 		if (fs.quiet) | ||||
| @@ -253,7 +262,7 @@ namespace { | ||||
| 			out << "examining top level of mapping tree" << end_message(); | ||||
| 			{ | ||||
| 				nested_output::nest _ = out.push(); | ||||
| 				dev_tree dtree(*tm, sb.data_mapping_root_, | ||||
| 				dev_tree dtree(*tm, mapping_root(sb, fs), | ||||
| 					       mapping_tree_detail::mtree_traits::ref_counter(tm)); | ||||
| 				check_mapping_tree(dtree, mapping_rep); | ||||
| 			} | ||||
| @@ -262,7 +271,7 @@ namespace { | ||||
| 			out << "examining mapping tree" << end_message(); | ||||
| 			{ | ||||
| 				nested_output::nest _ = out.push(); | ||||
| 				mapping_tree mtree(*tm, sb.data_mapping_root_, | ||||
| 				mapping_tree mtree(*tm, mapping_root(sb, fs), | ||||
| 						   mapping_tree_detail::block_traits::ref_counter(tm->get_sm())); | ||||
| 				check_mapping_tree(mtree, mapping_rep); | ||||
| 			} | ||||
| @@ -332,6 +341,7 @@ thin_check_cmd::usage(std::ostream &out) const | ||||
| 	    << "  {-q|--quiet}" << endl | ||||
| 	    << "  {-h|--help}" << endl | ||||
| 	    << "  {-V|--version}" << endl | ||||
| 	    << "  {--override-mapping-root}" << endl | ||||
| 	    << "  {--clear-needs-check-flag}" << endl | ||||
| 	    << "  {--ignore-non-fatal-errors}" << endl | ||||
| 	    << "  {--skip-mappings}" << endl | ||||
| @@ -353,6 +363,7 @@ thin_check_cmd::run(int argc, char **argv) | ||||
| 		{ "skip-mappings", no_argument, NULL, 2}, | ||||
| 		{ "ignore-non-fatal-errors", no_argument, NULL, 3}, | ||||
| 		{ "clear-needs-check-flag", no_argument, NULL, 4 }, | ||||
| 		{ "override-mapping-root", required_argument, NULL, 5}, | ||||
| 		{ NULL, no_argument, NULL, 0 } | ||||
| 	}; | ||||
|  | ||||
| @@ -392,6 +403,11 @@ thin_check_cmd::run(int argc, char **argv) | ||||
| 			fs.clear_needs_check_flag_on_success = true; | ||||
| 			break; | ||||
|  | ||||
| 		case 5: | ||||
| 			// override-mapping-root | ||||
| 			fs.override_mapping_root = boost::lexical_cast<uint64_t>(optarg); | ||||
| 			break; | ||||
|  | ||||
| 		default: | ||||
| 			usage(cerr); | ||||
| 			return 1; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user