]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: Stop trying to open runtime journal once flushed
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 26 Sep 2023 13:59:23 +0000 (15:59 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 26 Sep 2023 18:01:07 +0000 (19:01 +0100)
Once we've flushed the runtime journal to /var, stop trying to open
it since that will just fail with ENOENT all the time.

src/journal/journald-server.c

index 897e2abd3a2f540b0115f2e99e4af51c8c48f16e..b6f494b4ce372a5af991a9d7c6e6eacd6fa4ee46 100644 (file)
@@ -384,8 +384,26 @@ static int server_system_journal_open(
 
                 fn = strjoina(s->runtime_storage.path, "/system.journal");
 
-                if (s->system_journal && !relinquish_requested) {
+                if (!s->system_journal || relinquish_requested) {
 
+                        /* OK, we really need the runtime journal, so create it if necessary. */
+
+                        (void) mkdir_parents(s->runtime_storage.path, 0755);
+                        (void) mkdir(s->runtime_storage.path, 0750);
+
+                        r = server_open_journal(
+                                        s,
+                                        /* reliably= */ true,
+                                        fn,
+                                        O_RDWR|O_CREAT,
+                                        /* seal= */ false,
+                                        &s->runtime_storage.metrics,
+                                        &s->runtime_journal);
+                        if (r < 0)
+                                return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
+                                                                   "Failed to open runtime journal: %m");
+
+                } else if (!server_flushed_flag_is_set(s)) {
                         /* Try to open the runtime journal, but only if it already exists, so that we can
                          * flush it into the system journal */
 
@@ -404,25 +422,6 @@ static int server_system_journal_open(
 
                                 r = 0;
                         }
-
-                } else {
-
-                        /* OK, we really need the runtime journal, so create it if necessary. */
-
-                        (void) mkdir_parents(s->runtime_storage.path, 0755);
-                        (void) mkdir(s->runtime_storage.path, 0750);
-
-                        r = server_open_journal(
-                                        s,
-                                        /* reliably= */ true,
-                                        fn,
-                                        O_RDWR|O_CREAT,
-                                        /* seal= */ false,
-                                        &s->runtime_storage.metrics,
-                                        &s->runtime_journal);
-                        if (r < 0)
-                                return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
-                                                                   "Failed to open runtime journal: %m");
                 }
 
                 if (s->runtime_journal) {