Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
timeshift: more log cleanups, fix the wrong total updates
  • Loading branch information
perexg committed Dec 13, 2015
1 parent 66e5d27 commit d301e31
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/timeshift/private.h
Expand Up @@ -118,6 +118,12 @@ typedef struct timeshift {

} timeshift_t;

/*
*
*/
extern uint64_t timeshift_total_size;
extern uint64_t timeshift_total_ram_size;

/*
* Write functions
*/
Expand Down
15 changes: 7 additions & 8 deletions src/timeshift/timeshift_filemgr.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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(&timeshift_total_size, r);
if (tsf->ram)
Expand All @@ -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(&timeshift_total_size, tsf->size);
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/timeshift/timeshift_writer.c
Expand Up @@ -275,9 +275,9 @@ static inline ssize_t _process_msg0
if (err > 0) {
tsf->last = sm->sm_time;
tsf->size += err;
atomic_add_u64(&timeshift_conf.total_size, err);
atomic_add_u64(&timeshift_total_size, err);
if (tsf->ram)
atomic_add_u64(&timeshift_conf.total_ram_size, err);
atomic_add_u64(&timeshift_total_ram_size, err);
}
return err;
}
Expand Down

2 comments on commit d301e31

@ksooo
Copy link
Contributor

@ksooo ksooo commented on d301e31 Dec 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please backport this to 4.0.x?

@perexg
Copy link
Contributor Author

@perexg perexg commented on d301e31 Dec 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug is not in 4.0.x.

Please sign in to comment.