richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
dd65c9
From 3511688b336ee36f200d2ade5e3bdc01de9c503e Mon Sep 17 00:00:00 2001
dd65c9
From: Jan Synacek <jsynacek@redhat.com>
dd65c9
Date: Mon, 9 Oct 2017 12:47:21 +0200
dd65c9
Subject: [PATCH] journal: only check available space when journal is open
dd65c9
dd65c9
RHEL-only
dd65c9
dd65c9
Related: #1493846
dd65c9
---
dd65c9
 src/journal/journald-server.c | 17 ++++++++++-------
dd65c9
 1 file changed, 10 insertions(+), 7 deletions(-)
dd65c9
dd65c9
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
dd65c9
index 96e7d6156..f6f8c30eb 100644
dd65c9
--- a/src/journal/journald-server.c
dd65c9
+++ b/src/journal/journald-server.c
dd65c9
@@ -253,12 +253,12 @@ static int system_journal_open(Server *s, bool flush_requested) {
dd65c9
         if (r < 0)
dd65c9
                 return log_error_errno(r, "Failed to get machine id: %m");
dd65c9
 
dd65c9
-        sd_id128_to_string(machine, ids);
dd65c9
-
dd65c9
         if (!s->system_journal &&
dd65c9
             IN_SET(s->storage, STORAGE_PERSISTENT, STORAGE_AUTO) &&
dd65c9
             (flush_requested || flushed_flag_is_set())) {
dd65c9
 
dd65c9
+                sd_id128_to_string(machine, ids);
dd65c9
+
dd65c9
                 /* If in auto mode: first try to create the machine
dd65c9
                  * path, but not the prefix.
dd65c9
                  *
dd65c9
@@ -274,9 +274,10 @@ static int system_journal_open(Server *s, bool flush_requested) {
dd65c9
                 fn = strjoina(fn, "/system.journal");
dd65c9
                 r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, NULL, &s->system_journal);
dd65c9
 
dd65c9
-                if (r >= 0)
dd65c9
+                if (r >= 0) {
dd65c9
                         server_fix_perms(s, s->system_journal, 0);
dd65c9
-                else if (r < 0) {
dd65c9
+                        available_space(s, true);
dd65c9
+                } else if (r < 0) {
dd65c9
                         if (r != -ENOENT && r != -EROFS)
dd65c9
                                 log_warning_errno(r, "Failed to open system journal: %m");
dd65c9
 
dd65c9
@@ -297,6 +298,8 @@ static int system_journal_open(Server *s, bool flush_requested) {
dd65c9
         if (!s->runtime_journal &&
dd65c9
             (s->storage != STORAGE_NONE)) {
dd65c9
 
dd65c9
+                sd_id128_to_string(machine, ids);
dd65c9
+
dd65c9
                 fn = strjoin("/run/log/journal/", ids, "/system.journal", NULL);
dd65c9
                 if (!fn)
dd65c9
                         return -ENOMEM;
dd65c9
@@ -333,12 +336,12 @@ static int system_journal_open(Server *s, bool flush_requested) {
dd65c9
                                 return log_error_errno(r, "Failed to open runtime journal: %m");
dd65c9
                 }
dd65c9
 
dd65c9
-                if (s->runtime_journal)
dd65c9
+                if (s->runtime_journal) {
dd65c9
                         server_fix_perms(s, s->runtime_journal, 0);
dd65c9
+                        available_space(s, true);
dd65c9
+                }
dd65c9
         }
dd65c9
 
dd65c9
-        available_space(s, true);
dd65c9
-
dd65c9
         return r;
dd65c9
 }
dd65c9