mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Changes come comments. No functionality change.
This commit is contained in:
parent
04a8a94f9e
commit
1314f12d64
3 changed files with 11 additions and 10 deletions
2
check.c
2
check.c
|
|
@ -314,7 +314,7 @@ static int repair(struct snapraid_state* state, unsigned pos, unsigned diskmax,
|
|||
memset(buffer[failed[j].index], 0, state->block_size);
|
||||
/* note that from now the buffer is definitively lost */
|
||||
/* we can do this only because it's the last retry of recovering */
|
||||
|
||||
|
||||
/* mark that we have restored an old state */
|
||||
failed[j].is_outofdate = 1;
|
||||
}
|
||||
|
|
|
|||
5
elem.h
5
elem.h
|
|
@ -69,6 +69,8 @@ struct snapraid_file;
|
|||
/**
|
||||
* The block has both the hash and the parity computed.
|
||||
* This is the normal state of a saved block.
|
||||
* Note that if exists at least one BLOCK_STATE_BLK in a disk, all the other
|
||||
* blocks at the same address in other disks can be only BLOCK_EMPTY or BLOCK_STATE_BLK.
|
||||
*/
|
||||
#define BLOCK_STATE_BLK 0
|
||||
|
||||
|
|
@ -80,9 +82,6 @@ struct snapraid_file;
|
|||
/**
|
||||
* The block has the hash computed, but the parity is invalid.
|
||||
* This happens when the parity is invalidated by a change in another block.
|
||||
* Note that this state is almost reduntant because we can detect that the parity is invalid
|
||||
* also checking the other disks, where for sure exists a block the BLOCK_STATE_CHG/NEW state
|
||||
* or a BLOCK_DELETED block.
|
||||
*/
|
||||
#define BLOCK_STATE_INV 2
|
||||
|
||||
|
|
|
|||
14
state.c
14
state.c
|
|
@ -563,7 +563,7 @@ static void state_content_check(struct snapraid_state* state, const char* path)
|
|||
}
|
||||
}
|
||||
|
||||
/* check the parity validity invariant */
|
||||
/* check the parity validity */
|
||||
for(j=0;1;++j) { /* for all the blocks */
|
||||
int at_least_one = 0;
|
||||
int parity_is_valid = 0;
|
||||
|
|
@ -578,6 +578,7 @@ static void state_content_check(struct snapraid_state* state, const char* path)
|
|||
if (j < size) {
|
||||
struct snapraid_block* block = tommy_array_get(&disk->blockarr, j);
|
||||
|
||||
/* mark if at least one block is addressed */
|
||||
at_least_one = 1;
|
||||
|
||||
if (block == BLOCK_EMPTY) {
|
||||
|
|
@ -585,16 +586,17 @@ static void state_content_check(struct snapraid_state* state, const char* path)
|
|||
} else if (block == BLOCK_DELETED) {
|
||||
parity_is_invalid = 1;
|
||||
} else {
|
||||
switch (block_state_get(block)) {
|
||||
case BLOCK_STATE_BLK : parity_is_valid = 1; break;
|
||||
case BLOCK_STATE_NEW : parity_is_invalid = 1; break;
|
||||
case BLOCK_STATE_INV : parity_is_invalid = 1; break;
|
||||
case BLOCK_STATE_CHG : parity_is_invalid = 1; break;
|
||||
unsigned state = block_state_get(block);
|
||||
if (state == BLOCK_STATE_BLK) {
|
||||
parity_is_valid = 1;
|
||||
} else {
|
||||
parity_is_invalid = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* we cannot have different blocks reporting both valid and invalid parity */
|
||||
if (parity_is_valid && parity_is_invalid) {
|
||||
fprintf(stderr, "Internal inconsistency in parity validity at block %u\n", j);
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue