Check the block state before getting the parity mapping

This case is not problematic, but we enforce the check order
for consistency.
This commit is contained in:
Andrea Mazzoleni 2015-10-08 18:41:01 +02:00
parent 2df022c38b
commit 0c7ea790c3

View file

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