diff --git a/scan.c b/scan.c index 84294f85..ea378945 100644 --- a/scan.c +++ b/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;iblockmax;++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) {