diff options
author | Wang Shilong <wshilong@ddn.com> | 2018-05-12 12:37:58 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2018-05-12 12:37:58 -0400 |
commit | 736dedbb1a7dcb669e4990884b5dd9d6aef0fc77 (patch) | |
tree | 9de6d65b6fb966425f5f86ed6bceb7364813f83b | |
parent | 206f6d552d0c0596cbc076a3249f7182f08a35d9 (diff) |
ext4: mark block bitmap corrupted when found
There are still some cases that we missed to set
block bitmaps corrupted bit properly:
1) block bitmap number is wrong.
2) failed to read block bitmap due to disk errors.
3) double free block bitmaps..
4) some mismatch check with bitmaps vs buddy information.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Liu Bo <bo.liu@linux.alibaba.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
-rw-r--r-- | fs/ext4/balloc.c | 4 | ||||
-rw-r--r-- | fs/ext4/mballoc.c | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 009dea942e34..b00481c475cb 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
@@ -421,6 +421,8 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group) | |||
421 | (bitmap_blk >= ext4_blocks_count(sbi->s_es))) { | 421 | (bitmap_blk >= ext4_blocks_count(sbi->s_es))) { |
422 | ext4_error(sb, "Invalid block bitmap block %llu in " | 422 | ext4_error(sb, "Invalid block bitmap block %llu in " |
423 | "block_group %u", bitmap_blk, block_group); | 423 | "block_group %u", bitmap_blk, block_group); |
424 | ext4_mark_group_bitmap_corrupted(sb, block_group, | ||
425 | EXT4_GROUP_INFO_BBITMAP_CORRUPT); | ||
424 | return ERR_PTR(-EFSCORRUPTED); | 426 | return ERR_PTR(-EFSCORRUPTED); |
425 | } | 427 | } |
426 | bh = sb_getblk(sb, bitmap_blk); | 428 | bh = sb_getblk(sb, bitmap_blk); |
@@ -499,6 +501,8 @@ int ext4_wait_block_bitmap(struct super_block *sb, ext4_group_t block_group, | |||
499 | ext4_error(sb, "Cannot read block bitmap - " | 501 | ext4_error(sb, "Cannot read block bitmap - " |
500 | "block_group = %u, block_bitmap = %llu", | 502 | "block_group = %u, block_bitmap = %llu", |
501 | block_group, (unsigned long long) bh->b_blocknr); | 503 | block_group, (unsigned long long) bh->b_blocknr); |
504 | ext4_mark_group_bitmap_corrupted(sb, block_group, | ||
505 | EXT4_GROUP_INFO_BBITMAP_CORRUPT); | ||
502 | return -EIO; | 506 | return -EIO; |
503 | } | 507 | } |
504 | clear_buffer_new(bh); | 508 | clear_buffer_new(bh); |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index bc2d1eb9fd5d..0d473991eebd 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -470,6 +470,8 @@ static void mb_free_blocks_double(struct inode *inode, struct ext4_buddy *e4b, | |||
470 | "freeing block already freed " | 470 | "freeing block already freed " |
471 | "(bit %u)", | 471 | "(bit %u)", |
472 | first + i); | 472 | first + i); |
473 | ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group, | ||
474 | EXT4_GROUP_INFO_BBITMAP_CORRUPT); | ||
473 | } | 475 | } |
474 | mb_clear_bit(first + i, e4b->bd_info->bb_bitmap); | 476 | mb_clear_bit(first + i, e4b->bd_info->bb_bitmap); |
475 | } | 477 | } |
@@ -1950,6 +1952,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, | |||
1950 | "%d free clusters as per " | 1952 | "%d free clusters as per " |
1951 | "group info. But bitmap says 0", | 1953 | "group info. But bitmap says 0", |
1952 | free); | 1954 | free); |
1955 | ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group, | ||
1956 | EXT4_GROUP_INFO_BBITMAP_CORRUPT); | ||
1953 | break; | 1957 | break; |
1954 | } | 1958 | } |
1955 | 1959 | ||
@@ -1960,6 +1964,8 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, | |||
1960 | "%d free clusters as per " | 1964 | "%d free clusters as per " |
1961 | "group info. But got %d blocks", | 1965 | "group info. But got %d blocks", |
1962 | free, ex.fe_len); | 1966 | free, ex.fe_len); |
1967 | ext4_mark_group_bitmap_corrupted(sb, e4b->bd_group, | ||
1968 | EXT4_GROUP_INFO_BBITMAP_CORRUPT); | ||
1963 | /* | 1969 | /* |
1964 | * The number of free blocks differs. This mostly | 1970 | * The number of free blocks differs. This mostly |
1965 | * indicate that the bitmap is corrupt. So exit | 1971 | * indicate that the bitmap is corrupt. So exit |