automatic logrotate on huge logfiles

This commit is contained in:
Thomas Schoebel-Theuer 2012-02-28 12:02:35 +01:00 committed by Thomas Schoebel-Theuer
parent baf5ea99da
commit e058dc18e0
2 changed files with 23 additions and 0 deletions

11
Kconfig
View File

@ -130,6 +130,17 @@ config MARS_LOGROT
---help---
Normally ON. Switch off only for EXPERIMENTS!
config MARS_LOGROT_AUTO
int "automatic logrotate when logfile exceeds size (in GB)"
depends on MARS_LOGROT
default 64
---help---
You could switch this off by setting to 0. However, deletion
of really huge logfile can take several minutes, or even substantial
fractions of hours (depending on the underlying filesystem).
Thus it is highly recommended to limit the logfile size to some
reasonable maximum size. Switch only off for experiments!
config MARS_MIN_SPACE
bool "check for filesystem overflow in /mars"
depends on MARS

View File

@ -1745,6 +1745,18 @@ int make_log_init(void *buf, struct mars_dent *dent)
}
MARS_DBG("logfile '%s' size = %lld\n", aio_path, rot->aio_info.current_size);
#if defined(CONFIG_MARS_LOGROT_AUTO) && CONFIG_MARS_LOGROT_AUTO > 0
if (rot->is_primary &&
unlikely(rot->aio_info.current_size >= (loff_t)CONFIG_MARS_LOGROT_AUTO * 1024 * 1024 * 1024)) {
char *new_path = path_make("%s/log-%09d-%s", parent_path, aio_dent->d_serial + 1, my_id());
if (likely(new_path && !mars_find_dent(global, new_path))) {
MARS_INF("old logfile size = %lld, creating new logfile '%s'\n", rot->aio_info.current_size, new_path);
_create_new_logfile(new_path);
}
brick_string_free(new_path);
}
#endif
// check whether attach is allowed
switch_path = path_make("%s/todo-%s/attach", parent_path, my_id());