In fix/check with the -e option process the whole files with bad blocks

This commit is contained in:
Andrea Mazzoleni 2021-05-22 22:17:42 +02:00
parent d5d10abcda
commit 7654ed45f1
5 changed files with 40 additions and 35 deletions

View file

@ -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]

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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.