Blame SOURCES/0560-journal-only-check-available-space-when-journal-is-o.patch

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