1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-13 13:17:43 +03:00

journal: Ratelimit more log messages

Followup for 8522691d4d.
This commit is contained in:
Daan De Meyer 2022-12-05 14:30:44 +01:00
parent d9799ea2e2
commit 04cb8ee880
2 changed files with 16 additions and 8 deletions

View File

@ -3583,22 +3583,24 @@ static int journal_file_warn_btrfs(JournalFile *f) {
r = fd_is_fs_type(f->fd, BTRFS_SUPER_MAGIC);
if (r < 0)
return log_warning_errno(r, "Failed to determine if journal is on btrfs: %m");
return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT, "Failed to determine if journal is on btrfs: %m");
if (!r)
return 0;
r = read_attr_fd(f->fd, &attrs);
if (r < 0)
return log_warning_errno(r, "Failed to read file attributes: %m");
return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT, "Failed to read file attributes: %m");
if (attrs & FS_NOCOW_FL) {
log_debug("Detected btrfs file system with copy-on-write disabled, all is good.");
return 0;
}
log_notice("Creating journal file %s on a btrfs file system, and copy-on-write is enabled. "
"This is likely to slow down journal access substantially, please consider turning "
"off the copy-on-write file attribute on the journal directory, using chattr +C.", f->path);
log_ratelimit_notice(JOURNAL_LOG_RATELIMIT,
"Creating journal file %s on a btrfs file system, and copy-on-write is enabled. "
"This is likely to slow down journal access substantially, please consider turning "
"off the copy-on-write file attribute on the journal directory, using chattr +C.",
f->path);
return 1;
}
@ -4169,7 +4171,8 @@ bool journal_file_rotate_suggested(JournalFile *f, usec_t max_file_usec, int log
/* If we gained new header fields we gained new features,
* hence suggest a rotation */
if (le64toh(f->header->header_size) < sizeof(Header)) {
log_full(log_level, "%s uses an outdated header, suggesting rotation.", f->path);
log_ratelimit_full(log_level, JOURNAL_LOG_RATELIMIT,
"%s uses an outdated header, suggesting rotation.", f->path);
return true;
}

View File

@ -13,6 +13,7 @@
#include "fs-util.h"
#include "journal-def.h"
#include "journal-file.h"
#include "journal-internal.h"
#include "journal-vacuum.h"
#include "sort-util.h"
#include "string-util.h"
@ -251,7 +252,9 @@ int journal_directory_vacuum(
freed += size;
} else if (r != -ENOENT)
log_warning_errno(r, "Failed to delete empty archived journal %s/%s: %m", directory, p);
log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to delete empty archived journal %s/%s: %m",
directory, p);
continue;
}
@ -299,7 +302,9 @@ int journal_directory_vacuum(
sum = 0;
} else if (r != -ENOENT)
log_warning_errno(r, "Failed to delete archived journal %s/%s: %m", directory, list[i].filename);
log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to delete archived journal %s/%s: %m",
directory, list[i].filename);
}
if (oldest_usec && i < n_list && (*oldest_usec == 0 || list[i].realtime < *oldest_usec))