diff options
Diffstat (limited to 'fs/ext2/super.c')
-rw-r--r-- | fs/ext2/super.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 4286ff6330b6..513cd421ac0b 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -184,8 +184,7 @@ static int init_inodecache(void) | |||
184 | 184 | ||
185 | static void destroy_inodecache(void) | 185 | static void destroy_inodecache(void) |
186 | { | 186 | { |
187 | if (kmem_cache_destroy(ext2_inode_cachep)) | 187 | kmem_cache_destroy(ext2_inode_cachep); |
188 | printk(KERN_INFO "ext2_inode_cache: not all structures were freed\n"); | ||
189 | } | 188 | } |
190 | 189 | ||
191 | static void ext2_clear_inode(struct inode *inode) | 190 | static void ext2_clear_inode(struct inode *inode) |
@@ -544,17 +543,24 @@ static int ext2_check_descriptors (struct super_block * sb) | |||
544 | int i; | 543 | int i; |
545 | int desc_block = 0; | 544 | int desc_block = 0; |
546 | struct ext2_sb_info *sbi = EXT2_SB(sb); | 545 | struct ext2_sb_info *sbi = EXT2_SB(sb); |
547 | unsigned long block = le32_to_cpu(sbi->s_es->s_first_data_block); | 546 | unsigned long first_block = le32_to_cpu(sbi->s_es->s_first_data_block); |
547 | unsigned long last_block; | ||
548 | struct ext2_group_desc * gdp = NULL; | 548 | struct ext2_group_desc * gdp = NULL; |
549 | 549 | ||
550 | ext2_debug ("Checking group descriptors"); | 550 | ext2_debug ("Checking group descriptors"); |
551 | 551 | ||
552 | for (i = 0; i < sbi->s_groups_count; i++) | 552 | for (i = 0; i < sbi->s_groups_count; i++) |
553 | { | 553 | { |
554 | if (i == sbi->s_groups_count - 1) | ||
555 | last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1; | ||
556 | else | ||
557 | last_block = first_block + | ||
558 | (EXT2_BLOCKS_PER_GROUP(sb) - 1); | ||
559 | |||
554 | if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0) | 560 | if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0) |
555 | gdp = (struct ext2_group_desc *) sbi->s_group_desc[desc_block++]->b_data; | 561 | gdp = (struct ext2_group_desc *) sbi->s_group_desc[desc_block++]->b_data; |
556 | if (le32_to_cpu(gdp->bg_block_bitmap) < block || | 562 | if (le32_to_cpu(gdp->bg_block_bitmap) < first_block || |
557 | le32_to_cpu(gdp->bg_block_bitmap) >= block + EXT2_BLOCKS_PER_GROUP(sb)) | 563 | le32_to_cpu(gdp->bg_block_bitmap) > last_block) |
558 | { | 564 | { |
559 | ext2_error (sb, "ext2_check_descriptors", | 565 | ext2_error (sb, "ext2_check_descriptors", |
560 | "Block bitmap for group %d" | 566 | "Block bitmap for group %d" |
@@ -562,8 +568,8 @@ static int ext2_check_descriptors (struct super_block * sb) | |||
562 | i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap)); | 568 | i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap)); |
563 | return 0; | 569 | return 0; |
564 | } | 570 | } |
565 | if (le32_to_cpu(gdp->bg_inode_bitmap) < block || | 571 | if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block || |
566 | le32_to_cpu(gdp->bg_inode_bitmap) >= block + EXT2_BLOCKS_PER_GROUP(sb)) | 572 | le32_to_cpu(gdp->bg_inode_bitmap) > last_block) |
567 | { | 573 | { |
568 | ext2_error (sb, "ext2_check_descriptors", | 574 | ext2_error (sb, "ext2_check_descriptors", |
569 | "Inode bitmap for group %d" | 575 | "Inode bitmap for group %d" |
@@ -571,9 +577,9 @@ static int ext2_check_descriptors (struct super_block * sb) | |||
571 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap)); | 577 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap)); |
572 | return 0; | 578 | return 0; |
573 | } | 579 | } |
574 | if (le32_to_cpu(gdp->bg_inode_table) < block || | 580 | if (le32_to_cpu(gdp->bg_inode_table) < first_block || |
575 | le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group >= | 581 | le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group > |
576 | block + EXT2_BLOCKS_PER_GROUP(sb)) | 582 | last_block) |
577 | { | 583 | { |
578 | ext2_error (sb, "ext2_check_descriptors", | 584 | ext2_error (sb, "ext2_check_descriptors", |
579 | "Inode table for group %d" | 585 | "Inode table for group %d" |
@@ -581,7 +587,7 @@ static int ext2_check_descriptors (struct super_block * sb) | |||
581 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_table)); | 587 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_table)); |
582 | return 0; | 588 | return 0; |
583 | } | 589 | } |
584 | block += EXT2_BLOCKS_PER_GROUP(sb); | 590 | first_block += EXT2_BLOCKS_PER_GROUP(sb); |
585 | gdp++; | 591 | gdp++; |
586 | } | 592 | } |
587 | return 1; | 593 | return 1; |
@@ -648,11 +654,10 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
648 | int i, j; | 654 | int i, j; |
649 | __le32 features; | 655 | __le32 features; |
650 | 656 | ||
651 | sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); | 657 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
652 | if (!sbi) | 658 | if (!sbi) |
653 | return -ENOMEM; | 659 | return -ENOMEM; |
654 | sb->s_fs_info = sbi; | 660 | sb->s_fs_info = sbi; |
655 | memset(sbi, 0, sizeof(*sbi)); | ||
656 | 661 | ||
657 | /* | 662 | /* |
658 | * See what the current blocksize for the device is, and | 663 | * See what the current blocksize for the device is, and |
@@ -861,10 +866,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
861 | 866 | ||
862 | if (EXT2_BLOCKS_PER_GROUP(sb) == 0) | 867 | if (EXT2_BLOCKS_PER_GROUP(sb) == 0) |
863 | goto cantfind_ext2; | 868 | goto cantfind_ext2; |
864 | sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) - | 869 | sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) - |
865 | le32_to_cpu(es->s_first_data_block) + | 870 | le32_to_cpu(es->s_first_data_block) - 1) |
866 | EXT2_BLOCKS_PER_GROUP(sb) - 1) / | 871 | / EXT2_BLOCKS_PER_GROUP(sb)) + 1; |
867 | EXT2_BLOCKS_PER_GROUP(sb); | ||
868 | db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / | 872 | db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / |
869 | EXT2_DESC_PER_BLOCK(sb); | 873 | EXT2_DESC_PER_BLOCK(sb); |
870 | sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL); | 874 | sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL); |