dcavalca / rpms / systemd

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