[PATCH 12/16] squashfs: step squashfs_readpage_block() lookups by folio

From: Tal Zussman

Date: Tue Nov 03 2026 - 08:30:19 EST


Have squashfs_readpage_block() move on to the index after each folio it
looks up rather than to the next index, so it grabs a large folio once
instead of once per page.

squashfs only uses order-0 folios, so no functional change. This is a
step towards enabling large folios.

Signed-off-by: Tal Zussman <tz2294@xxxxxxxxxxxx>
---
fs/squashfs/file_direct.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/squashfs/file_direct.c b/fs/squashfs/file_direct.c
index ef522923e6a9..110a5b14f9c4 100644
--- a/fs/squashfs/file_direct.c
+++ b/fs/squashfs/file_direct.c
@@ -44,7 +44,7 @@ int squashfs_readpage_block(struct folio *folio, u64 block, int bsize,
return res;

/* Try to grab all the folios covered by the Squashfs block */
- for (i = 0, index = start_index; index <= end_index; index++) {
+ for (i = 0, index = start_index; index <= end_index;) {
struct folio *f;

if (index == folio->index)
@@ -54,8 +54,12 @@ int squashfs_readpage_block(struct folio *folio, u64 block, int bsize,
FGP_LOCK | FGP_CREAT | FGP_NOWAIT,
mapping_gfp_mask(folio->mapping));

- if (IS_ERR(f))
+ if (IS_ERR(f)) {
+ index++;
continue;
+ }
+
+ index = folio_next_index(f);

if (folio_test_uptodate(f)) {
folio_unlock(f);

--
2.39.5