X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fjournald.c;h=c29d75c9c4045a22af163f3fbe5a689d87eb30f2;hb=bbd16ba5739c9b3c19e32a5a2f9e4e93d0ddb0c0;hp=e66bb07f84156c9b572a635cc962150e381e5c6f;hpb=dca6219e04505e9fa10b32e71059ce2abfae1dad;p=elogind.git diff --git a/src/journal/journald.c b/src/journal/journald.c index e66bb07f8..c29d75c9c 100644 --- a/src/journal/journald.c +++ b/src/journal/journald.c @@ -313,7 +313,7 @@ static JournalFile* find_journal(Server *s, uid_t uid) { journal_file_close(f); } - r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, s->system_journal, &f); + r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, &s->system_metrics, s->system_journal, &f); free(p); if (r < 0) @@ -493,7 +493,9 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned r != -EBADMSG && /* corrupted */ r != -ENODATA && /* truncated */ r != -EHOSTDOWN && /* other machine */ - r != -EPROTONOSUPPORT /* unsupported feature */)) { + r != -EPROTONOSUPPORT && /* unsupported feature */ + r != -EBUSY && /* unclean shutdown */ + r != -ESHUTDOWN /* already archived */)) { log_error("Failed to write entry, ignoring: %s", strerror(-r)); return; } @@ -502,6 +504,8 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned log_info("Allocation limit reached, rotating."); else if (r == -EHOSTDOWN) log_info("Journal file from other machine, rotating."); + else if (r == -EBUSY) + log_info("Unlcean shutdown, rotating."); else log_warning("Journal file corrupted, rotating."); @@ -509,6 +513,10 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned server_vacuum(s); vacuumed = true; + f = find_journal(s, uid); + if (!f) + return; + log_info("Retrying write."); } } @@ -2001,13 +2009,10 @@ static int system_journal_open(Server *s) { if (!fn) return -ENOMEM; - r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, NULL, &s->system_journal); + r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, &s->system_metrics, NULL, &s->system_journal); free(fn); if (r >= 0) { - journal_default_metrics(&s->system_metrics, s->system_journal->fd); - - s->system_journal->metrics = s->system_metrics; s->system_journal->compress = s->compress; server_fix_perms(s, s->system_journal, 0); @@ -2033,7 +2038,7 @@ static int system_journal_open(Server *s) { * if it already exists, so that we can flush * it into the system journal */ - r = journal_file_open(fn, O_RDWR, 0640, NULL, &s->runtime_journal); + r = journal_file_open(fn, O_RDWR, 0640, &s->runtime_metrics, NULL, &s->runtime_journal); free(fn); if (r < 0) { @@ -2049,7 +2054,7 @@ static int system_journal_open(Server *s) { * it if necessary. */ (void) mkdir_parents(fn, 0755); - r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, NULL, &s->runtime_journal); + r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, &s->runtime_metrics, NULL, &s->runtime_journal); free(fn); if (r < 0) { @@ -2059,9 +2064,6 @@ static int system_journal_open(Server *s) { } if (s->runtime_journal) { - journal_default_metrics(&s->runtime_metrics, s->runtime_journal->fd); - - s->runtime_journal->metrics = s->runtime_metrics; s->runtime_journal->compress = s->compress; server_fix_perms(s, s->runtime_journal, 0);