summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-journal/sd-journal.c
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2021-11-01 15:33:08 +0100
committerDaan De Meyer <daan.j.demeyer@gmail.com>2022-01-26 21:16:00 +0100
commit8bad5453543dc27054380636e9809256d6906dfd (patch)
treeaada8ad619dfb17ceea10796ecae23ecb36dcb8f /src/libsystemd/sd-journal/sd-journal.c
parentjournal: Inline loop variable (diff)
downloadsystemd-8bad5453543dc27054380636e9809256d6906dfd.tar.xz
systemd-8bad5453543dc27054380636e9809256d6906dfd.zip
journal: Stop comparing hash values from entry items against data objects
These checks don't achieve anything of value. Assuming they were added to check for corruption, they don't actually achieve this goal since other parts of the data object can still get corrupted and we wouldn't notice unless we'd recalculate the hash every time. In theory, we could use the entry item hash to avoid a random access lookup for the data object hash in the journal file in the future to speed up searching, but for finding all entry objects containing a specific data objects, we already have entry arrays per data object to get fast access to this information. This means that duplicating the hashes in the entry item doesn't result in any added value. In this commit, we remove the checks so that in future commits we can remove the hashes from the journal file format in the new compact mode.
Diffstat (limited to '')
-rw-r--r--src/libsystemd/sd-journal/sd-journal.c14
1 files changed, 0 insertions, 14 deletions
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c
index 50db7f9910..644b9957b0 100644
--- a/src/libsystemd/sd-journal/sd-journal.c
+++ b/src/libsystemd/sd-journal/sd-journal.c
@@ -2303,12 +2303,10 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
for (i = 0; i < n; i++) {
Object *d;
uint64_t p, l;
- le64_t le_hash;
size_t t;
int compression;
p = le64toh(o->entry.items[i].object_offset);
- le_hash = o->entry.items[i].hash;
r = journal_file_move_to_object(f, OBJECT_DATA, p, &d);
if (IN_SET(r, -EADDRNOTAVAIL, -EBADMSG)) {
log_debug_errno(r, "Entry item %"PRIu64" data object is bad, skipping over it: %m", i);
@@ -2317,11 +2315,6 @@ _public_ int sd_journal_get_data(sd_journal *j, const char *field, const void **
if (r < 0)
return r;
- if (le_hash != d->data.hash) {
- log_debug("Entry item %"PRIu64" hash is bad, skipping over it.", i);
- continue;
- }
-
l = le64toh(d->object.size) - offsetof(Object, data.payload);
compression = d->object.flags & OBJECT_COMPRESSION_MASK;
@@ -2450,10 +2443,8 @@ _public_ int sd_journal_enumerate_data(sd_journal *j, const void **data, size_t
for (uint64_t n = journal_file_entry_n_items(o); j->current_field < n; j->current_field++) {
uint64_t p;
- le64_t le_hash;
p = le64toh(o->entry.items[j->current_field].object_offset);
- le_hash = o->entry.items[j->current_field].hash;
r = journal_file_move_to_object(f, OBJECT_DATA, p, &o);
if (IN_SET(r, -EADDRNOTAVAIL, -EBADMSG)) {
log_debug_errno(r, "Entry item %"PRIu64" data object is bad, skipping over it: %m", j->current_field);
@@ -2462,11 +2453,6 @@ _public_ int sd_journal_enumerate_data(sd_journal *j, const void **data, size_t
if (r < 0)
return r;
- if (le_hash != o->data.hash) {
- log_debug("Entry item %"PRIu64" hash is bad, skipping over it.", j->current_field);
- continue;
- }
-
r = return_data(j, f, o, data, size);
if (r == -EBADMSG) {
log_debug("Entry item %"PRIu64" data payload is bad, skipping over it.", j->current_field);