Skip to content

Commit e187c65

Browse files
committed
ext4: remove call to ext4_group_desc() in ext4_group_used_meta_blocks()
The static function ext4_group_used_meta_blocks() only has one caller, who already has access to the block group's group descriptor. So it's better to have ext4_init_block_bitmap() pass the group descriptor to ext4_group_used_meta_blocks(), so it doesn't need to call ext4_group_desc(). Previously this function did not check if ext4_group_desc() returned NULL due to an error, potentially causing a kernel OOPS report. This avoids the issue entirely. Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent 074ca44 commit e187c65

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

fs/ext4/balloc.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,15 @@ static int ext4_block_in_group(struct super_block *sb, ext4_fsblk_t block,
5555
}
5656

5757
static int ext4_group_used_meta_blocks(struct super_block *sb,
58-
ext4_group_t block_group)
58+
ext4_group_t block_group,
59+
struct ext4_group_desc *gdp)
5960
{
6061
ext4_fsblk_t tmp;
6162
struct ext4_sb_info *sbi = EXT4_SB(sb);
6263
/* block bitmap, inode bitmap, and inode table blocks */
6364
int used_blocks = sbi->s_itb_per_group + 2;
6465

6566
if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
66-
struct ext4_group_desc *gdp;
67-
struct buffer_head *bh;
68-
69-
gdp = ext4_get_group_desc(sb, block_group, &bh);
7067
if (!ext4_block_in_group(sb, ext4_block_bitmap(sb, gdp),
7168
block_group))
7269
used_blocks--;
@@ -177,7 +174,7 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
177174
*/
178175
mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data);
179176
}
180-
return free_blocks - ext4_group_used_meta_blocks(sb, block_group);
177+
return free_blocks - ext4_group_used_meta_blocks(sb, block_group, gdp);
181178
}
182179

183180

0 commit comments

Comments
 (0)