mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04:00
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:
parent
e99b3e3461
commit
7a6db8600d
1 changed files with 14 additions and 1 deletions
15
scan.c
15
scan.c
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue