]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ext4: correct the reserved credits for extent conversion
authorZhang Yi <yi.zhang@huawei.com>
Mon, 7 Jul 2025 14:08:10 +0000 (22:08 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 14 Jul 2025 03:41:52 +0000 (23:41 -0400)
Now, we reserve journal credits for converting extents in only one page
to written state when the I/O operation is complete. This is
insufficient when large folio is enabled.

Fix this by reserving credits for converting up to one extent per block in
the largest 2MB folio, this calculation should only involve extents index
and leaf blocks, so it should not estimate too many credits.

Fixes: 7ac67301e82f ("ext4: enable large folio for regular file")
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Baokun Li <libaokun1@huawei.com>
Link: https://patch.msgid.link/20250707140814.542883-8-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/inode.c

index 2b1d158b3f18f40a4ea18c381827fa502694beb6..1d158e1de3a15d8f3323d719bd7a52aedee7ab4f 100644 (file)
@@ -2847,12 +2847,12 @@ static int ext4_do_writepages(struct mpage_da_data *mpd)
        mpd->journalled_more_data = 0;
 
        if (ext4_should_dioread_nolock(inode)) {
+               int bpf = ext4_journal_blocks_per_folio(inode);
                /*
                 * We may need to convert up to one extent per block in
-                * the page and we may dirty the inode.
+                * the folio and we may dirty the inode.
                 */
-               rsv_blocks = 1 + ext4_chunk_trans_blocks(inode,
-                                               PAGE_SIZE >> inode->i_blkbits);
+               rsv_blocks = 1 + ext4_ext_index_trans_blocks(inode, bpf);
        }
 
        if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)