From 0265885a39282cf9aa34cf1647cf9b260f9f41cc Mon Sep 17 00:00:00 2001 From: Ban Siesta Date: Sun, 4 Jan 2015 19:13:27 +0000 Subject: sdlog2: check every 20MiB if we're running out of space, moved the threshold to 50MiB --- src/modules/sdlog2/sdlog2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/modules/sdlog2') diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c index 1bf7d7198..31cdff306 100644 --- a/src/modules/sdlog2/sdlog2.c +++ b/src/modules/sdlog2/sdlog2.c @@ -178,6 +178,7 @@ static char log_dir[32]; /* statistics counters */ static uint64_t start_time = 0; static unsigned long log_bytes_written = 0; +static unsigned long last_checked_bytes_written = 0; static unsigned long log_msgs_written = 0; static unsigned long log_msgs_skipped = 0; @@ -604,11 +605,15 @@ static void *logwriter_thread(void *arg) fsync(log_fd); poll_count = 0; + } + + if (log_bytes_written - last_checked_bytes_written > 20*1024*1024) { /* check if space is available, if not stop everything */ if (check_free_space() != OK) { logwriter_should_exit = true; main_thread_should_exit = true; } + last_checked_bytes_written = log_bytes_written; } } @@ -1858,8 +1863,8 @@ int check_free_space() errx(ERROR, "ERR: statfs"); } - /* use a threshold of 10 MiB */ - if (statfs_buf.f_bavail < (int)(10 * 1024 * 1024 / statfs_buf.f_bsize)) { + /* use a threshold of 50 MiB */ + if (statfs_buf.f_bavail < (int)(50 * 1024 * 1024 / statfs_buf.f_bsize)) { mavlink_and_console_log_critical(mavlink_fd, "[sdlog2] no space on MicroSD: %u MiB", (unsigned int)(statfs_buf.f_bavail * statfs_buf.f_bsize) / (1024U * 1024U)); -- cgit v1.2.3