Message ID | 20250204231209.429356-4-mcgrof@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | enable bs > ps for block devices | expand |
On Tue, Feb 04, 2025 at 03:12:04PM -0800, Luis Chamberlain wrote: > From: Hannes Reinecke <hare@kernel.org> > > For large blocksizes the number of block bits is larger than PAGE_SHIFT, > so use instead use folio_pos(folio) >> blkbits to calculate the sector "so calculate the sector number from the byte offset instead" > number. This is required to enable large folios with buffer-heads. > > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> > Signed-off-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
diff --git a/fs/mpage.c b/fs/mpage.c index 82aecf372743..a3c82206977f 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -181,7 +181,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) if (folio_buffers(folio)) goto confused; - block_in_file = (sector_t)folio->index << (PAGE_SHIFT - blkbits); + block_in_file = folio_pos(folio) >> blkbits; last_block = block_in_file + args->nr_pages * blocks_per_page; last_block_in_file = (i_size_read(inode) + blocksize - 1) >> blkbits; if (last_block > last_block_in_file) @@ -527,7 +527,7 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc, * The page has no buffers: map it to disk */ BUG_ON(!folio_test_uptodate(folio)); - block_in_file = (sector_t)folio->index << (PAGE_SHIFT - blkbits); + block_in_file = folio_pos(folio) >> blkbits; /* * Whole page beyond EOF? Skip allocating blocks to avoid leaking * space.