Compare commits

...

4 commits
master ... v7.1

Author SHA1 Message Date
Andrea Mazzoleni
7df9d2772c Adds the elapsed time in seconds in the -G progress output. 2015-01-06 22:28:38 +01:00
Andrea Mazzoleni
765c9bf73a Updates to TommyDS 2.0. 2015-01-01 10:28:00 +01:00
Andrea Mazzoleni
745c51e8e5 Uses a better message for the Low Memory condition. 2014-12-31 09:08:36 +01:00
Andrea Mazzoleni
71355c563b 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.
2014-12-28 18:28:44 +01:00
4 changed files with 32 additions and 32 deletions

View file

@ -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 if (handle[j].st.st_size != block_file_get(block)->size
|| handle[j].st.st_mtime != block_file_get(block)->mtime_sec || handle[j].st.st_mtime != block_file_get(block)->mtime_sec
|| STAT_NSEC(&handle[j].st) != block_file_get(block)->mtime_nsec || 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 */ /* report that the block and the file are not synced */
block_is_unsynced = 1; block_is_unsynced = 1;

View file

@ -4693,6 +4693,7 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
) { ) {
uint64_t tick_total; uint64_t tick_total;
uint64_t tick_cpu; uint64_t tick_cpu;
time_t elapsed;
unsigned out_perc = 0; unsigned out_perc = 0;
unsigned out_speed = 0; unsigned out_speed = 0;
unsigned out_cpu = 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_total = state->tick_cpu + state->tick_io;
tick_cpu = state->tick_cpu; tick_cpu = state->tick_cpu;
elapsed = now - state->progress_whole_start - state->progress_wasted;
/* completion percentage */ /* completion percentage */
if (countmax) if (countmax)
@ -4757,7 +4759,7 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
} }
if (state->opt.gui) { 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); fflush(stdlog);
} else { } else {
printf("%u%%, %u MiB", out_perc, (unsigned)(countsize / (1024 * 1024))); printf("%u%%, %u MiB", out_perc, (unsigned)(countsize / (1024 * 1024)));

View file

@ -1437,14 +1437,21 @@ size_t malloc_counter(void)
return mcounter; 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]; char buf[32];
int i; int i;
if (!value) { if (!value)
return write(f, "0", 1); return write(f, "0", 1);
}
i = sizeof(buf); i = sizeof(buf);
while (value) { while (value) {
@ -1461,20 +1468,17 @@ static void malloc_fail(size_t size)
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
int f = 2; /* stderr */ int f = 2; /* stderr */
if (write(f, "Low Memory\n", 11) < 0) malloc_print(f, "Failed for Low Memory!\n");
return; malloc_print(f, "Allocating ");
if (write(f, "Allocating ", 11) < 0) malloc_printn(f, size);
return; malloc_print(f, " bytes.\n");
if (malloc_printn(f, size) < 0) malloc_print(f, "Already allocated ");
return; malloc_printn(f, malloc_counter());
if (write(f, " bytes\n", 7) < 0) malloc_print(f, " bytes.\n");
return; if (sizeof(void*) == 4) {
if (write(f, "Allocated ", 10) < 0) malloc_print(f, "You are currently using a 32 bits executable.\n");
return; malloc_print(f, "If you have more than 4GB of memory, please upgrade to a 64 bits one.\n");
if (malloc_printn(f, malloc_counter()) < 0) }
return;
if (write(f, " bytes\n", 7) < 0)
return;
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
@ -1558,10 +1562,7 @@ void* malloc_nofail_align(size_t size, void** freeptr)
if (!ptr) { if (!ptr) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
/* don't use printf to avoid any possible extra allocation */ malloc_fail(size);
if (write(2, "Low Memory\n", 11) != 11) {
/* ignore error */
}
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
@ -1577,10 +1578,7 @@ void** malloc_nofail_vector_align(int nd, int n, size_t size, void** freeptr)
if (!ptr) { if (!ptr) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
/* don't use printf to avoid any possible extra allocation */ malloc_fail(n * size);
if (write(2, "Low Memory\n", 11) != 11) {
/* ignore error */
}
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* 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) { if (raid_mtest_vector(n, size, vv) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
fprintf(stderr, "DANGER! Your RAM memory is broken! DO NOT PROCEED UNTIL FIXED!\n"); 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); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }

View file

@ -84,11 +84,11 @@ static void tommy_hashdyn_resize(tommy_hashdyn* hashdyn, tommy_count_t new_bucke
j = hashdyn->bucket[i]; j = hashdyn->bucket[i];
while (j) { while (j) {
tommy_hashdyn_node* j_next = j->next; tommy_hashdyn_node* j_next = j->next;
tommy_count_t index = j->key & new_bucket_mask; tommy_count_t pos = j->key & new_bucket_mask;
if (new_bucket[index]) if (new_bucket[pos])
tommy_list_insert_tail_not_empty(new_bucket[index], j); tommy_list_insert_tail_not_empty(new_bucket[pos], j);
else else
tommy_list_insert_first(&new_bucket[index], j); tommy_list_insert_first(&new_bucket[pos], j);
j = j_next; j = j_next;
} }
} }