[thin_check] --ignore-non-fatal-errors
This commit is contained in:
		@@ -39,6 +39,7 @@ Feature: thin_check
 | 
			
		||||
      {-V|--version}
 | 
			
		||||
      {--super-block-only}
 | 
			
		||||
      {--skip-mappings}
 | 
			
		||||
      {--ignore-non-fatal-errors}
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
  Scenario: Unrecognised option should cause failure
 | 
			
		||||
@@ -64,3 +65,8 @@ Feature: thin_check
 | 
			
		||||
    Given valid metadata
 | 
			
		||||
    When I run thin_check with --skip-mappings
 | 
			
		||||
    Then it should pass
 | 
			
		||||
 | 
			
		||||
  Scenario: --ignore-non-fatal-errors check passes on valid metadata
 | 
			
		||||
    Given valid metadata
 | 
			
		||||
    When I run thin_check with --ignore-non-fatal-errors
 | 
			
		||||
    Then it should pass
 | 
			
		||||
@@ -32,6 +32,14 @@ Only check the superblock is present.
 | 
			
		||||
Skip checking of the block mappings which make up the bulk of the
 | 
			
		||||
metadata.
 | 
			
		||||
 | 
			
		||||
.IP "\fB\-\-ignore\-non\-fatal\-errors\fP"
 | 
			
		||||
.B thin_check
 | 
			
		||||
will only return a non-zero exit code if it finds a fatal
 | 
			
		||||
error.  An example of a on fatal error is an incorrect data block
 | 
			
		||||
reference count causing a block to be considered allocated when it in
 | 
			
		||||
fact isn't.  Ignoring errors for a long time is not advised, you
 | 
			
		||||
really should be using thin_repair to fix them.
 | 
			
		||||
 | 
			
		||||
.SH EXAMPLE
 | 
			
		||||
Analyses and repairs thin provisioning metadata on logical volume
 | 
			
		||||
/dev/vg/metadata:
 | 
			
		||||
 
 | 
			
		||||
@@ -233,6 +233,8 @@ namespace {
 | 
			
		||||
		bool check_device_tree;
 | 
			
		||||
		bool check_mapping_tree_level1;
 | 
			
		||||
		bool check_mapping_tree_level2;
 | 
			
		||||
 | 
			
		||||
		bool ignore_non_fatal_errors;
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	error_state metadata_check(string const &path, flags fs) {
 | 
			
		||||
@@ -299,7 +301,10 @@ namespace {
 | 
			
		||||
			return 1;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return (err == NO_ERROR) ? 0 : 1;
 | 
			
		||||
		if (fs.ignore_non_fatal_errors)
 | 
			
		||||
			return (err == FATAL) ? 1 : 0;
 | 
			
		||||
		else
 | 
			
		||||
			return (err == NO_ERROR) ? 0 : 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void usage(ostream &out, string const &cmd) {
 | 
			
		||||
@@ -309,7 +314,8 @@ namespace {
 | 
			
		||||
		    << "  {-h|--help}" << endl
 | 
			
		||||
		    << "  {-V|--version}" << endl
 | 
			
		||||
		    << "  {--super-block-only}" << endl
 | 
			
		||||
		    << "  {--skip-mappings}" << endl;
 | 
			
		||||
		    << "  {--skip-mappings}" << endl
 | 
			
		||||
		    << "  {--ignore-non-fatal-errors}" << endl;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -325,12 +331,14 @@ int main(int argc, char **argv)
 | 
			
		||||
		{ "version", no_argument, NULL, 'V'},
 | 
			
		||||
		{ "super-block-only", no_argument, NULL, 1},
 | 
			
		||||
		{ "skip-mappings", no_argument, NULL, 2},
 | 
			
		||||
		{ "ignore-non-fatal-errors", no_argument, NULL, 3},
 | 
			
		||||
		{ NULL, no_argument, NULL, 0 }
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	fs.check_device_tree = true;
 | 
			
		||||
	fs.check_mapping_tree_level1 = true;
 | 
			
		||||
	fs.check_mapping_tree_level2 = true;
 | 
			
		||||
	fs.ignore_non_fatal_errors = false;
 | 
			
		||||
 | 
			
		||||
	while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
 | 
			
		||||
		switch(c) {
 | 
			
		||||
@@ -358,6 +366,11 @@ int main(int argc, char **argv)
 | 
			
		||||
			fs.check_mapping_tree_level2 = false;
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		case 3:
 | 
			
		||||
			// ignore-non-fatal-errors
 | 
			
		||||
			fs.ignore_non_fatal_errors = true;
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		default:
 | 
			
		||||
			usage(cerr, basename(argv[0]));
 | 
			
		||||
			return 1;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user