Skip to content

Commit 2e8216e

Browse files
zhangyi089gregkh
authored andcommitted
ext4: reserved credits for one extent during the folio writeback
commit bbbf150 upstream. After ext4 supports large folios, reserving journal credits for one maximum-ordered folio based on the worst case cenario during the writeback process can easily exceed the maximum transaction credits. Additionally, reserving journal credits for one page is also no longer appropriate. Currently, the folio writeback process can either extend the journal credits or initiate a new transaction if the currently reserved journal credits are insufficient. Therefore, it can be modified to reserve credits for only one extent at the outset. In most cases involving continuous mapping, these credits are generally adequate, and we may only need to perform some basic credit expansion. However, in extreme cases where the block size and folio size differ significantly, or when the folios are sufficiently discontinuous, it may be necessary to restart a new transaction and resubmit the folios. Suggested-by: Jan Kara <[email protected]> Signed-off-by: Zhang Yi <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2b6d392 commit 2e8216e

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

fs/ext4/inode.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,21 +2548,6 @@ static int mpage_map_and_submit_extent(handle_t *handle,
25482548
return err;
25492549
}
25502550

2551-
/*
2552-
* Calculate the total number of credits to reserve for one writepages
2553-
* iteration. This is called from ext4_writepages(). We map an extent of
2554-
* up to MAX_WRITEPAGES_EXTENT_LEN blocks and then we go on and finish mapping
2555-
* the last partial page. So in total we can map MAX_WRITEPAGES_EXTENT_LEN +
2556-
* bpp - 1 blocks in bpp different extents.
2557-
*/
2558-
static int ext4_da_writepages_trans_blocks(struct inode *inode)
2559-
{
2560-
int bpp = ext4_journal_blocks_per_folio(inode);
2561-
2562-
return ext4_meta_trans_blocks(inode,
2563-
MAX_WRITEPAGES_EXTENT_LEN + bpp - 1, bpp);
2564-
}
2565-
25662551
static int ext4_journal_folio_buffers(handle_t *handle, struct folio *folio,
25672552
size_t len)
25682553
{
@@ -2919,8 +2904,14 @@ static int ext4_do_writepages(struct mpage_da_data *mpd)
29192904
* not supported by delalloc.
29202905
*/
29212906
BUG_ON(ext4_should_journal_data(inode));
2922-
needed_blocks = ext4_da_writepages_trans_blocks(inode);
2923-
2907+
/*
2908+
* Calculate the number of credits needed to reserve for one
2909+
* extent of up to MAX_WRITEPAGES_EXTENT_LEN blocks. It will
2910+
* attempt to extend the transaction or start a new iteration
2911+
* if the reserved credits are insufficient.
2912+
*/
2913+
needed_blocks = ext4_chunk_trans_blocks(inode,
2914+
MAX_WRITEPAGES_EXTENT_LEN);
29242915
/* start a new transaction */
29252916
handle = ext4_journal_start_with_reserve(inode,
29262917
EXT4_HT_WRITE_PAGE, needed_blocks, rsv_blocks);

0 commit comments

Comments
 (0)