diff --git a/cmdline/check.c b/cmdline/check.c index fb0283b2..2159c8b7 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -801,8 +801,21 @@ static int block_is_enabled(struct snapraid_state* state, block_off_t i, struct unsigned j; unsigned l; + /* filter for bad blocks */ + if (state->opt.badblockonly) { + snapraid_info info; + + /* get block specific info */ + info = info_get(&state->infoarr, i); + + /* + * Filter specifically only for bad blocks + */ + return info_get_bad(info); + } + /* filter for the parity */ - if (state->opt.badonly) { + if (state->opt.badfileonly) { snapraid_info info; /* get block specific info */ diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index f92ae1e6..36656662 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -315,6 +315,7 @@ struct option long_options[] = { { "filter-disk", 1, 0, 'd' }, { "filter-missing", 0, 0, 'm' }, { "filter-error", 0, 0, 'e' }, + { "filter-block-error", 0, 0, 'b' }, { "percentage", 1, 0, 'p' }, /* legacy name for --plan */ { "plan", 1, 0, 'p' }, { "older-than", 1, 0, 'o' }, @@ -478,7 +479,7 @@ struct option long_options[] = { }; #endif -#define OPTIONS "c:f:d:mep:o:S:B:L:i:l:ZEUDNFRahTC:vqHVG" +#define OPTIONS "c:f:d:mebp:o:S:B:L:i:l:ZEUDNFRahTC:vqHVG" volatile int global_interrupt = 0; @@ -627,10 +628,18 @@ int main(int argc, char* argv[]) opt.expected_missing = 1; break; case 'e' : - /* when processing only error, we filter both files and blocks */ + /* when processing only error, we filter files */ /* and we apply fixes only to synced ones */ filter_error = 1; - opt.badonly = 1; + opt.badfileonly = 1; + opt.syncedonly = 1; + break; + case 'b' : + /* when processing only block with error, we filter both files and blocks */ + /* and we apply fixes only to synced ones */ + filter_error = 1; + opt.badfileonly = 1; + opt.badblockonly = 1; opt.syncedonly = 1; break; case 'p' : diff --git a/cmdline/state.h b/cmdline/state.h index 47947589..e91e0cfe 100644 --- a/cmdline/state.h +++ b/cmdline/state.h @@ -73,7 +73,8 @@ extern volatile int global_interrupt; struct snapraid_option { int gui; /**< Gui output. */ int auditonly; /**< In check, checks only the hash and not the parity. */ - int badonly; /**< In fix, fixes only the blocks marked as bad. */ + int badfileonly; /**< In fix, fixes only files marked as bad. */ + int badblockonly; /**< In fix, fixes only the blocks marked as bad. */ int syncedonly; /**< In fix, fixes only files that are synced. */ int prehash; /**< Enables the prehash mode for sync. */ unsigned io_error_limit; /**< Max number of input/output errors before aborting. */