Commit 41f04d85 authored by Eric Sandeen's avatar Eric Sandeen Committed by Linus Torvalds

[PATCH] ext2: fix mounts at 16T

Signed-off-by: default avatarEric Sandeen <esandeen@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 855565e8
...@@ -544,17 +544,24 @@ static int ext2_check_descriptors (struct super_block * sb) ...@@ -544,17 +544,24 @@ static int ext2_check_descriptors (struct super_block * sb)
int i; int i;
int desc_block = 0; int desc_block = 0;
struct ext2_sb_info *sbi = EXT2_SB(sb); struct ext2_sb_info *sbi = EXT2_SB(sb);
unsigned long block = le32_to_cpu(sbi->s_es->s_first_data_block); unsigned long first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
unsigned long last_block;
struct ext2_group_desc * gdp = NULL; struct ext2_group_desc * gdp = NULL;
ext2_debug ("Checking group descriptors"); ext2_debug ("Checking group descriptors");
for (i = 0; i < sbi->s_groups_count; i++) for (i = 0; i < sbi->s_groups_count; i++)
{ {
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) if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0)
gdp = (struct ext2_group_desc *) sbi->s_group_desc[desc_block++]->b_data; gdp = (struct ext2_group_desc *) sbi->s_group_desc[desc_block++]->b_data;
if (le32_to_cpu(gdp->bg_block_bitmap) < block || if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
le32_to_cpu(gdp->bg_block_bitmap) >= block + EXT2_BLOCKS_PER_GROUP(sb)) le32_to_cpu(gdp->bg_block_bitmap) > last_block)
{ {
ext2_error (sb, "ext2_check_descriptors", ext2_error (sb, "ext2_check_descriptors",
"Block bitmap for group %d" "Block bitmap for group %d"
...@@ -562,8 +569,8 @@ static int ext2_check_descriptors (struct super_block * sb) ...@@ -562,8 +569,8 @@ static int ext2_check_descriptors (struct super_block * sb)
i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap)); i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap));
return 0; return 0;
} }
if (le32_to_cpu(gdp->bg_inode_bitmap) < block || if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block ||
le32_to_cpu(gdp->bg_inode_bitmap) >= block + EXT2_BLOCKS_PER_GROUP(sb)) le32_to_cpu(gdp->bg_inode_bitmap) > last_block)
{ {
ext2_error (sb, "ext2_check_descriptors", ext2_error (sb, "ext2_check_descriptors",
"Inode bitmap for group %d" "Inode bitmap for group %d"
...@@ -571,9 +578,9 @@ static int ext2_check_descriptors (struct super_block * sb) ...@@ -571,9 +578,9 @@ static int ext2_check_descriptors (struct super_block * sb)
i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap)); i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap));
return 0; return 0;
} }
if (le32_to_cpu(gdp->bg_inode_table) < block || if (le32_to_cpu(gdp->bg_inode_table) < first_block ||
le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group >= le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group >
block + EXT2_BLOCKS_PER_GROUP(sb)) last_block)
{ {
ext2_error (sb, "ext2_check_descriptors", ext2_error (sb, "ext2_check_descriptors",
"Inode table for group %d" "Inode table for group %d"
...@@ -581,7 +588,7 @@ static int ext2_check_descriptors (struct super_block * sb) ...@@ -581,7 +588,7 @@ static int ext2_check_descriptors (struct super_block * sb)
i, (unsigned long) le32_to_cpu(gdp->bg_inode_table)); i, (unsigned long) le32_to_cpu(gdp->bg_inode_table));
return 0; return 0;
} }
block += EXT2_BLOCKS_PER_GROUP(sb); first_block += EXT2_BLOCKS_PER_GROUP(sb);
gdp++; gdp++;
} }
return 1; return 1;
...@@ -861,10 +868,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -861,10 +868,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if (EXT2_BLOCKS_PER_GROUP(sb) == 0) if (EXT2_BLOCKS_PER_GROUP(sb) == 0)
goto cantfind_ext2; goto cantfind_ext2;
sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) - sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
le32_to_cpu(es->s_first_data_block) + le32_to_cpu(es->s_first_data_block) - 1)
EXT2_BLOCKS_PER_GROUP(sb) - 1) / / EXT2_BLOCKS_PER_GROUP(sb)) + 1;
EXT2_BLOCKS_PER_GROUP(sb);
db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
EXT2_DESC_PER_BLOCK(sb); EXT2_DESC_PER_BLOCK(sb);
sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL); sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment