diff options
author | Darrick J. Wong <djwong@us.ibm.com> | 2012-04-29 18:35:10 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-04-29 18:35:10 -0400 |
commit | fa77dcfafeaa6bc73293c646bfc3d5192dcf0be2 (patch) | |
tree | 66c4232c2e5c1f59666e05164b77539a9b1dd290 /fs/ext4/mballoc.c | |
parent | 41a246d1ff75a95d2be3191ca6e6db139dc0f430 (diff) |
ext4: calculate and verify block bitmap checksum
Compute and verify the checksum of the block bitmap; this checksum is
stored in the block group descriptor.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r-- | fs/ext4/mballoc.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 99ab428bcfa0..95a388fef397 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -788,7 +788,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore) | |||
788 | int first_block; | 788 | int first_block; |
789 | struct super_block *sb; | 789 | struct super_block *sb; |
790 | struct buffer_head *bhs; | 790 | struct buffer_head *bhs; |
791 | struct buffer_head **bh; | 791 | struct buffer_head **bh = NULL; |
792 | struct inode *inode; | 792 | struct inode *inode; |
793 | char *data; | 793 | char *data; |
794 | char *bitmap; | 794 | char *bitmap; |
@@ -2797,6 +2797,8 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, | |||
2797 | } | 2797 | } |
2798 | len = ext4_free_group_clusters(sb, gdp) - ac->ac_b_ex.fe_len; | 2798 | len = ext4_free_group_clusters(sb, gdp) - ac->ac_b_ex.fe_len; |
2799 | ext4_free_group_clusters_set(sb, gdp, len); | 2799 | ext4_free_group_clusters_set(sb, gdp, len); |
2800 | ext4_block_bitmap_csum_set(sb, ac->ac_b_ex.fe_group, gdp, bitmap_bh, | ||
2801 | EXT4_BLOCKS_PER_GROUP(sb) / 8); | ||
2800 | gdp->bg_checksum = ext4_group_desc_csum(sbi, ac->ac_b_ex.fe_group, gdp); | 2802 | gdp->bg_checksum = ext4_group_desc_csum(sbi, ac->ac_b_ex.fe_group, gdp); |
2801 | 2803 | ||
2802 | ext4_unlock_group(sb, ac->ac_b_ex.fe_group); | 2804 | ext4_unlock_group(sb, ac->ac_b_ex.fe_group); |
@@ -4659,6 +4661,8 @@ do_more: | |||
4659 | 4661 | ||
4660 | ret = ext4_free_group_clusters(sb, gdp) + count_clusters; | 4662 | ret = ext4_free_group_clusters(sb, gdp) + count_clusters; |
4661 | ext4_free_group_clusters_set(sb, gdp, ret); | 4663 | ext4_free_group_clusters_set(sb, gdp, ret); |
4664 | ext4_block_bitmap_csum_set(sb, block_group, gdp, bitmap_bh, | ||
4665 | EXT4_BLOCKS_PER_GROUP(sb) / 8); | ||
4662 | gdp->bg_checksum = ext4_group_desc_csum(sbi, block_group, gdp); | 4666 | gdp->bg_checksum = ext4_group_desc_csum(sbi, block_group, gdp); |
4663 | ext4_unlock_group(sb, block_group); | 4667 | ext4_unlock_group(sb, block_group); |
4664 | percpu_counter_add(&sbi->s_freeclusters_counter, count_clusters); | 4668 | percpu_counter_add(&sbi->s_freeclusters_counter, count_clusters); |
@@ -4803,6 +4807,8 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb, | |||
4803 | mb_free_blocks(NULL, &e4b, bit, count); | 4807 | mb_free_blocks(NULL, &e4b, bit, count); |
4804 | blk_free_count = blocks_freed + ext4_free_group_clusters(sb, desc); | 4808 | blk_free_count = blocks_freed + ext4_free_group_clusters(sb, desc); |
4805 | ext4_free_group_clusters_set(sb, desc, blk_free_count); | 4809 | ext4_free_group_clusters_set(sb, desc, blk_free_count); |
4810 | ext4_block_bitmap_csum_set(sb, block_group, desc, bitmap_bh, | ||
4811 | EXT4_BLOCKS_PER_GROUP(sb) / 8); | ||
4806 | desc->bg_checksum = ext4_group_desc_csum(sbi, block_group, desc); | 4812 | desc->bg_checksum = ext4_group_desc_csum(sbi, block_group, desc); |
4807 | ext4_unlock_group(sb, block_group); | 4813 | ext4_unlock_group(sb, block_group); |
4808 | percpu_counter_add(&sbi->s_freeclusters_counter, | 4814 | percpu_counter_add(&sbi->s_freeclusters_counter, |