From d301e315ac6bee3483c502c3b3c5cc1cc0c60c16 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sun, 13 Dec 2015 19:58:35 +0100 Subject: [PATCH] timeshift: more log cleanups, fix the wrong total updates --- src/timeshift/private.h | 6 ++++++ src/timeshift/timeshift_filemgr.c | 15 +++++++-------- src/timeshift/timeshift_writer.c | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/timeshift/private.h b/src/timeshift/private.h index 5f193fbc0..b112b060e 100644 --- a/src/timeshift/private.h +++ b/src/timeshift/private.h @@ -118,6 +118,12 @@ typedef struct timeshift { } timeshift_t; +/* + * + */ +extern uint64_t timeshift_total_size; +extern uint64_t timeshift_total_ram_size; + /* * Write functions */ diff --git a/src/timeshift/timeshift_filemgr.c b/src/timeshift/timeshift_filemgr.c index 48fc358db..db0d8b0d2 100644 --- a/src/timeshift/timeshift_filemgr.c +++ b/src/timeshift/timeshift_filemgr.c @@ -75,7 +75,7 @@ static void* timeshift_reaper_callback ( void *p ) tvhlog(LOG_ERR, "timeshift", "failed to remove %s [e=%s]", dpath, strerror(errno)); } else { - tvhtrace("timeshift", "remove RAM segment (time %li)", (long)tsf->time); + tvhtrace("timeshift", "remove RAM segment (time %"PRItime_t", size %"PRId64")", tsf->time, (int64_t)tsf->size); } /* Free memory */ @@ -152,8 +152,7 @@ int timeshift_filemgr_makedirs ( int index, char *buf, size_t len ) void timeshift_filemgr_close ( timeshift_file_t *tsf ) { ssize_t r = timeshift_write_eof(tsf); - if (r > 0) - { + if (r > 0) { tsf->size += r; atomic_add_u64(×hift_total_size, r); if (tsf->ram) @@ -175,9 +174,9 @@ void timeshift_filemgr_remove assert(tsf->rfd < 0); if (tvhtrace_enabled()) { if (tsf->path) - tvhdebug("timeshift", "ts %d remove %s", ts->id, tsf->path); + tvhdebug("timeshift", "ts %d remove %s (size %"PRId64")", ts->id, tsf->path, (int64_t)tsf->size); else - tvhdebug("timeshift", "ts %d RAM segment remove time %li", ts->id, (long)tsf->time); + tvhdebug("timeshift", "ts %d RAM segment remove time %"PRItime_t" (size %"PRId64", alloc size %"PRId64")", ts->id, tsf->time, (int64_t)tsf->size, (int64_t)tsf->ram_size); } TAILQ_REMOVE(&ts->files, tsf, link); atomic_dec_u64(×hift_total_size, tsf->size); @@ -297,8 +296,8 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int create ) free(tsf_tmp); tsf_tmp = NULL; } else { - tvhtrace("timeshift", "ts %d create RAM segment with %"PRId64" bytes (time %li)", - ts->id, tsf_tmp->ram_size, (long)time); + tvhtrace("timeshift", "ts %d create RAM segment with %"PRId64" bytes (time %"PRItime_t")", + ts->id, tsf_tmp->ram_size, time); } } @@ -402,7 +401,7 @@ void timeshift_filemgr_init ( void ) /* Size processing */ timeshift_total_size = 0; - timeshift_conf.ram_size = 0; + timeshift_conf.ram_size = 0; /* Start the reaper thread */ timeshift_reaper_run = 1; diff --git a/src/timeshift/timeshift_writer.c b/src/timeshift/timeshift_writer.c index ee611ad70..b27fe5143 100644 --- a/src/timeshift/timeshift_writer.c +++ b/src/timeshift/timeshift_writer.c @@ -275,9 +275,9 @@ static inline ssize_t _process_msg0 if (err > 0) { tsf->last = sm->sm_time; tsf->size += err; - atomic_add_u64(×hift_conf.total_size, err); + atomic_add_u64(×hift_total_size, err); if (tsf->ram) - atomic_add_u64(×hift_conf.total_ram_size, err); + atomic_add_u64(×hift_total_ram_size, err); } return err; } -- 2.47.3