Handles better upgrading in the status command.

This commit is contained in:
Andrea Mazzoleni 2014-11-09 22:24:20 +01:00
parent 87e6497665
commit 0c539a0b35
5 changed files with 22 additions and 3 deletions

View file

@ -629,9 +629,6 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
printf("Scrubbing...\n");
/* after opening parity files, refresh the free info */
state_refresh(state);
error = 0;
ret = state_scrub_process(state, parity_ptr, 0, blockmax, timelimit, lastlimit, now);

View file

@ -70,10 +70,14 @@ int state_status(struct snapraid_state* state)
block_off_t parity_block_free;
unsigned unsynced_blocks;
uint64_t all_wasted;
int free_not_zero;
/* get the present time */
now = time(0);
/* keep track if at least a free info is available */
free_not_zero = 0;
blockmax = parity_size(state);
fprintf(stdlog, "summary:block_size:%u\n", state->block_size);
@ -86,6 +90,8 @@ int state_status(struct snapraid_state* state)
fprintf(stdlog, "summary:parity_block_free:%s:%u\n", lev_config_name(l), state->parity[l].free_blocks);
if (state->parity[l].free_blocks < parity_block_free)
parity_block_free = state->parity[l].free_blocks;
if (state->parity[l].free_blocks != 0)
free_not_zero = 1;
}
fprintf(stdlog, "summary:parity_block_free_min:%u\n", parity_block_free);
@ -162,6 +168,9 @@ int state_status(struct snapraid_state* state)
disk_file_size += file->size;
}
if (disk->free_blocks != 0)
free_not_zero = 1;
/* get the free block info */
disk_block_max_by_space = disk_block_count + disk->free_blocks;
disk_block_max_by_parity = blockmax + parity_block_free;
@ -216,6 +225,10 @@ int state_status(struct snapraid_state* state)
printf(" %3u%%", perc(file_block_count, file_block_count + file_block_free));
printf("\n");
/* warn about invalid data free info */
if (!free_not_zero)
printf("\nWARNING! Free space info will be valid after the first sync.\n");
fprintf(stdlog, "summary:file_count:%u\n", file_count);
fprintf(stdlog, "summary:file_block_count:%" PRIu64 "\n", file_block_count);
fprintf(stdlog, "summary:fragmented_file_count:%u\n", file_fragmented);

View file

@ -532,6 +532,9 @@ It includes information about the parity fragmentation, how old
are the blocks without checking, and all the recorded silent
errors encountered while scrubbing.
.PP
Note that the information presented refers at the latest time you run \[dq]sync\[dq].
Later modifications are not taken into account.
.PP
Nothing is modified.
.SS sync
Updates the parity information. All the modified files

View file

@ -285,6 +285,9 @@ Commands
are the blocks without checking, and all the recorded silent
errors encountered while scrubbing.
Note that the information presented refers at the latest time you run "sync".
Later modifications are not taken into account.
Nothing is modified.
sync

View file

@ -309,6 +309,9 @@ It includes information about the parity fragmentation, how old
are the blocks without checking, and all the recorded silent
errors encountered while scrubbing.
Note that the information presented refers at the latest time you run "sync".
Later modifications are not taken into account.
Nothing is modified.
5.2 sync