Skip to content

Commit 8e50e23

Browse files
LiBaokun96tytso
authored andcommitted
ext4: support large block size in mpage_prepare_extent_to_map()
Use the EXT4_PG_TO_LBLK/EXT4_LBLK_TO_PG macros to complete the conversion between folio indexes and blocks to avoid negative left/right shifts after supporting blocksize greater than PAGE_SIZE. Signed-off-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com> Message-ID: <20251121090654.631996-20-libaokun@huaweicloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent b967ab7 commit 8e50e23

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

fs/ext4/inode.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,7 +2620,6 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
26202620
pgoff_t end = mpd->end_pos >> PAGE_SHIFT;
26212621
xa_mark_t tag;
26222622
int i, err = 0;
2623-
int blkbits = mpd->inode->i_blkbits;
26242623
ext4_lblk_t lblk;
26252624
struct buffer_head *head;
26262625
handle_t *handle = NULL;
@@ -2659,7 +2658,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
26592658
*/
26602659
if (mpd->wbc->sync_mode == WB_SYNC_NONE &&
26612660
mpd->wbc->nr_to_write <=
2662-
mpd->map.m_len >> (PAGE_SHIFT - blkbits))
2661+
EXT4_LBLK_TO_PG(mpd->inode, mpd->map.m_len))
26632662
goto out;
26642663

26652664
/* If we can't merge this page, we are done. */
@@ -2737,8 +2736,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
27372736
mpage_folio_done(mpd, folio);
27382737
} else {
27392738
/* Add all dirty buffers to mpd */
2740-
lblk = ((ext4_lblk_t)folio->index) <<
2741-
(PAGE_SHIFT - blkbits);
2739+
lblk = EXT4_PG_TO_LBLK(mpd->inode, folio->index);
27422740
head = folio_buffers(folio);
27432741
err = mpage_process_page_bufs(mpd, head, head,
27442742
lblk);

0 commit comments

Comments
 (0)