From 0c539a0b3545fe8dfb61f00e1f8ea2771ca1dfb3 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 9 Nov 2014 22:24:20 +0100 Subject: [PATCH] Handles better upgrading in the status command. --- cmdline/scrub.c | 3 --- cmdline/status.c | 13 +++++++++++++ snapraid.1 | 3 +++ snapraid.d | 3 +++ snapraid.txt | 3 +++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/cmdline/scrub.c b/cmdline/scrub.c index 8148bdc4..ed4c242f 100644 --- a/cmdline/scrub.c +++ b/cmdline/scrub.c @@ -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); diff --git a/cmdline/status.c b/cmdline/status.c index 1728e0da..40639c59 100644 --- a/cmdline/status.c +++ b/cmdline/status.c @@ -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); diff --git a/snapraid.1 b/snapraid.1 index c6353cae..e49ece3c 100644 --- a/snapraid.1 +++ b/snapraid.1 @@ -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 diff --git a/snapraid.d b/snapraid.d index 13c20f84..42ac11de 100644 --- a/snapraid.d +++ b/snapraid.d @@ -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 diff --git a/snapraid.txt b/snapraid.txt index bacd2581..eec62f9f 100644 --- a/snapraid.txt +++ b/snapraid.txt @@ -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