]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: Ratelimit more log messages 25633/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 5 Dec 2022 13:30:44 +0000 (14:30 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 5 Dec 2022 13:41:53 +0000 (14:41 +0100)
Followup for 8522691d4da.

src/libsystemd/sd-journal/journal-file.c
src/libsystemd/sd-journal/journal-vacuum.c

index 6fcd1fac07a0b344b08454761d3d914f62874591..507958dabdd5be142e5e8f01a890778e4911ec13 100644 (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;
         }
 
index eac35002023a1f379798227b304d604110d5b7d9..7b5e0fa65fa0ade51eedbef4fd064f0490534433 100644 (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))