From 91671274bcc3ca44367b623985a9abc813db997f Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 19 May 2019 16:46:03 +0200 Subject: [PATCH] Don't fix the size of filtered out parities --- HISTORY | 2 ++ cmdline/check.c | 38 +++++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/HISTORY b/HISTORY index 710e2414..dfa1cabc 100644 --- a/HISTORY +++ b/HISTORY @@ -3,6 +3,8 @@ SnapRAID HISTORY 11.4 2019/05 ============ + * In fixing, if a parity is filtered out, don't attempt to recover its size, + and proceed without it if missing. * Avoid unnecessary parity read when fixing the parity itself. This improves the 'fix' speed when a parity file is completely missing. * Removed a build warning about major/minor defined now in sys/sysmacros.h. diff --git a/cmdline/check.c b/cmdline/check.c index 72012df6..b65849e5 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -1973,20 +1973,32 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b } parity_ptr[l] = &parity[l]; - ret = parity_create(parity_ptr[l], &state->parity[l], l, state->file_mode, state->block_size, state->opt.parity_limit_size); - if (ret == -1) { - /* LCOV_EXCL_START */ - log_fatal("WARNING! Without an accessible %s file, it isn't possible to fix any error.\n", lev_name(l)); - exit(EXIT_FAILURE); - /* LCOV_EXCL_STOP */ - } - ret = parity_chsize(parity_ptr[l], &state->parity[l], 0, size, state->block_size, state->opt.skip_fallocate, state->opt.skip_space_holder); - if (ret == -1) { - /* LCOV_EXCL_START */ - log_fatal("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l)); - exit(EXIT_FAILURE); - /* LCOV_EXCL_STOP */ + /* if the parity is excluded */ + if (state->parity[l].is_excluded_by_filter) { + /* open for reading, and ignore error */ + ret = parity_open(parity_ptr[l], &state->parity[l], l, state->file_mode, state->block_size, state->opt.parity_limit_size); + if (ret == -1) { + /* continue anyway */ + parity_ptr[l] = 0; + } + } else { + /* open for writing */ + ret = parity_create(parity_ptr[l], &state->parity[l], l, state->file_mode, state->block_size, state->opt.parity_limit_size); + if (ret == -1) { + /* LCOV_EXCL_START */ + log_fatal("WARNING! Without an accessible %s file, it isn't possible to fix any error.\n", lev_name(l)); + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } + + ret = parity_chsize(parity_ptr[l], &state->parity[l], 0, size, state->block_size, state->opt.skip_fallocate, state->opt.skip_space_holder); + if (ret == -1) { + /* LCOV_EXCL_START */ + log_fatal("WARNING! Without an accessible %s file, it isn't possible to sync.\n", lev_name(l)); + exit(EXIT_FAILURE); + /* LCOV_EXCL_STOP */ + } } } } else if (!state->opt.auditonly) {