Skip to content

Commit 86c60ef

Browse files
Hannes Reineckebrauner
authored andcommitted
fs/mpage: avoid negative shift for large blocksize
For large blocksizes the number of block bits is larger than PAGE_SHIFT, so calculate the sector number from the byte offset instead. This is required to enable large folios with buffer-heads. Reviewed-by: "Matthew Wilcox (Oracle)" <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]> Signed-off-by: Hannes Reinecke <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent b72e591 commit 86c60ef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/mpage.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args)
181181
if (folio_buffers(folio))
182182
goto confused;
183183

184-
block_in_file = (sector_t)folio->index << (PAGE_SHIFT - blkbits);
184+
block_in_file = folio_pos(folio) >> blkbits;
185185
last_block = block_in_file + args->nr_pages * blocks_per_page;
186186
last_block_in_file = (i_size_read(inode) + blocksize - 1) >> blkbits;
187187
if (last_block > last_block_in_file)
@@ -527,7 +527,7 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc,
527527
* The page has no buffers: map it to disk
528528
*/
529529
BUG_ON(!folio_test_uptodate(folio));
530-
block_in_file = (sector_t)folio->index << (PAGE_SHIFT - blkbits);
530+
block_in_file = folio_pos(folio) >> blkbits;
531531
/*
532532
* Whole page beyond EOF? Skip allocating blocks to avoid leaking
533533
* space.

0 commit comments

Comments
 (0)