diff options
author | Tao Ma <boyu.mt@taobao.com> | 2012-10-22 00:34:32 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-10-22 00:34:32 -0400 |
commit | 79f1ba49569e5aec919b653c55b03274c2331701 (patch) | |
tree | 612d4200d13a10d5df0cb6508cc5b1e7fd10fd45 /fs/ext4/balloc.c | |
parent | 76495ec1d47e1c0fe0673faf9179bda6bc8ab5c2 (diff) |
ext4: Checksum the block bitmap properly with bigalloc enabled
In mke2fs, we only checksum the whole bitmap block and it is right.
While in the kernel, we use EXT4_BLOCKS_PER_GROUP to indicate the
size of the checksumed bitmap which is wrong when we enable bigalloc.
The right size should be EXT4_CLUSTERS_PER_GROUP and this patch fixes
it.
Also as every caller of ext4_block_bitmap_csum_set and
ext4_block_bitmap_csum_verify pass in EXT4_BLOCKS_PER_GROUP(sb)/8,
we'd better removes this parameter and sets it in the function itself.
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Cc: stable@vger.kernel.org
Diffstat (limited to 'fs/ext4/balloc.c')
-rw-r--r-- | fs/ext4/balloc.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 1b5089067d01..cf1821784a16 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
@@ -174,8 +174,7 @@ void ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, | |||
174 | ext4_free_inodes_set(sb, gdp, 0); | 174 | ext4_free_inodes_set(sb, gdp, 0); |
175 | ext4_itable_unused_set(sb, gdp, 0); | 175 | ext4_itable_unused_set(sb, gdp, 0); |
176 | memset(bh->b_data, 0xff, sb->s_blocksize); | 176 | memset(bh->b_data, 0xff, sb->s_blocksize); |
177 | ext4_block_bitmap_csum_set(sb, block_group, gdp, bh, | 177 | ext4_block_bitmap_csum_set(sb, block_group, gdp, bh); |
178 | EXT4_BLOCKS_PER_GROUP(sb) / 8); | ||
179 | return; | 178 | return; |
180 | } | 179 | } |
181 | memset(bh->b_data, 0, sb->s_blocksize); | 180 | memset(bh->b_data, 0, sb->s_blocksize); |
@@ -212,8 +211,7 @@ void ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, | |||
212 | */ | 211 | */ |
213 | ext4_mark_bitmap_end(num_clusters_in_group(sb, block_group), | 212 | ext4_mark_bitmap_end(num_clusters_in_group(sb, block_group), |
214 | sb->s_blocksize * 8, bh->b_data); | 213 | sb->s_blocksize * 8, bh->b_data); |
215 | ext4_block_bitmap_csum_set(sb, block_group, gdp, bh, | 214 | ext4_block_bitmap_csum_set(sb, block_group, gdp, bh); |
216 | EXT4_BLOCKS_PER_GROUP(sb) / 8); | ||
217 | ext4_group_desc_csum_set(sb, block_group, gdp); | 215 | ext4_group_desc_csum_set(sb, block_group, gdp); |
218 | } | 216 | } |
219 | 217 | ||
@@ -350,7 +348,7 @@ void ext4_validate_block_bitmap(struct super_block *sb, | |||
350 | return; | 348 | return; |
351 | } | 349 | } |
352 | if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group, | 350 | if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group, |
353 | desc, bh, EXT4_BLOCKS_PER_GROUP(sb) / 8))) { | 351 | desc, bh))) { |
354 | ext4_unlock_group(sb, block_group); | 352 | ext4_unlock_group(sb, block_group); |
355 | ext4_error(sb, "bg %u: bad block bitmap checksum", block_group); | 353 | ext4_error(sb, "bg %u: bad block bitmap checksum", block_group); |
356 | return; | 354 | return; |