Skip to content

Commit

Permalink
ext[234]: use ext[234]_get_group_desc()
Browse files Browse the repository at this point in the history
Use ext[234]_get_group_desc() to get group descriptor from group number.

Cc: <linux-ext4@vger.kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Akinobu Mita authored and Linus Torvalds committed Feb 6, 2008
1 parent 144704e commit 197cd65
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 27 deletions.
12 changes: 4 additions & 8 deletions fs/ext2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,27 +617,24 @@ static int ext2_setup_super (struct super_block * sb,
return res;
}

static int ext2_check_descriptors (struct super_block * sb)
static int ext2_check_descriptors(struct super_block *sb)
{
int i;
int desc_block = 0;
struct ext2_sb_info *sbi = EXT2_SB(sb);
unsigned long first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
unsigned long last_block;
struct ext2_group_desc * gdp = NULL;

ext2_debug ("Checking group descriptors");

for (i = 0; i < sbi->s_groups_count; i++)
{
for (i = 0; i < sbi->s_groups_count; i++) {
struct ext2_group_desc *gdp = ext2_get_group_desc(sb, i, NULL);

if (i == sbi->s_groups_count - 1)
last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1;
else
last_block = first_block +
(EXT2_BLOCKS_PER_GROUP(sb) - 1);

if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0)
gdp = (struct ext2_group_desc *) sbi->s_group_desc[desc_block++]->b_data;
if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
le32_to_cpu(gdp->bg_block_bitmap) > last_block)
{
Expand Down Expand Up @@ -667,7 +664,6 @@ static int ext2_check_descriptors (struct super_block * sb)
return 0;
}
first_block += EXT2_BLOCKS_PER_GROUP(sb);
gdp++;
}
return 1;
}
Expand Down
13 changes: 4 additions & 9 deletions fs/ext3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1252,28 +1252,24 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
}

/* Called at mount-time, super-block is locked */
static int ext3_check_descriptors (struct super_block * sb)
static int ext3_check_descriptors(struct super_block *sb)
{
struct ext3_sb_info *sbi = EXT3_SB(sb);
ext3_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
ext3_fsblk_t last_block;
struct ext3_group_desc * gdp = NULL;
int desc_block = 0;
int i;

ext3_debug ("Checking group descriptors");

for (i = 0; i < sbi->s_groups_count; i++)
{
for (i = 0; i < sbi->s_groups_count; i++) {
struct ext3_group_desc *gdp = ext3_get_group_desc(sb, i, NULL);

if (i == sbi->s_groups_count - 1)
last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1;
else
last_block = first_block +
(EXT3_BLOCKS_PER_GROUP(sb) - 1);

if ((i % EXT3_DESC_PER_BLOCK(sb)) == 0)
gdp = (struct ext3_group_desc *)
sbi->s_group_desc[desc_block++]->b_data;
if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
le32_to_cpu(gdp->bg_block_bitmap) > last_block)
{
Expand Down Expand Up @@ -1306,7 +1302,6 @@ static int ext3_check_descriptors (struct super_block * sb)
return 0;
}
first_block += EXT3_BLOCKS_PER_GROUP(sb);
gdp++;
}

sbi->s_es->s_free_blocks_count=cpu_to_le32(ext3_count_free_blocks(sb));
Expand Down
14 changes: 4 additions & 10 deletions fs/ext4/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1458,16 +1458,14 @@ int ext4_group_desc_csum_verify(struct ext4_sb_info *sbi, __u32 block_group,
}

/* Called at mount-time, super-block is locked */
static int ext4_check_descriptors (struct super_block * sb)
static int ext4_check_descriptors(struct super_block *sb)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
ext4_fsblk_t last_block;
ext4_fsblk_t block_bitmap;
ext4_fsblk_t inode_bitmap;
ext4_fsblk_t inode_table;
struct ext4_group_desc * gdp = NULL;
int desc_block = 0;
int flexbg_flag = 0;
ext4_group_t i;

Expand All @@ -1476,17 +1474,15 @@ static int ext4_check_descriptors (struct super_block * sb)

ext4_debug ("Checking group descriptors");

for (i = 0; i < sbi->s_groups_count; i++)
{
for (i = 0; i < sbi->s_groups_count; i++) {
struct ext4_group_desc *gdp = ext4_get_group_desc(sb, i, NULL);

if (i == sbi->s_groups_count - 1 || flexbg_flag)
last_block = ext4_blocks_count(sbi->s_es) - 1;
else
last_block = first_block +
(EXT4_BLOCKS_PER_GROUP(sb) - 1);

if ((i % EXT4_DESC_PER_BLOCK(sb)) == 0)
gdp = (struct ext4_group_desc *)
sbi->s_group_desc[desc_block++]->b_data;
block_bitmap = ext4_block_bitmap(sb, gdp);
if (block_bitmap < first_block || block_bitmap > last_block)
{
Expand Down Expand Up @@ -1524,8 +1520,6 @@ static int ext4_check_descriptors (struct super_block * sb)
}
if (!flexbg_flag)
first_block += EXT4_BLOCKS_PER_GROUP(sb);
gdp = (struct ext4_group_desc *)
((__u8 *)gdp + EXT4_DESC_SIZE(sb));
}

ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb));
Expand Down

0 comments on commit 197cd65

Please sign in to comment.