From e7303a11c670cb2a48219be46de8bacabfd09194 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 23 May 2013 11:57:02 +0100 Subject: [PATCH] [thin_check] --ignore-non-fatal-errors --- features/thin_check.feature | 6 ++++++ man8/thin_check.8 | 8 ++++++++ thin-provisioning/thin_check.cc | 17 +++++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/features/thin_check.feature b/features/thin_check.feature index 098218e..32c1d88 100644 --- a/features/thin_check.feature +++ b/features/thin_check.feature @@ -39,6 +39,7 @@ Feature: thin_check {-V|--version} {--super-block-only} {--skip-mappings} + {--ignore-non-fatal-errors} """ Scenario: Unrecognised option should cause failure @@ -63,4 +64,9 @@ Feature: thin_check Scenario: --skip-mappings check passes on valid metadata 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 \ No newline at end of file diff --git a/man8/thin_check.8 b/man8/thin_check.8 index d52add2..f9606e0 100644 --- a/man8/thin_check.8 +++ b/man8/thin_check.8 @@ -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: diff --git a/thin-provisioning/thin_check.cc b/thin-provisioning/thin_check.cc index efe0ca3..cb8d283 100644 --- a/thin-provisioning/thin_check.cc +++ b/thin-provisioning/thin_check.cc @@ -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;