mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Force version 3 when saving content
This avoid saving the content file when it was not strictly necessary because we keep the partity size.
This commit is contained in:
parent
d02d33cd7f
commit
2555e503aa
2 changed files with 14 additions and 35 deletions
1
HISTORY
1
HISTORY
|
|
@ -3,6 +3,7 @@ SnapRAID HISTORY
|
|||
|
||||
13.1 WIP
|
||||
========
|
||||
* Avoided saving the content file when it was not strictly necessary.
|
||||
* More log tags for the `status` command [Tristan Teufel]
|
||||
* Added documentation of the tags used in the log file in the new
|
||||
snapraid_log manpage.
|
||||
|
|
|
|||
|
|
@ -3057,27 +3057,15 @@ static void* state_write_thread(void* arg)
|
|||
block_off_t idx;
|
||||
block_off_t begin;
|
||||
unsigned l, s;
|
||||
int version;
|
||||
|
||||
count_file = 0;
|
||||
count_hardlink = 0;
|
||||
count_symlink = 0;
|
||||
count_dir = 0;
|
||||
|
||||
/* check what version to use */
|
||||
version = 2;
|
||||
for (l = 0; l < state->level; ++l) {
|
||||
if (state->parity[l].split_mac > 1)
|
||||
version = 3;
|
||||
}
|
||||
if (BLOCK_HASH_SIZE != 16)
|
||||
version = 3;
|
||||
|
||||
/* force version 3 a we want to always store the parity size */
|
||||
/* write header */
|
||||
if (version == 3)
|
||||
swrite("SNAPCNT3\n\3\0\0", 12, f);
|
||||
else
|
||||
swrite("SNAPCNT2\n\3\0\0", 12, f);
|
||||
swrite("SNAPCNT3\n\3\0\0", 12, f);
|
||||
|
||||
/* write block size and block max */
|
||||
sputc('z', f);
|
||||
|
|
@ -3086,10 +3074,8 @@ static void* state_write_thread(void* arg)
|
|||
sputb32(blockmax, f);
|
||||
|
||||
/* hash size */
|
||||
if (version == 3) {
|
||||
sputc('y', f);
|
||||
sputb32(BLOCK_HASH_SIZE, f);
|
||||
}
|
||||
sputc('y', f);
|
||||
sputb32(BLOCK_HASH_SIZE, f);
|
||||
|
||||
if (serror(f)) {
|
||||
/* LCOV_EXCL_START */
|
||||
|
|
@ -3179,23 +3165,15 @@ static void* state_write_thread(void* arg)
|
|||
|
||||
/* for each parity */
|
||||
for (l = 0; l < state->level; ++l) {
|
||||
if (version == 3) {
|
||||
sputc('Q', f);
|
||||
sputb32(l, f);
|
||||
sputb32(state->parity[l].total_blocks, f);
|
||||
sputb32(state->parity[l].free_blocks, f);
|
||||
sputb32(state->parity[l].split_mac, f);
|
||||
for (s = 0; s < state->parity[l].split_mac; ++s) {
|
||||
sputbs(state->parity[l].split_map[s].path, f);
|
||||
sputbs(state->parity[l].split_map[s].uuid, f);
|
||||
sputb64(state->parity[l].split_map[s].size, f);
|
||||
}
|
||||
} else {
|
||||
sputc('P', f);
|
||||
sputb32(l, f);
|
||||
sputb32(state->parity[l].total_blocks, f);
|
||||
sputb32(state->parity[l].free_blocks, f);
|
||||
sputbs(state->parity[l].split_map[0].uuid, f);
|
||||
sputc('Q', f);
|
||||
sputb32(l, f);
|
||||
sputb32(state->parity[l].total_blocks, f);
|
||||
sputb32(state->parity[l].free_blocks, f);
|
||||
sputb32(state->parity[l].split_mac, f);
|
||||
for (s = 0; s < state->parity[l].split_mac; ++s) {
|
||||
sputbs(state->parity[l].split_map[s].path, f);
|
||||
sputbs(state->parity[l].split_map[s].uuid, f);
|
||||
sputb64(state->parity[l].split_map[s].size, f);
|
||||
}
|
||||
if (serror(f)) {
|
||||
/* LCOV_EXCL_START */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue