diff --git a/HISTORY b/HISTORY index 65a6d9c5..4218ebd6 100644 --- a/HISTORY +++ b/HISTORY @@ -1,8 +1,12 @@ SnapRAID HISTORY ================ -11.5 2020/05 +11.5 2021/06 ============ + * The fix and check command with the -e option now process the whole files + that have bad blocks, and not only the block marked bad. + This allow to print the file paths and to process them like standard + fix and check. * Removed the default -march=native to allow to deploy in any machine. * Fixed typos [Andrea Gelmini] diff --git a/cmdline/check.c b/cmdline/check.c index dfdf958b..fb0283b2 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -591,11 +591,10 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign * adjust the timestamp, and print the result. * * This works only if the whole file is processed, including its last block. - * This doesn't always happen, like when fixing only bad blocks, or with an - * explicit end block. + * This doesn't always happen, like with an explicit end block. * * In such case, the check/fix command won't report any information of the - * files affected. + * files partially checked. */ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct snapraid_handle* handle, unsigned diskmax) { @@ -604,10 +603,6 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s char esc_buffer[ESC_MAX]; char esc_buffer_alt[ESC_MAX]; - /* if we are processing only bad blocks, skip all post-processing */ - if (state->opt.badonly) - return 0; - /* for all the files print the final status, and does the final time fix */ /* we also ensure to close files after processing the last block */ for (j = 0; j < diskmax; ++j) { @@ -806,28 +801,36 @@ static int block_is_enabled(struct snapraid_state* state, block_off_t i, struct unsigned j; unsigned l; - /* if we filter for only bad blocks */ + /* filter for the parity */ if (state->opt.badonly) { snapraid_info info; /* get block specific info */ info = info_get(&state->infoarr, i); - /* skip if this is not bad */ - if (!info_get_bad(info)) - return 0; - } - - /* now apply the filters */ - - /* if a parity is not excluded, include all blocks, even unused ones */ - for (l = 0; l < state->level; ++l) { - if (!state->parity[l].is_excluded_by_filter) { + /* + * If the block is bad, it has to be processed + * + * This is not necessary in normal cases because if a block is bad, + * it necessary needs to have a file related to it, and files with + * bad blocks are fully included. + * + * But some files may be excluded by additional filter options, + * so it's not always true, and this ensures to always check all + * the bad blocks. + */ + if (info_get_bad(info)) return 1; + } else { + /* if a parity is not excluded, include all blocks, even unused ones */ + for (l = 0; l < state->level; ++l) { + if (!state->parity[l].is_excluded_by_filter) { + return 1; + } } } - /* otherwise include only used blocks */ + /* filter for the files */ for (j = 0; j < diskmax; ++j) { struct snapraid_block* block; diff --git a/snapraid.1 b/snapraid.1 index 1b448dcc..93c85dbc 100644 --- a/snapraid.1 +++ b/snapraid.1 @@ -1041,9 +1041,9 @@ Note that it cannot be used with \[dq]sync\[dq] and \[dq]scrub\[dq], because the process the whole array. .TP .B \-e, \-\-filter\-error -Filters the blocks to process in \[dq]check\[dq] and \[dq]fix\[dq]. -It processes only the blocks marked with silent or input/output -errors during \[dq]sync\[dq] and \[dq]scrub\[dq], and listed in \[dq]status\[dq]. +Process the files with errors in \[dq]check\[dq] and \[dq]fix\[dq]. +It processes only files that have blocks marked with silent +or input/output errors during \[dq]sync\[dq] and \[dq]scrub\[dq], and listed in \[dq]status\[dq]. This option can be used only with \[dq]check\[dq] and \[dq]fix\[dq]. .TP .B \-p, \-\-plan PERC|bad|new|full diff --git a/snapraid.d b/snapraid.d index 41bc583a..196570d1 100644 --- a/snapraid.d +++ b/snapraid.d @@ -737,9 +737,9 @@ Options process the whole array. -e, --filter-error - Filters the blocks to process in "check" and "fix". - It processes only the blocks marked with silent or input/output - errors during "sync" and "scrub", and listed in "status". + Process the files with errors in "check" and "fix". + It processes only files that have blocks marked with silent + or input/output errors during "sync" and "scrub", and listed in "status". This option can be used only with "check" and "fix". -p, --plan PERC|bad|new|full diff --git a/snapraid.txt b/snapraid.txt index ccff41cd..72734e06 100644 --- a/snapraid.txt +++ b/snapraid.txt @@ -794,9 +794,9 @@ SnapRAID provides the following options: process the whole array. -e, --filter-error - Filters the blocks to process in "check" and "fix". - It processes only the blocks marked with silent or input/output - errors during "sync" and "scrub", and listed in "status". + Process the files with errors in "check" and "fix". + It processes only files that have blocks marked with silent + or input/output errors during "sync" and "scrub", and listed in "status". This option can be used only with "check" and "fix". -p, --plan PERC|bad|new|full @@ -919,12 +919,10 @@ SnapRAID provides the following options: This option can be used to completely reallocate all the files removing the fragmentation, but reusing the hashes present in the content file to validate data. - - WARNING! This option is for experts only, and it's highly - recommended to not use it. - You DO NOT have data protection during the "sync" operation. - - This option can be used only with "sync". + This option can be used only with "sync". + WARNING! This option is for experts only, and it's highly + recommended to not use it. + You DO NOT have data protection during the "sync" operation. -l, --log FILE Write a detailed log in the specified file.