summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-13 23:32:14 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-13 23:35:12 -0400
commite40ec7aec5e64cd0cfa5fc556d6a9747229b5794 (patch)
treedc0d5ff693d8de783c66f6b91854a6cd73c30242
parent6e5abe1564070a760196b97031eca9cf5e95e8a2 (diff)
journald: do not calculate free space too early
Since the system journal wasn't open yet, available_space() returned 0. Before: systemd-journal[22170]: Allowing system journal files to grow to 4.0G. systemd-journal[22170]: Journal size currently limited to 0B due to SystemKeepFree. After: systemd-journal[22178]: Allowing system journal files to grow to 4.0G. systemd-journal[22178]: Journal size currently limited to 3.0G due to SystemKeepFree. Also, when failing to write a message, show how much space was needed: "Failed to write entry (26 items, 260123456 bytes) despite vacuuming, ignoring: ...".
-rw-r--r--src/journal/journald-server.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index a2b5ac7513..de96040242 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -465,7 +465,12 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned
}
if (vacuumed || !shall_try_append_again(f, r)) {
- log_error("Failed to write entry, ignoring: %s", strerror(-r));
+ size_t size = 0;
+ unsigned i;
+ for (i = 0; i < n; i++)
+ size += iovec[i].iov_len;
+
+ log_error("Failed to write entry (%d items, %zu bytes), ignoring: %s", n, size, strerror(-r));
return;
}
@@ -478,8 +483,14 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned
log_debug("Retrying write.");
r = journal_file_append_entry(f, NULL, iovec, n, &s->seqnum, NULL, NULL);
- if (r < 0)
- log_error("Failed to write entry, ignoring: %s", strerror(-r));
+ if (r < 0) {
+ size_t size = 0;
+ unsigned i;
+ for (i = 0; i < n; i++)
+ size += iovec[i].iov_len;
+
+ log_error("Failed to write entry (%d items, %zu bytes) despite vacuuming, ignoring: %s", n, size, strerror(-r));
+ }
}
static void dispatch_message_real(
@@ -767,9 +778,6 @@ static int system_journal_open(Server *s) {
char *fn;
sd_id128_t machine;
char ids[33];
- uint64_t avail;
-
- avail = available_space(s);
r = sd_id128_get_machine(&machine);
if (r < 0)
@@ -790,27 +798,23 @@ static int system_journal_open(Server *s) {
if (s->storage == STORAGE_PERSISTENT)
(void) mkdir("/var/log/journal/", 0755);
- fn = strappend("/var/log/journal/", ids);
- if (!fn)
- return -ENOMEM;
-
+ fn = strappenda("/var/log/journal/", ids);
(void) mkdir(fn, 0755);
- free(fn);
-
- fn = strjoin("/var/log/journal/", ids, "/system.journal", NULL);
- if (!fn)
- return -ENOMEM;
+ fn = strappenda(fn, "/system.journal");
r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, NULL, &s->system_journal);
- free(fn);
if (r >= 0) {
char fb[FORMAT_BYTES_MAX];
+ uint64_t avail;
server_fix_perms(s, s->system_journal, 0);
+
server_driver_message(s, SD_ID128_NULL, "Allowing system journal files to grow to %s.",
format_bytes(fb, sizeof(fb), s->system_metrics.max_use));
+ avail = available_space(s);
+
if (s->system_metrics.max_use > avail)
server_driver_message(s, SD_ID128_NULL, "Journal size currently limited to %s due to SystemKeepFree.",
format_bytes(fb, sizeof(fb), avail));
@@ -864,11 +868,14 @@ static int system_journal_open(Server *s) {
if (s->runtime_journal) {
char fb[FORMAT_BYTES_MAX];
+ uint64_t avail;
server_fix_perms(s, s->runtime_journal, 0);
server_driver_message(s, SD_ID128_NULL, "Allowing runtime journal files to grow to %s.",
format_bytes(fb, sizeof(fb), s->runtime_metrics.max_use));
+ avail = available_space(s);
+
if (s->system_metrics.max_use > avail)
server_driver_message(s, SD_ID128_NULL, "Journal size currently limited to %s due to RuntimeKeepFree.",
format_bytes(fb, sizeof(fb), avail));