Skip to content

Commit

Permalink
ext4: remove call to ext4_group_desc() in ext4_group_used_meta_blocks()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Theodore Ts'o committed Feb 6, 2009
1 parent 074ca44 commit e187c65
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions fs/ext4/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,15 @@ static int ext4_block_in_group(struct super_block *sb, ext4_fsblk_t block,
}

static int ext4_group_used_meta_blocks(struct super_block *sb,
ext4_group_t block_group)
ext4_group_t block_group,
struct ext4_group_desc *gdp)
{
ext4_fsblk_t tmp;
struct ext4_sb_info *sbi = EXT4_SB(sb);
/* block bitmap, inode bitmap, and inode table blocks */
int used_blocks = sbi->s_itb_per_group + 2;

if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
struct ext4_group_desc *gdp;
struct buffer_head *bh;

gdp = ext4_get_group_desc(sb, block_group, &bh);
if (!ext4_block_in_group(sb, ext4_block_bitmap(sb, gdp),
block_group))
used_blocks--;
Expand Down Expand Up @@ -177,7 +174,7 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
*/
mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data);
}
return free_blocks - ext4_group_used_meta_blocks(sb, block_group);
return free_blocks - ext4_group_used_meta_blocks(sb, block_group, gdp);
}


Expand Down

0 comments on commit e187c65

Please sign in to comment.