If the blocksize is larger than the pagesize allocate folios with the correct order. Signed-off-by: Hannes Reinecke <hare@xxxxxxx> --- mm/filemap.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 05fd86752489..468f25714ced 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1927,7 +1927,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, folio_wait_stable(folio); no_page: if (!folio && (fgp_flags & FGP_CREAT)) { - int err; + int err, order = 0; if ((fgp_flags & FGP_WRITE) && mapping_can_writeback(mapping)) gfp |= __GFP_WRITE; if (fgp_flags & FGP_NOFS) @@ -1937,7 +1937,9 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index, gfp |= GFP_NOWAIT | __GFP_NOWARN; } - folio = filemap_alloc_folio(gfp, 0); + if (mapping->host->i_blkbits > PAGE_SHIFT) + order = mapping->host->i_blkbits - PAGE_SHIFT; + folio = filemap_alloc_folio(gfp, order); if (!folio) return NULL; @@ -2492,9 +2494,11 @@ static int filemap_create_folio(struct file *file, struct folio_batch *fbatch) { struct folio *folio; - int error; + int error, order = 0; - folio = filemap_alloc_folio(mapping_gfp_mask(mapping), 0); + if (mapping->host->i_blkbits > PAGE_SHIFT) + order = mapping->host->i_blkbits - PAGE_SHIFT; + folio = filemap_alloc_folio(mapping_gfp_mask(mapping), order); if (!folio) return -ENOMEM; @@ -3607,14 +3611,16 @@ static struct folio *do_read_cache_folio(struct address_space *mapping, pgoff_t index, filler_t filler, struct file *file, gfp_t gfp) { struct folio *folio; - int err; + int err, order = 0; + if (mapping->host->i_blkbits > PAGE_SHIFT) + order = mapping->host->i_blkbits - PAGE_SHIFT; if (!filler) filler = mapping->a_ops->read_folio; repeat: folio = filemap_get_folio(mapping, index); if (!folio) { - folio = filemap_alloc_folio(gfp, 0); + folio = filemap_alloc_folio(gfp, order); if (!folio) return ERR_PTR(-ENOMEM); err = filemap_add_folio(mapping, folio, index, gfp); -- 2.35.3