From d5d10abcda53abf2f1e7b74e5ca7a681c66c7afe Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 22 May 2021 21:02:51 +0200 Subject: [PATCH] Do not postprocess files in excluded blocks The filtering is by files, so the last block is included. The only exception is with an explicit end block, but in such case, like when fixing bad blocks the post processing is not expected. --- cmdline/check.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/cmdline/check.c b/cmdline/check.c index 749039f2..dfdf958b 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -590,9 +590,12 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign * For each file, if we are at the last block, closes it, * adjust the timestamp, and print the result. * - * This works with the assumption to always process the whole files to - * fix. This assumption is not always correct, and in such case we have to - * skip the whole postprocessing. And example, is when fixing only bad blocks. + * 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. + * + * In such case, the check/fix command won't report any information of the + * files affected. */ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct snapraid_handle* handle, unsigned diskmax) { @@ -601,8 +604,7 @@ 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, we don't have to do any post-processing */ - /* as we don't have any guarantee to process the last block of the fixed files */ + /* if we are processing only bad blocks, skip all post-processing */ if (state->opt.badonly) return 0; @@ -922,17 +924,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna int rehash; if (!bit_vect_test(block_enabled, i)) { - /* post process the files */ - ret = file_post(state, fix, i, handle, diskmax); - if (ret == -1) { - /* LCOV_EXCL_START */ - log_fatal("Stopping at block %u\n", i); - ++unrecoverable_error; - goto bail; - /* LCOV_EXCL_STOP */ - } - - /* and now continue with the next block */ + /* continue with the next block */ continue; }