teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

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

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