From 3a4ce0b1e2154b300669bdc695f5432c8b1283da Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 29 Mar 2015 22:18:21 +0200 Subject: [PATCH] Use GB instead of GiB to be more consistent with HD size. --- HISTORY | 2 ++ cmdline/dup.c | 2 +- cmdline/list.c | 2 +- cmdline/snapraid.c | 2 +- cmdline/state.c | 8 ++++---- cmdline/state.h | 6 ++++++ cmdline/status.c | 19 +++++++++---------- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/HISTORY b/HISTORY index 1e20c24d..ace3bc61 100644 --- a/HISTORY +++ b/HISTORY @@ -29,6 +29,8 @@ SnapRAID HISTORY * In the "status" command the "Wasted" column now shows a negative number for the amount of space that you can still waste without filling up the parity. + * In the "status" and others commands we now use GB instead of GiB, + when referring to disk space. * Renames the -s and -t options to -S and -B as they are intended to be manual only operations. * Windows binary built with gcc 4.8.1 using the MXE cross compiler 2.23, diff --git a/cmdline/dup.c b/cmdline/dup.c index a4f2c3de..a4ff67cd 100644 --- a/cmdline/dup.c +++ b/cmdline/dup.c @@ -138,7 +138,7 @@ void state_dup(struct snapraid_state* state) tommy_hashdyn_done(&hashset); msg_status("\n"); - msg_status("%8u duplicates, for %" PRIu64 " MiB\n", count, size / (1024 * 1024)); + msg_status("%8u duplicates, for %" PRIu64 " GB\n", count, size / GIGA); if (count) msg_status("There are duplicates!\n"); else diff --git a/cmdline/list.c b/cmdline/list.c index 30bd40db..60ef441e 100644 --- a/cmdline/list.c +++ b/cmdline/list.c @@ -109,7 +109,7 @@ void state_list(struct snapraid_state* state) } msg_status("\n"); - msg_status("%8u files, for %" PRIu64 " GiB\n", file_count, file_size / (1024 * 1024 * 1024)); + msg_status("%8u files, for %" PRIu64 " GB\n", file_count, file_size / GIGA); msg_status("%8u links\n", link_count); msg_tag("summary:file_count:%u\n", file_count); diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index 441fea6e..cc10e98f 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -84,7 +84,7 @@ void memory(void) /* size of the file + the size of the 3 hashtables pointers to it, * 2 for the hashtable grow factor */ msg_tag("memory:file:%" PRIu64 "\n", (uint64_t)(sizeof(struct snapraid_file) + 3*2*sizeof(void*))); - msg_progress("Using %u MiB of memory.\n", (unsigned)(malloc_counter() / 1024 / 1024)); + msg_progress("Using %u MiB of memory.\n", (unsigned)(malloc_counter() / (1024 * 1024))); } diff --git a/cmdline/state.c b/cmdline/state.c index 4e268fcf..9a9151a2 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -4622,13 +4622,13 @@ void state_progress_end(struct snapraid_state* state, block_off_t countpos, bloc time_t now; time_t elapsed; - unsigned countsize_MiB = (countsize + 1024 * 1024 - 1) / (1024 * 1024); + unsigned countsize_MB = (countsize + MEGA - 1) / MEGA; now = time(0); elapsed = now - state->progress_whole_start - state->progress_wasted; - msg_bar("%u%% completed, %u MiB processed", countpos * 100 / countmax, countsize_MiB); + msg_bar("%u%% completed, %u MB processed", countpos * 100 / countmax, countsize_MB); if (elapsed >= 60) msg_bar(" in %u:%02u", (unsigned)(elapsed / 3600), (unsigned)((elapsed % 3600) / 60)); msg_bar("\n"); @@ -4738,7 +4738,7 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off /* estimate the speed in MiB/s */ if (delta_time != 0) - out_speed = (unsigned)(delta_size / (1024 * 1024) / delta_time); + out_speed = (unsigned)(delta_size / MEGA / delta_time); /* estimate the cpu usage percentage */ if (delta_tick_total != 0) @@ -4753,7 +4753,7 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off msg_tag("run:pos:%u:%u:%" PRIu64 ":%u:%u:%u:%u:%" PRIu64 "\n", blockpos, countpos, countsize, out_perc, out_eta, out_speed, out_cpu, (uint64_t)elapsed); msg_flush(); } else { - msg_bar("%u%%, %u MiB", out_perc, (unsigned)(countsize / (1024 * 1024))); + msg_bar("%u%%, %u MiB", out_perc, (unsigned)(countsize / MEGA)); if (out_speed) msg_bar(", %u MiB/s", out_speed); if (out_cpu) diff --git a/cmdline/state.h b/cmdline/state.h index ce30ada6..7ca07688 100644 --- a/cmdline/state.h +++ b/cmdline/state.h @@ -41,6 +41,12 @@ const char* lev_config_name(unsigned level); /****************************************************************************/ /* state */ +/** + * Units for disk space. + */ +#define MEGA (1000 * 1000) +#define GIGA (1000 * 1000 * 1000) + /** * File modes. */ diff --git a/cmdline/status.c b/cmdline/status.c index 73064b61..34e3bf38 100644 --- a/cmdline/status.c +++ b/cmdline/status.c @@ -68,7 +68,6 @@ int state_status(struct snapraid_state* state) uint64_t file_size; uint64_t file_block_count; uint64_t file_block_free; - uint64_t base = 1024 * 1024 * 1024ULL; block_off_t parity_block_free; unsigned unsynced_blocks; uint64_t all_wasted; @@ -100,7 +99,7 @@ int state_status(struct snapraid_state* state) printf("SnapRAID status report:\n"); printf("\n"); printf(" Files Fragmented Excess Wasted Used Free Use Name\n"); - printf(" Files Fragments GiB GiB GiB \n"); + printf(" Files Fragments GB GB GB\n"); /* count fragments */ file_count = 0; @@ -200,17 +199,17 @@ int state_status(struct snapraid_state* state) printf("%8u", disk_file_count); printf("%8u", disk_file_fragmented); printf("%8u", disk_extra_fragment); - if (wasted < -100LL * 1024 * 1024 * 1024) { + if (wasted < -100LL * GIGA) { printf(" -"); } else if (wasted < 0) { char buffer[32]; - snprintf(buffer, sizeof(buffer), "-%" PRId64 ".%01" PRIu64, -wasted / base, (-wasted * 10 / base) % 10); + snprintf(buffer, sizeof(buffer), "-%" PRId64 ".%01" PRIu64, -wasted / GIGA, (-wasted * 10 / GIGA) % 10); printf("%8s", buffer); } else { - printf("%6" PRIu64 ".%01" PRIu64, wasted / base, (wasted * 10 / base) % 10); + printf("%6" PRIu64 ".%01" PRIu64, wasted / GIGA, (wasted * 10 / GIGA) % 10); } - printf("%8" PRIu64, disk_file_size / base); - printf("%8" PRIu64, (disk_block_max - disk_block_count) * (uint64_t)state->block_size / base); + printf("%8" PRIu64, disk_file_size / GIGA); + printf("%8" PRIu64, (disk_block_max - disk_block_count) * (uint64_t)state->block_size / GIGA); printf(" %3u%%", perc(disk_block_count, disk_block_max)); printf(" %s\n", disk->name); @@ -233,9 +232,9 @@ int state_status(struct snapraid_state* state) printf("%8u", file_count); printf("%8u", file_fragmented); printf("%8u", extra_fragment); - printf("%6" PRIu64 ".%01" PRIu64, all_wasted / base, (all_wasted * 10 / base) % 10); - printf("%8" PRIu64, file_size / base); - printf("%8" PRIu64, file_block_free * state->block_size / base); + printf("%6" PRIu64 ".%01" PRIu64, all_wasted / GIGA, (all_wasted * 10 / GIGA) % 10); + printf("%8" PRIu64, file_size / GIGA); + printf("%8" PRIu64, file_block_free * state->block_size / GIGA); printf(" %3u%%", perc(file_block_count, file_block_count + file_block_free)); printf("\n");