From: Kemeng Shi Date: Fri, 3 Mar 2023 17:21:20 +0000 (+0800) Subject: ext4: simplify calculation of blkoff in ext4_mb_new_blocks_simple X-Git-Tag: v5.15.161~227 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=db26ff923faaac309afac5db652b4251a44515b1;p=thirdparty%2Fkernel%2Fstable.git ext4: simplify calculation of blkoff in ext4_mb_new_blocks_simple [ Upstream commit 253cacb0de89235673ad5889d61f275a73dbee79 ] We try to allocate a block from goal in ext4_mb_new_blocks_simple. We only need get blkoff in first group with goal and set blkoff to 0 for the rest groups. Signed-off-by: Kemeng Shi Link: https://lore.kernel.org/r/20230303172120.3800725-21-shikemeng@huaweicloud.com Signed-off-by: Theodore Ts'o Stable-dep-of: 3f4830abd236 ("ext4: fix potential unnitialized variable") Signed-off-by: Sasha Levin --- diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 8dba416aa6c1e..c2fcdee223317 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -5908,9 +5908,6 @@ static ext4_fsblk_t ext4_mb_new_blocks_simple(handle_t *handle, return 0; } - ext4_get_group_no_and_offset(sb, - max(ext4_group_first_block_no(sb, group), goal), - NULL, &blkoff); while (1) { i = mb_find_next_zero_bit(bitmap_bh->b_data, max, blkoff); @@ -5925,6 +5922,8 @@ static ext4_fsblk_t ext4_mb_new_blocks_simple(handle_t *handle, brelse(bitmap_bh); if (i < max) break; + + blkoff = 0; } if (group >= ext4_get_groups_count(sb) || i >= max) {