Enforces the invariant of having BLK states only if the parity is OK. Otherwise the block is moved to INV.

This commit is contained in:
Andrea Mazzoleni 2012-03-13 23:45:56 +01:00
parent e99b3e3461
commit 7a6db8600d

15
scan.c
View file

@ -97,6 +97,8 @@ static void scan_file_insert(struct snapraid_state* state, struct snapraid_disk*
block_pos = disk->first_free_block;
block_max = tommy_array_size(&disk->blockarr);
for(i=0;i<file->blockmax;++i) {
tommy_node* j;
/* find a free block */
while (block_pos < block_max && block_is_valid(tommy_array_get(&disk->blockarr, block_pos)))
++block_pos;
@ -116,7 +118,18 @@ static void scan_file_insert(struct snapraid_state* state, struct snapraid_disk*
else
block_state_set(&file->blockvec[i], BLOCK_STATE_CHG);
/* store in the disk map */
/* invalidate the block of all the other disks */
for(j=state->disklist;j!=0;j=j->next) {
struct snapraid_disk* oth_disk = j->data;
struct snapraid_block* oth_block = disk_block_get(oth_disk, block_pos);
if (block_is_valid(oth_block)) {
/* remove the parity info for this block */
block_clear_parity(oth_block);
}
}
/* store in the disk map, after invalidating all the other blocks */
tommy_array_set(&disk->blockarr, block_pos, &file->blockvec[i]);
}
if (file->blockmax) {