Skip to content

Commit 5137d6c

Browse files
zhangyi089tytso
authored andcommitted
ext4: fix insufficient credits calculation in ext4_meta_trans_blocks()
The calculation of journal credits in ext4_meta_trans_blocks() should include pextents, as each extent separately may be allocated from a different group and thus need to update different bitmap and group descriptor block. Fixes: 0e32d86 ("ext4: correct the journal credits calculations of allocating blocks") Reported-by: Jan Kara <jack@suse.cz> Closes: https://lore.kernel.org/linux-ext4/nhxfuu53wyacsrq7xqgxvgzcggyscu2tbabginahcygvmc45hy@t4fvmyeky33e/ 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-11-yi.zhang@huaweicloud.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 57661f2 commit 5137d6c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/ext4/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6212,7 +6212,7 @@ int ext4_meta_trans_blocks(struct inode *inode, int lblocks, int pextents)
62126212
int ret;
62136213

62146214
/*
6215-
* How many index and lead blocks need to touch to map @lblocks
6215+
* How many index and leaf blocks need to touch to map @lblocks
62166216
* logical blocks to @pextents physical extents?
62176217
*/
62186218
idxblocks = ext4_index_trans_blocks(inode, lblocks, pextents);
@@ -6221,7 +6221,7 @@ int ext4_meta_trans_blocks(struct inode *inode, int lblocks, int pextents)
62216221
* Now let's see how many group bitmaps and group descriptors need
62226222
* to account
62236223
*/
6224-
groups = idxblocks;
6224+
groups = idxblocks + pextents;
62256225
gdpblocks = groups;
62266226
if (groups > ngroups)
62276227
groups = ngroups;

0 commit comments

Comments
 (0)