mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-26 18:06:28 -05:00
Avoid redundant block initialization when loading content files
This commit is contained in:
parent
bc564e7465
commit
b14f703d2b
4 changed files with 22 additions and 10 deletions
|
|
@ -691,6 +691,7 @@ static void scan_file_apply(void* void_scan, void* void_disc)
|
|||
struct snapraid_disk* disk = scan->disk;
|
||||
int is_diff = scan->is_diff;
|
||||
struct snapraid_file* file;
|
||||
block_off_t block_pos;
|
||||
tommy_node* i;
|
||||
int is_original_file_size_different_than_zero;
|
||||
int is_file_already_present;
|
||||
|
|
@ -997,6 +998,18 @@ static void scan_file_apply(void* void_scan, void* void_disc)
|
|||
/* insert it */
|
||||
file = file_alloc(state->block_size, sub, disc->size, disc->mtime_sec, disc->mtime_nsec, disc->inode);
|
||||
|
||||
/*
|
||||
* Copy detection recognizes reused hashes from REP blocks before parity
|
||||
* allocation. Initialize new scan blocks to CHG so uninitialized state can
|
||||
* never be mistaken for a reusable hash.
|
||||
*/
|
||||
for (block_pos = 0; block_pos < file->blockmax; ++block_pos) {
|
||||
struct snapraid_block* block = fs_file2block_get(file, block_pos);
|
||||
|
||||
block_state_set(block, BLOCK_STATE_CHG);
|
||||
hash_invalid_set(block->hash);
|
||||
}
|
||||
|
||||
/* mark it as present and physically discovered during Phase 1 */
|
||||
file_flag_set(file, FILE_IS_PRESENT);
|
||||
file_flag_set(file, FILE_IS_DISCOVERED);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue