From: Joel Rosdahl Date: Thu, 4 Jan 2018 21:55:58 +0000 (+0100) Subject: cleanup: Improve logging X-Git-Tag: v3.3.5~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e53191d60e6d6bf90fac4753152b10ef4386938d;p=thirdparty%2Fccache.git cleanup: Improve logging --- diff --git a/cleanup.c b/cleanup.c index 428a64b52..f6f363f1f 100644 --- a/cleanup.c +++ b/cleanup.c @@ -1,5 +1,5 @@ // Copyright (C) 2002-2006 Andrew Tridgell -// Copyright (C) 2009-2016 Joel Rosdahl +// Copyright (C) 2009-2018 Joel Rosdahl // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free @@ -194,6 +194,9 @@ cleanup_dir(struct conf *conf, const char *dir) stats_add_cleanup(dir, 1); } + cc_log("After cleanup: %lu KiB, %zu files", + (unsigned long)cache_size / 1024, + files_in_cache); stats_set_sizes(dir, files_in_cache, cache_size); // Free it up. diff --git a/stats.c b/stats.c index 5d9fc7378..4576c3c51 100644 --- a/stats.c +++ b/stats.c @@ -1,5 +1,5 @@ // Copyright (C) 2002-2004 Andrew Tridgell -// Copyright (C) 2009-2016 Joel Rosdahl +// Copyright (C) 2009-2018 Joel Rosdahl // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free @@ -374,22 +374,31 @@ stats_flush(void) } } + char *subdir = dirname(stats_file); bool need_cleanup = false; + if (conf->max_files != 0 && counters->data[STATS_NUMFILES] > conf->max_files / 16) { + cc_log("Need to clean up %s since it holds %u files (limit: %u files)", + subdir, + counters->data[STATS_NUMFILES], + conf->max_files / 16); need_cleanup = true; } if (conf->max_size != 0 && counters->data[STATS_TOTALSIZE] > conf->max_size / 1024 / 16) { + cc_log("Need to clean up %s since it holds %u KiB (limit: %lu KiB)", + subdir, + counters->data[STATS_TOTALSIZE], + (unsigned long)conf->max_size / 1024 / 16); need_cleanup = true; } if (need_cleanup) { - char *p = dirname(stats_file); - cleanup_dir(conf, p); - free(p); + cleanup_dir(conf, subdir); } + free(subdir); counters_free(counters); }