From 24040269ee70c2b53bd508646e7de053adfa92df Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 15 Dec 2021 18:23:15 +0100 Subject: [PATCH] journal: Stop reading in increments of block size during hole punching Let's not try to be overly clever here. This code path is not overly performance sensitive and we should avoid trying to outsmart the kernel without proper benchmarking. --- src/journal/journald-file.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/journal/journald-file.c b/src/journal/journald-file.c index 64f522a7aa8..503900d5bc2 100644 --- a/src/journal/journald-file.c +++ b/src/journal/journald-file.c @@ -81,7 +81,6 @@ static int journald_file_entry_array_punch_hole(JournalFile *f, uint64_t p, uint static int journald_file_punch_holes(JournalFile *f) { HashItem items[PAYLOAD_BUFFER_SIZE / sizeof(HashItem)]; uint64_t p, sz; - size_t to_read; ssize_t n; int r; @@ -92,10 +91,9 @@ static int journald_file_punch_holes(JournalFile *f) { p = le64toh(f->header->data_hash_table_offset); sz = le64toh(f->header->data_hash_table_size); - to_read = MIN((size_t) f->last_stat.st_blksize, sizeof(items)); for (uint64_t i = p; i < p + sz; i += n) { - n = pread(f->fd, items, MIN(to_read, p + sz - i), i); + n = pread(f->fd, items, MIN(sizeof(items), p + sz - i), i); if (n < 0) return n; -- 2.47.3