Skip to content

Commit 0146940

Browse files
DaanDeMeyerkeszybz
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)
1 parent 3cc2aa3 commit 0146940

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
@@ -384,8 +384,26 @@ static int server_system_journal_open(
384384

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

387-
if (s->system_journal && !relinquish_requested) {
387+
if (!s->system_journal || relinquish_requested) {
388388

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

@@ -404,25 +422,6 @@ static int server_system_journal_open(
404422

405423
r = 0;
406424
}
407-
408-
} else {
409-
410-
/* OK, we really need the runtime journal, so create it if necessary. */
411-
412-
(void) mkdir_parents(s->runtime_storage.path, 0755);
413-
(void) mkdir(s->runtime_storage.path, 0750);
414-
415-
r = server_open_journal(
416-
s,
417-
/* reliably= */ true,
418-
fn,
419-
O_RDWR|O_CREAT,
420-
/* seal= */ false,
421-
&s->runtime_storage.metrics,
422-
&s->runtime_journal);
423-
if (r < 0)
424-
return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
425-
"Failed to open runtime journal: %m");
426425
}
427426

428427
if (s->runtime_journal) {

0 commit comments

Comments
 (0)