1 ext4: mark block bitmap corrupted when found
3 From: Wang Shilong <wshilong@ddn.com>
5 There are still some cases that we missed to set
6 block bitmaps corrupted bit properly:
8 1) block bitmap number is wrong.
9 2) failed to read block bitmap due to disk errors.
10 3) double free block bitmaps..
11 4) some mismatch check with bitmaps vs buddy information.
13 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
14 Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
15 Signed-off-by: Wang Shilong <wshilong@ddn.com>
16 Reviewed-by: Liu Bo <bo.liu@linux.alibaba.com>
17 Reviewed-by: Andreas Dilger <adilger@dilger.ca>
19 fs/ext4/balloc.c | 4 ++++
20 fs/ext4/mballoc.c | 6 ++++++
21 2 files changed, 10 insertions(+)
23 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
24 index 009dea942e34..b00481c475cb 100644
25 --- a/fs/ext4/balloc.c
26 +++ b/fs/ext4/balloc.c
27 @@ -421,6 +421,8 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
28 (bitmap_blk >= ext4_blocks_count(sbi->s_es))) {
29 ext4_error(sb, "Invalid block bitmap block %llu in "
30 "block_group %u", bitmap_blk, block_group);
31 + ext4_mark_group_bitmap_corrupted(sb, block_group,
32 + EXT4_GROUP_INFO_BBITMAP_CORRUPT);
33 return ERR_PTR(-EFSCORRUPTED);
35 bh = sb_getblk(sb, bitmap_blk);
36 @@ -499,6 +501,8 @@ int ext4_wait_block_bitmap(struct super_block *sb, ext4_group_t block_group,
37 ext4_error(sb, "Cannot read block bitmap - "
38 "block_group = %u, block_bitmap = %llu",
39 block_group, (unsigned long long) bh->b_blocknr);
40 + ext4_mark_group_bitmap_corrupted(sb, block_group,
41 + EXT4_GROUP_INFO_BBITMAP_CORRUPT);
45 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
46 index bc2d1eb9fd5d..0d473991eebd 100644
47 --- a/fs/ext4/mballoc.c
48 +++ b/fs/ext4/mballoc.c
49 @@ -470,6 +470,8 @@ static void mb_free_blocks_double(struct inode *inode, struct ext4_buddy *e4b,
50 "freeing block already freed "
53 + ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group,
54 + EXT4_GROUP_INFO_BBITMAP_CORRUPT);
56 mb_clear_bit(first + i, e4b->bd_info->bb_bitmap);
58 @@ -1950,6 +1952,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
59 "%d free clusters as per "
60 "group info. But bitmap says 0",
62 + ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group,
63 + EXT4_GROUP_INFO_BBITMAP_CORRUPT);
67 @@ -1960,6 +1964,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
68 "%d free clusters as per "
69 "group info. But got %d blocks",
71 + ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group,
72 + EXT4_GROUP_INFO_BBITMAP_CORRUPT);
74 * The number of free blocks differs. This mostly
75 * indicate that the bitmap is corrupt. So exit