[PATCH 16/16] squashfs: use folios to fill the bio in squashfs_bio_read()
From: Tal Zussman
Date: Tue Nov 03 2026 - 11:26:19 EST
Fill the bio with folios. Use filemap_get_folio() for the compressed
data cache and bio_add_folio_nofail(), which adds one vec per folio as
squashfs_bio_read_cached() expects.
This removes one of the last callers of find_get_page() and two calls
to compound_head(). No functional change.
Signed-off-by: Tal Zussman <tz2294@xxxxxxxxxxxx>
---
fs/squashfs/block.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c
index 3c81999ae441..bf0511c7b82e 100644
--- a/fs/squashfs/block.c
+++ b/fs/squashfs/block.c
@@ -186,24 +186,24 @@ static int squashfs_bio_read_cached(struct bio *fullbio,
return 0;
}
-static struct page *squashfs_get_cache_page(struct address_space *mapping,
- pgoff_t index)
+static struct folio *squashfs_get_cache_folio(struct address_space *mapping,
+ pgoff_t index)
{
- struct page *page;
+ struct folio *folio;
if (!mapping)
return NULL;
- page = find_get_page(mapping, index);
- if (!page)
+ folio = filemap_get_folio(mapping, index);
+ if (IS_ERR(folio))
return NULL;
- if (!PageUptodate(page)) {
- put_page(page);
+ if (!folio_test_uptodate(folio)) {
+ folio_put(folio);
return NULL;
}
- return page;
+ return folio;
}
static int squashfs_bio_read(struct super_block *sb, u64 index, int length,
@@ -231,22 +231,23 @@ static int squashfs_bio_read(struct super_block *sb, u64 index, int length,
unsigned int len =
min_t(unsigned int, PAGE_SIZE - offset, total_len);
pgoff_t index = (read_start >> PAGE_SHIFT) + i;
- struct page *page;
+ struct folio *folio;
- page = squashfs_get_cache_page(cache_mapping, index);
- if (!page)
- page = alloc_page(GFP_NOIO);
+ folio = squashfs_get_cache_folio(cache_mapping, index);
+ if (!folio)
+ folio = folio_alloc(GFP_NOIO, 0);
- if (!page) {
+ if (!folio) {
error = -ENOMEM;
goto out_free_bio;
}
/*
- * Use the __ version to avoid merging since we need each page
- * to be separate when we check for and avoid cached pages.
+ * squashfs_bio_read_cached() needs one bvec per folio to find
+ * and skip the cached ones. bio_add_folio_nofail() never merges
+ * with the previous bvec, unlike bio_add_folio().
*/
- __bio_add_page(bio, page, len, offset);
+ bio_add_folio_nofail(bio, folio, len, offset);
offset = 0;
total_len -= len;
}
--
2.39.5