[PATCH 02/16] squashfs: don't read an extra block when expanding readahead
From: Tal Zussman
Date: Tue Nov 03 2026 - 08:42:51 EST
squashfs_readahead() expands the readahead window to whole blocks with
(len | mask) + 1. When len is already a multiple of the block size, that
adds another whole block, so a block-aligned 128K window on a filesystem
with 128K blocks reads 256K.
Round len up to the block size instead.
Fixes: 8fc78b6fe24c ("squashfs: implement readahead")
Signed-off-by: Tal Zussman <tz2294@xxxxxxxxxxxx>
---
fs/squashfs/file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index 9c9a437ab118..12263ec8494b 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -587,7 +587,7 @@ static void squashfs_readahead(struct readahead_control *ractl)
loff_t file_end = i_size_read(inode) >> msblk->block_log;
unsigned int max_pages = 1UL << shift;
- readahead_expand(ractl, start, (len | mask) + 1);
+ readahead_expand(ractl, start, round_up(len, msblk->block_size));
pages = kmalloc_array(max_pages, sizeof(void *), GFP_KERNEL);
if (!pages)
--
2.39.5