From 0c7ea790c3cf264ca077aa280e4b70727ad73569 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 8 Oct 2015 18:41:01 +0200 Subject: [PATCH] Check the block state before getting the parity mapping This case is not problematic, but we enforce the check order for consistency. --- cmdline/scan.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmdline/scan.c b/cmdline/scan.c index 186d909f..d29d2bdd 100644 --- a/cmdline/scan.c +++ b/cmdline/scan.c @@ -365,12 +365,20 @@ static int file_is_full_invalid_parity_and_stable(struct snapraid_state* state, for (i = 0; i < file->blockmax; ++i) { snapraid_info info; struct snapraid_block* block = fs_file2block_get(file, i); - block_off_t parity_pos = fs_file2par_get(disk, file, i); + block_off_t parity_pos; /* exclude blocks with parity */ if (!block_has_invalid_parity(block)) return 0; + /* + * Get the parity position, but only after checking + * that the file has invalid parity. + * This is not really required, as we are sure + * that 'kept" files are mapped into parity. + */ + parity_pos = fs_file2par_get(disk, file, i); + /* get block specific info */ info = info_get(&state->infoarr, parity_pos);