diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2013-08-28 18:46:56 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-08-28 18:46:56 -0400 |
commit | bdfb6ff4a255dcebeb09a901250e13a97eff75af (patch) | |
tree | ae320a717aea5bf4f40d6e87816322ac7a79f3fb /fs/ext4 | |
parent | 87a39389be3e3b007d341be510a7e4a0542bdf05 (diff) |
ext4: mark group corrupt on group descriptor checksum
If the group descriptor fails validation, mark the whole blockgroup
corrupt so that the inode/block allocators skip this group. The
previous approach takes the risk of writing to a damaged group
descriptor; hopefully it was never the case that the [ib]bitmap fields
pointed to another valid block and got dirtied, since the memset would
fill the page with 1s.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/balloc.c | 9 | ||||
-rw-r--r-- | fs/ext4/ialloc.c | 10 |
2 files changed, 8 insertions, 11 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index d9b66c4a26e8..dc5d572ebd6a 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
@@ -184,6 +184,7 @@ void ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, | |||
184 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 184 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
185 | ext4_fsblk_t start, tmp; | 185 | ext4_fsblk_t start, tmp; |
186 | int flex_bg = 0; | 186 | int flex_bg = 0; |
187 | struct ext4_group_info *grp; | ||
187 | 188 | ||
188 | J_ASSERT_BH(bh, buffer_locked(bh)); | 189 | J_ASSERT_BH(bh, buffer_locked(bh)); |
189 | 190 | ||
@@ -191,11 +192,9 @@ void ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, | |||
191 | * essentially implementing a per-group read-only flag. */ | 192 | * essentially implementing a per-group read-only flag. */ |
192 | if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) { | 193 | if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) { |
193 | ext4_error(sb, "Checksum bad for group %u", block_group); | 194 | ext4_error(sb, "Checksum bad for group %u", block_group); |
194 | ext4_free_group_clusters_set(sb, gdp, 0); | 195 | grp = ext4_get_group_info(sb, block_group); |
195 | ext4_free_inodes_set(sb, gdp, 0); | 196 | set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &grp->bb_state); |
196 | ext4_itable_unused_set(sb, gdp, 0); | 197 | set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state); |
197 | memset(bh->b_data, 0xff, sb->s_blocksize); | ||
198 | ext4_block_bitmap_csum_set(sb, block_group, gdp, bh); | ||
199 | return; | 198 | return; |
200 | } | 199 | } |
201 | memset(bh->b_data, 0, sb->s_blocksize); | 200 | memset(bh->b_data, 0, sb->s_blocksize); |
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index d5106078595e..137193ff389b 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
@@ -70,18 +70,16 @@ static unsigned ext4_init_inode_bitmap(struct super_block *sb, | |||
70 | ext4_group_t block_group, | 70 | ext4_group_t block_group, |
71 | struct ext4_group_desc *gdp) | 71 | struct ext4_group_desc *gdp) |
72 | { | 72 | { |
73 | struct ext4_group_info *grp; | ||
73 | J_ASSERT_BH(bh, buffer_locked(bh)); | 74 | J_ASSERT_BH(bh, buffer_locked(bh)); |
74 | 75 | ||
75 | /* If checksum is bad mark all blocks and inodes use to prevent | 76 | /* If checksum is bad mark all blocks and inodes use to prevent |
76 | * allocation, essentially implementing a per-group read-only flag. */ | 77 | * allocation, essentially implementing a per-group read-only flag. */ |
77 | if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) { | 78 | if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) { |
78 | ext4_error(sb, "Checksum bad for group %u", block_group); | 79 | ext4_error(sb, "Checksum bad for group %u", block_group); |
79 | ext4_free_group_clusters_set(sb, gdp, 0); | 80 | grp = ext4_get_group_info(sb, block_group); |
80 | ext4_free_inodes_set(sb, gdp, 0); | 81 | set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &grp->bb_state); |
81 | ext4_itable_unused_set(sb, gdp, 0); | 82 | set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state); |
82 | memset(bh->b_data, 0xff, sb->s_blocksize); | ||
83 | ext4_inode_bitmap_csum_set(sb, block_group, gdp, bh, | ||
84 | EXT4_INODES_PER_GROUP(sb) / 8); | ||
85 | return 0; | 83 | return 0; |
86 | } | 84 | } |
87 | 85 | ||