]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: Stop reading in increments of block size during hole punching 21784/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 15 Dec 2021 17:23:15 +0000 (18:23 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 15 Dec 2021 17:24:29 +0000 (18:24 +0100)
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

index 64f522a7aa86143d60d3eae83b36faea6471eeda..503900d5bc2721115db99c780730a764bbaaf45f 100644 (file)
@@ -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;