1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-02-12 21:57:27 +03:00

journal: Stop trying to open runtime journal once flushed

Once we've flushed the runtime journal to /var, stop trying to open
it since that will just fail with ENOENT all the time.

(cherry picked from commit 418a4987775280adef4e6ac4e474937ea89f0f5c)
(cherry picked from commit 01469405c7b9ef175a16c89c4a518798d2c8f65d)
This commit is contained in:
Daan De Meyer 2023-09-26 15:59:23 +02:00 committed by Luca Boccassi
parent a678987634
commit ce0e97e3a8

View File

@ -391,8 +391,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 */
@ -411,25 +429,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) {