From: Daan De Meyer Date: Tue, 25 Jan 2022 13:21:55 +0000 (+0000) Subject: journal: Fail gracefully when linking a new entry X-Git-Tag: v251-rc1~444^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df535364356dcd16af68659298f0ca959f412f16;p=thirdparty%2Fsystemd.git journal: Fail gracefully when linking a new entry Let's always try to link all entry items even if linking one fails due to not being able to allocate a new entry array. Other entry items might still be successfully linked if the entry array of the corresponding data object isn't full yet. --- diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c index f1cbeb325a5..efda525c3a0 100644 --- a/src/libsystemd/sd-journal/journal-file.c +++ b/src/libsystemd/sd-journal/journal-file.c @@ -1786,12 +1786,20 @@ static int journal_file_link_entry(JournalFile *f, Object *o, uint64_t offset) { /* Link up the items */ n = journal_file_entry_n_items(o); for (uint64_t i = 0; i < n; i++) { - r = journal_file_link_entry_item(f, o, offset, i); - if (r < 0) - return r; + int k; + + /* If we fail to link an entry item because we can't allocate a new entry array, don't fail + * immediately but try to link the other entry items since it might still be possible to link + * those if they don't require a new entry array to be allocated. */ + + k = journal_file_link_entry_item(f, o, offset, i); + if (k == -E2BIG) + r = k; + else if (k < 0) + return k; } - return 0; + return r; } static int journal_file_append_entry_internal(