Skip to content

Commit ce0e97e

Browse files
DaanDeMeyerbluca
authored andcommitted
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 418a498) (cherry picked from commit 0146940)
1 parent a678987 commit ce0e97e

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

src/journal/journald-server.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,26 @@ static int server_system_journal_open(
391391

392392
fn = strjoina(s->runtime_storage.path, "/system.journal");
393393

394-
if (s->system_journal && !relinquish_requested) {
394+
if (!s->system_journal || relinquish_requested) {
395395

396+
/* OK, we really need the runtime journal, so create it if necessary. */
397+
398+
(void) mkdir_parents(s->runtime_storage.path, 0755);
399+
(void) mkdir(s->runtime_storage.path, 0750);
400+
401+
r = server_open_journal(
402+
s,
403+
/* reliably= */ true,
404+
fn,
405+
O_RDWR|O_CREAT,
406+
/* seal= */ false,
407+
&s->runtime_storage.metrics,
408+
&s->runtime_journal);
409+
if (r < 0)
410+
return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
411+
"Failed to open runtime journal: %m");
412+
413+
} else if (!server_flushed_flag_is_set(s)) {
396414
/* Try to open the runtime journal, but only if it already exists, so that we can
397415
* flush it into the system journal */
398416

@@ -411,25 +429,6 @@ static int server_system_journal_open(
411429

412430
r = 0;
413431
}
414-
415-
} else {
416-
417-
/* OK, we really need the runtime journal, so create it if necessary. */
418-
419-
(void) mkdir_parents(s->runtime_storage.path, 0755);
420-
(void) mkdir(s->runtime_storage.path, 0750);
421-
422-
r = server_open_journal(
423-
s,
424-
/* reliably= */ true,
425-
fn,
426-
O_RDWR|O_CREAT,
427-
/* seal= */ false,
428-
&s->runtime_storage.metrics,
429-
&s->runtime_journal);
430-
if (r < 0)
431-
return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
432-
"Failed to open runtime journal: %m");
433432
}
434433

435434
if (s->runtime_journal) {

0 commit comments

Comments
 (0)