mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Improves the -G, --gui output.
This commit is contained in:
parent
750e21ec87
commit
d35beda689
10 changed files with 165 additions and 29 deletions
29
check.c
29
check.c
|
|
@ -1650,6 +1650,35 @@ bail:
|
|||
printf("Everything OK\n");
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:error:%u\n", error);
|
||||
if (fix)
|
||||
fprintf(stdlog, "summary:error_recovered:%u\n", recovered_error);
|
||||
if (check)
|
||||
fprintf(stdlog, "summary:error_unrecoverable:%u\n", unrecoverable_error);
|
||||
if (fix) {
|
||||
if (error + recovered_error + unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else if (unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:recovered\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:unrecoverable\n");
|
||||
} else if (check) {
|
||||
if (error + unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else if (unrecoverable_error == 0)
|
||||
fprintf(stdlog, "summary:exit:recoverable\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:unrecoverable\n");
|
||||
} else { /* audit only */
|
||||
if (error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:error\n");
|
||||
}
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
free(failed);
|
||||
free(failed_map);
|
||||
free(handle);
|
||||
|
|
|
|||
19
dup.c
19
dup.c
|
|
@ -140,11 +140,20 @@ void state_dup(struct snapraid_state* state)
|
|||
tommy_list_foreach(&hashlist, (tommy_foreach_func*)hash_free);
|
||||
tommy_hashdyn_done(&hashset);
|
||||
|
||||
if (!state->opt.gui) {
|
||||
if (count)
|
||||
printf("%u duplicates, for %"PRIu64" MiB.\n", count, size / (1024*1024));
|
||||
else
|
||||
printf("No duplicate\n");
|
||||
if (count)
|
||||
printf("%u duplicates, for %"PRIu64" MiB.\n", count, size / (1024*1024));
|
||||
else
|
||||
printf("No duplicate\n");
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:dup_count:%u\n", count);
|
||||
fprintf(stdlog, "summary:dup_size:%"PRIu64"\n", size);
|
||||
if (count == 0) {
|
||||
fprintf(stdlog, "summary:exit:unique\n");
|
||||
} else {
|
||||
fprintf(stdlog, "summary:exit:dup\n");
|
||||
}
|
||||
fflush(stdlog);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
29
scan.c
29
scan.c
|
|
@ -1104,6 +1104,7 @@ void state_scan(struct snapraid_state* state, int output)
|
|||
|
||||
if (state->opt.verbose || output) {
|
||||
struct snapraid_scan total;
|
||||
int no_difference;
|
||||
|
||||
total.count_equal = 0;
|
||||
total.count_move = 0;
|
||||
|
|
@ -1131,9 +1132,33 @@ void state_scan(struct snapraid_state* state, int output)
|
|||
printf("\tadded %d\n", total.count_insert);
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:equal:%u\n", total.count_equal);
|
||||
fprintf(stdlog, "summary:moved:%u\n", total.count_move);
|
||||
fprintf(stdlog, "summary:restored:%u\n", total.count_restore);
|
||||
fprintf(stdlog, "summary:changed:%u\n", total.count_change);
|
||||
fprintf(stdlog, "summary:removed:%u\n", total.count_remove);
|
||||
fprintf(stdlog, "summary:added:%u\n", total.count_insert);
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
no_difference = !total.count_move && !total.count_restore && !total.count_change && !total.count_remove && !total.count_insert;
|
||||
|
||||
if (output) {
|
||||
if (!total.count_move && !total.count_restore && !total.count_change && !total.count_remove && !total.count_insert) {
|
||||
printf("No difference.\n");
|
||||
if (no_difference) {
|
||||
printf("No difference\n");
|
||||
} else {
|
||||
printf("There are differences\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
if (no_difference) {
|
||||
fprintf(stdlog, "summary:exit:equal\n");
|
||||
fflush(stdlog);
|
||||
} else {
|
||||
fprintf(stdlog, "summary:exit:diff\n");
|
||||
fflush(stdlog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
10
scrub.c
10
scrub.c
|
|
@ -389,6 +389,16 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
printf("Everything OK\n");
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:error_read:%u\n", error);
|
||||
fprintf(stdlog, "summary:error_data:%u\n", silent_error);
|
||||
if (error + silent_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:error\n");
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
bail:
|
||||
for(j=0;j<diskmax;++j) {
|
||||
ret = handle_close(&handle[j]);
|
||||
|
|
|
|||
|
|
@ -578,8 +578,6 @@ int main(int argc, char* argv[])
|
|||
state_read(&state);
|
||||
|
||||
state_scan(&state, 1);
|
||||
|
||||
memory(state.opt.gui);
|
||||
} else if (operation == OPERATION_SYNC) {
|
||||
|
||||
/* in the next state read ensures to clear all the undeterminated hashes in case */
|
||||
|
|
|
|||
1
state.c
1
state.c
|
|
@ -657,6 +657,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
|
|||
case 1 : fprintf(stdlog, "mode:raid5\n"); break;
|
||||
case 2 : fprintf(stdlog, "mode:raid6\n"); break;
|
||||
case 3 : fprintf(stdlog, "mode:raidTP\n"); break;
|
||||
case 4 : fprintf(stdlog, "mode:raidQP\n"); break;
|
||||
}
|
||||
|
||||
for(l=0;l<state->level;++l) {
|
||||
|
|
|
|||
79
status.c
79
status.c
|
|
@ -110,17 +110,37 @@ int state_status(struct snapraid_state* state)
|
|||
printf("Files: %u\n", file_count);
|
||||
printf("Fragmented files: %u\n", file_fragmented);
|
||||
printf("Excess fragments: %u\n", extra_fragment);
|
||||
printf("Files size: %" PRIu64 " GiB\n", file_size / (1024*1024*1024) );
|
||||
printf("Parity size: %" PRIu64 " GiB\n", blockmax * (uint64_t)state->block_size / (1024*1024*1024) );
|
||||
printf("Files size: %"PRIu64" GiB\n", file_size / (1024*1024*1024) );
|
||||
printf("Parity size: %"PRIu64" GiB\n", blockmax * (uint64_t)state->block_size / (1024*1024*1024) );
|
||||
|
||||
printf("\n");
|
||||
|
||||
/* count unsynched blocks */
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:file_count:%u\n", file_count);
|
||||
fprintf(stdlog, "summary:fragmented_file_count:%u\n", file_fragmented);
|
||||
fprintf(stdlog, "summary:excess_fragment_count:%u\n", extra_fragment);
|
||||
fprintf(stdlog, "summary:file_size:%"PRIu64"\n", file_size);
|
||||
fprintf(stdlog, "summary:parity_size:%"PRIu64"\n", blockmax * (uint64_t)state->block_size);
|
||||
fprintf(stdlog, "summary:hash:%s\n", hash_config_name(state->hash));
|
||||
fprintf(stdlog, "summary:prev_hash:%s\n", hash_config_name(state->prevhash));
|
||||
fprintf(stdlog, "summary:best_hash:%s\n", hash_config_name(state->besthash));
|
||||
fprintf(stdlog, "block_count:%u\n", blockmax);
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
/* copy the info a temp vector, and count bad/rehash/unsynched blocks */
|
||||
infomap = malloc_nofail(blockmax * sizeof(snapraid_info));
|
||||
bad = 0;
|
||||
count = 0;
|
||||
rehash = 0;
|
||||
unsynched_blocks = 0;
|
||||
|
||||
for(i=0;i<blockmax;++i) {
|
||||
int one_invalid;
|
||||
int one_valid;
|
||||
|
||||
snapraid_info info = info_get(&state->infoarr, i);
|
||||
|
||||
/* for each disk */
|
||||
one_invalid = 0;
|
||||
one_valid = 0;
|
||||
|
|
@ -138,27 +158,32 @@ int state_status(struct snapraid_state* state)
|
|||
if (one_invalid && one_valid) {
|
||||
++unsynched_blocks;
|
||||
}
|
||||
}
|
||||
|
||||
/* copy the info a temp vector, and count bad/rehash blocks */
|
||||
infomap = malloc_nofail(blockmax * sizeof(snapraid_info));
|
||||
bad = 0;
|
||||
count = 0;
|
||||
rehash = 0;
|
||||
for(i=0;i<blockmax;++i) {
|
||||
snapraid_info info = info_get(&state->infoarr, i);
|
||||
|
||||
/* skip unused blocks */
|
||||
if (info == 0)
|
||||
continue;
|
||||
|
||||
if (info_get_bad(info))
|
||||
++bad;
|
||||
if (info != 0) {
|
||||
if (info_get_bad(info))
|
||||
++bad;
|
||||
|
||||
if (info_get_rehash(info))
|
||||
++rehash;
|
||||
if (info_get_rehash(info))
|
||||
++rehash;
|
||||
|
||||
infomap[count++] = info;
|
||||
infomap[count++] = info;
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
if (info != 0)
|
||||
fprintf(stdlog, "block:%u:%"PRIu64":%s:%s:%s:%s\n", i, (uint64_t)info_get_time(info), one_valid ? "used": "", one_invalid ? "unsynched" : "", info_get_bad(info) ? "bad" : "", info_get_rehash(info) ? "rehash" : "");
|
||||
else
|
||||
fprintf(stdlog, "block_noinfo:%u:%s:%s\n", i, one_valid ? "used": "", one_invalid ? "unsynched" : "");
|
||||
}
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:has_unsynched:%u\n", unsynched_blocks);
|
||||
fprintf(stdlog, "summary:has_rehash:%u\n", rehash);
|
||||
fprintf(stdlog, "summary:has_bad:%u\n", bad);
|
||||
fprintf(stdlog, "time_count:%u\n", count);
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
if (!count) {
|
||||
|
|
@ -169,6 +194,20 @@ int state_status(struct snapraid_state* state)
|
|||
|
||||
/* sort the info to get the time info */
|
||||
qsort(infomap, count, sizeof(snapraid_info), info_time_compare);
|
||||
|
||||
if (state->opt.gui) {
|
||||
/* info for making the graph */
|
||||
i = 0;
|
||||
while (i < count) {
|
||||
unsigned j = i + 1;
|
||||
while (j < count && info_get_time(infomap[i]) == info_get_time(infomap[j]))
|
||||
++j;
|
||||
fprintf(stdlog, "time:%"PRIu64":%u\n", (uint64_t)info_get_time(infomap[i]), j - i);
|
||||
i = j;
|
||||
}
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
oldest = info_get_time(infomap[0]);
|
||||
median = info_get_time(infomap[count / 2]);
|
||||
newest = info_get_time(infomap[count - 1]);
|
||||
|
|
|
|||
10
sync.c
10
sync.c
|
|
@ -442,6 +442,16 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
printf("Everything OK\n");
|
||||
}
|
||||
|
||||
if (state->opt.gui) {
|
||||
fprintf(stdlog, "summary:error_readwrite:%u\n", error);
|
||||
fprintf(stdlog, "summary:error_data:%u\n", silent_error);
|
||||
if (error + silent_error == 0)
|
||||
fprintf(stdlog, "summary:exit:ok\n");
|
||||
else
|
||||
fprintf(stdlog, "summary:exit:error\n");
|
||||
fflush(stdlog);
|
||||
}
|
||||
|
||||
bail:
|
||||
for(j=0;j<diskmax;++j) {
|
||||
ret = handle_close(&handle[j]);
|
||||
|
|
|
|||
10
util.c
10
util.c
|
|
@ -1469,6 +1469,16 @@ void memhash(unsigned kind, const unsigned char* seed, void* digest, const void*
|
|||
}
|
||||
}
|
||||
|
||||
const char* hash_config_name(unsigned kind)
|
||||
{
|
||||
switch (kind) {
|
||||
case HASH_UNDEFINED : return "undefined";
|
||||
case HASH_MURMUR3 : return "murmur3";
|
||||
case HASH_SPOOKY2 : return "spooky2";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* random */
|
||||
|
||||
|
|
|
|||
5
util.h
5
util.h
|
|
@ -492,6 +492,11 @@ char* strdup_nofail(const char* str);
|
|||
*/
|
||||
void memhash(unsigned kind, const unsigned char* seed, void* digest, const void* src, unsigned size);
|
||||
|
||||
/**
|
||||
* Return the hash name.
|
||||
*/
|
||||
const char* hash_config_name(unsigned kind);
|
||||
|
||||
/****************************************************************************/
|
||||
/* random */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue