]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: Fail gracefully when linking a new entry
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 25 Jan 2022 13:21:55 +0000 (13:21 +0000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 26 Jan 2022 20:16:00 +0000 (20:16 +0000)
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.

src/libsystemd/sd-journal/journal-file.c

index f1cbeb325a592896b4c95246acd7fe363c0e9e5a..efda525c3a06d0cf4e4f3615ce69035d4a4f976a 100644 (file)
@@ -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(