From 71355c563bafb46877e537dd49db3050cbb2d960 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 28 Dec 2014 18:28:44 +0100 Subject: [PATCH 1/4] In scrub don't check the inode to verify if the file is synced. On filesystem without persistent inode, they can be different from one run to another. In sync they are automatically adjusted, but not in scrub. --- cmdline/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmdline/scrub.c b/cmdline/scrub.c index b6e4b0ec..7f3480ba 100644 --- a/cmdline/scrub.c +++ b/cmdline/scrub.c @@ -289,7 +289,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par if (handle[j].st.st_size != block_file_get(block)->size || handle[j].st.st_mtime != block_file_get(block)->mtime_sec || STAT_NSEC(&handle[j].st) != block_file_get(block)->mtime_nsec - || handle[j].st.st_ino != block_file_get(block)->inode + /* don't check the inode to support filesystem without persistent inodes */ ) { /* report that the block and the file are not synced */ block_is_unsynced = 1; From 745c51e8e5e73bf1ae2b79611f8d56bd1c8f97b3 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 31 Dec 2014 09:08:36 +0100 Subject: [PATCH 2/4] Uses a better message for the Low Memory condition. --- cmdline/util.c | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/cmdline/util.c b/cmdline/util.c index 15708a84..0d924daa 100644 --- a/cmdline/util.c +++ b/cmdline/util.c @@ -1437,14 +1437,21 @@ size_t malloc_counter(void) return mcounter; } -static int malloc_printn(int f, size_t value) +static ssize_t malloc_print(int f, const char* str) +{ + ssize_t len = 0; + while (str[len]) + ++len; + return write(f, str, len); +} + +static ssize_t malloc_printn(int f, size_t value) { char buf[32]; int i; - if (!value) { + if (!value) return write(f, "0", 1); - } i = sizeof(buf); while (value) { @@ -1461,20 +1468,17 @@ static void malloc_fail(size_t size) /* LCOV_EXCL_START */ int f = 2; /* stderr */ - if (write(f, "Low Memory\n", 11) < 0) - return; - if (write(f, "Allocating ", 11) < 0) - return; - if (malloc_printn(f, size) < 0) - return; - if (write(f, " bytes\n", 7) < 0) - return; - if (write(f, "Allocated ", 10) < 0) - return; - if (malloc_printn(f, malloc_counter()) < 0) - return; - if (write(f, " bytes\n", 7) < 0) - return; + malloc_print(f, "Failed for Low Memory!\n"); + malloc_print(f, "Allocating "); + malloc_printn(f, size); + malloc_print(f, " bytes.\n"); + malloc_print(f, "Already allocated "); + malloc_printn(f, malloc_counter()); + malloc_print(f, " bytes.\n"); + if (sizeof(void*) == 4) { + malloc_print(f, "You are currently using a 32 bits executable.\n"); + malloc_print(f, "If you have more than 4GB of memory, please upgrade to a 64 bits one.\n"); + } /* LCOV_EXCL_STOP */ } @@ -1558,10 +1562,7 @@ void* malloc_nofail_align(size_t size, void** freeptr) if (!ptr) { /* LCOV_EXCL_START */ - /* don't use printf to avoid any possible extra allocation */ - if (write(2, "Low Memory\n", 11) != 11) { - /* ignore error */ - } + malloc_fail(size); exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ } @@ -1577,10 +1578,7 @@ void** malloc_nofail_vector_align(int nd, int n, size_t size, void** freeptr) if (!ptr) { /* LCOV_EXCL_START */ - /* don't use printf to avoid any possible extra allocation */ - if (write(2, "Low Memory\n", 11) != 11) { - /* ignore error */ - } + malloc_fail(n * size); exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ } @@ -1593,7 +1591,7 @@ void mtest_vector(int n, size_t size, void** vv) if (raid_mtest_vector(n, size, vv) != 0) { /* LCOV_EXCL_START */ fprintf(stderr, "DANGER! Your RAM memory is broken! DO NOT PROCEED UNTIL FIXED!\n"); - fprintf(stderr, "Try running some memory test like http://www.memtest86.com/\n"); + fprintf(stderr, "Try running a memory test like http://www.memtest86.com/\n"); exit(EXIT_FAILURE); /* LCOV_EXCL_STOP */ } From 765c9bf73a823ae0288bbb7d240592746d770c88 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 1 Jan 2015 10:28:00 +0100 Subject: [PATCH 3/4] Updates to TommyDS 2.0. --- tommyds/tommyhashdyn.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tommyds/tommyhashdyn.c b/tommyds/tommyhashdyn.c index 8aa3e53a..02ef4049 100644 --- a/tommyds/tommyhashdyn.c +++ b/tommyds/tommyhashdyn.c @@ -84,11 +84,11 @@ static void tommy_hashdyn_resize(tommy_hashdyn* hashdyn, tommy_count_t new_bucke j = hashdyn->bucket[i]; while (j) { tommy_hashdyn_node* j_next = j->next; - tommy_count_t index = j->key & new_bucket_mask; - if (new_bucket[index]) - tommy_list_insert_tail_not_empty(new_bucket[index], j); + tommy_count_t pos = j->key & new_bucket_mask; + if (new_bucket[pos]) + tommy_list_insert_tail_not_empty(new_bucket[pos], j); else - tommy_list_insert_first(&new_bucket[index], j); + tommy_list_insert_first(&new_bucket[pos], j); j = j_next; } } From 7df9d2772cc4b29602f4756887d9829b4111e194 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 6 Jan 2015 22:28:38 +0100 Subject: [PATCH 4/4] Adds the elapsed time in seconds in the -G progress output. --- cmdline/state.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmdline/state.c b/cmdline/state.c index eac77fdc..8cccef40 100644 --- a/cmdline/state.c +++ b/cmdline/state.c @@ -4693,6 +4693,7 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off ) { uint64_t tick_total; uint64_t tick_cpu; + time_t elapsed; unsigned out_perc = 0; unsigned out_speed = 0; unsigned out_cpu = 0; @@ -4700,6 +4701,7 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off tick_total = state->tick_cpu + state->tick_io; tick_cpu = state->tick_cpu; + elapsed = now - state->progress_whole_start - state->progress_wasted; /* completion percentage */ if (countmax) @@ -4757,7 +4759,7 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off } if (state->opt.gui) { - fprintf(stdlog, "run:pos:%u:%u:%" PRIu64 ":%u:%u:%u:%u\n", blockpos, countpos, countsize, out_perc, out_eta, out_speed, out_cpu); + fprintf(stdlog, "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); fflush(stdlog); } else { printf("%u%%, %u MiB", out_perc, (unsigned)(countsize / (1024 * 1024)));