From 5506c15a65b3eebb9f15000105e6eb7c02742a10 Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Thu, 10 Aug 2017 02:30:02 +0800 Subject: [PATCH] LU-9410 ldiskfs: no check mb bitmap if flex_bg enabled When initializes (reformat) the filesystem, the number of free blocks in the group descriptor is calculated via the ext2fs_reserve_super_and_bgd() (e2fsprogs). As commented in such function: "This is not necessarily the case when the flex_bg feature is enabled, so callers should take care!". So it is normal that we may find the block group descriptor that has LDISKFS_BG_BLOCK_UNINIT flag but with 0 free blocks. The ldiskfs_mb_check_ondisk_bitmap() should NOT report error for such block group, instead, skip the check directly. Signed-off-by: Fan Yong Change-Id: Iba0fb2bf0632a6e54222472bc724a8ea0478e9ae Reviewed-on: https://review.whamcloud.com/28566 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Tested-by: Maloo Reviewed-by: Oleg Drokin --- .../patches/rhel6.3/ext4-mballoc-extra-checks.patch | 10 +++++++--- .../ext4-corrupted-inode-block-bitmaps-handling-patches.patch | 6 +++--- .../ext4-corrupted-inode-block-bitmaps-handling-patches.patch | 6 +++--- .../ext4-corrupted-inode-block-bitmaps-handling-patches.patch | 6 +++--- .../patches/rhel7/ext4-mballoc-extra-checks.patch | 10 +++++++--- .../ext4-corrupted-inode-block-bitmaps-handling-patches.patch | 6 +++--- .../patches/sles11sp2/ext4-mballoc-extra-checks.patch | 10 +++++++--- .../ext4-corrupted-inode-block-bitmaps-handling-patches.patch | 6 +++--- .../patches/sles12sp2/ext4-mballoc-extra-checks.patch | 10 +++++++--- 9 files changed, 43 insertions(+), 27 deletions(-) diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-mballoc-extra-checks.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-mballoc-extra-checks.patch index 91b728d..d0ef621 100644 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-mballoc-extra-checks.patch +++ b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-mballoc-extra-checks.patch @@ -148,7 +148,7 @@ Index: linux-stage/fs/ext4/mballoc.c for (i = 0; i <= 13; i++) seq_printf(seq, " %-5u", i <= sb->s_blocksize_bits + 1 ? sg.info.bb_counters[i] : 0); -@@ -3354,23 +3365,68 @@ +@@ -3354,23 +3365,72 @@ } /* @@ -162,6 +162,10 @@ Index: linux-stage/fs/ext4/mballoc.c +{ + unsigned short max = EXT4_BLOCKS_PER_GROUP(sb); + unsigned short i, first, free = 0; ++ unsigned short free_in_gdp = ext4_free_blks_count(sb, gdp); ++ ++ if (free_in_gdp == 0 && gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) ++ return 0; + + i = mb_find_next_zero_bit(bitmap, max, 0); + @@ -175,10 +179,10 @@ Index: linux-stage/fs/ext4/mballoc.c + i = mb_find_next_zero_bit(bitmap, max, i); + } + -+ if (free != ext4_free_blks_count(sb, gdp)) { ++ if (free != free_in_gdp) { + ext4_error(sb, "on-disk bitmap for group %d" + "corrupted: %u blocks free in bitmap, %u - in gd\n", -+ group, free, ext4_free_blks_count(sb, gdp)); ++ group, free, free_in_gdp); + return -EIO; + } + return 0; diff --git a/ldiskfs/kernel_patches/patches/rhel6.6/ext4-corrupted-inode-block-bitmaps-handling-patches.patch b/ldiskfs/kernel_patches/patches/rhel6.6/ext4-corrupted-inode-block-bitmaps-handling-patches.patch index 8ab3de5..568d552 100644 --- a/ldiskfs/kernel_patches/patches/rhel6.6/ext4-corrupted-inode-block-bitmaps-handling-patches.patch +++ b/ldiskfs/kernel_patches/patches/rhel6.6/ext4-corrupted-inode-block-bitmaps-handling-patches.patch @@ -249,14 +249,14 @@ index efcf909..06cd929 100644 @@ -3382,9 +3401,10 @@ int ext4_mb_check_ondisk_bitmap(struct super_block *sb, void *bitmap, } - if (free != ext4_free_blks_count(sb, gdp)) { + if (free != free_in_gdp) { - ext4_error(sb, "on-disk bitmap for group %d" - "corrupted: %u blocks free in bitmap, %u - in gd\n", -- group, free, ext4_free_blks_count(sb, gdp)); +- group, free, free_in_gdp); + ext4_corrupted_block_group(sb, group, + EXT4_GROUP_INFO_BBITMAP_CORRUPT, + "on-disk bitmap for group %d corrupted: %u blocks free in bitmap, %u - in gd\n", -+ group, free, ext4_free_blks_count(sb, gdp)); ++ group, free, free_in_gdp); return -EIO; } return 0; diff --git a/ldiskfs/kernel_patches/patches/rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch b/ldiskfs/kernel_patches/patches/rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch index 247f753..60f63c5 100644 --- a/ldiskfs/kernel_patches/patches/rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch +++ b/ldiskfs/kernel_patches/patches/rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch @@ -259,15 +259,15 @@ Index: linux-stage/fs/ext4/mballoc.c @@ -3598,9 +3607,11 @@ int ext4_mb_check_ondisk_bitmap(struct s } - if (free != ext4_free_group_clusters(sb, gdp)) { + if (free != free_in_gdp) { - ext4_error(sb, "on-disk bitmap for group %d" - "corrupted: %u blocks free in bitmap, %u - in gd\n", -- group, free, ext4_free_group_clusters(sb, gdp)); +- group, free, free_in_gdp); + ext4_corrupted_block_group(sb, group, + EXT4_GROUP_INFO_BBITMAP_CORRUPT, + "on-disk bitmap for group %d corrupted: %u blocks free in bitmap, %u - in gd\n", + group, free, -+ ext4_free_group_clusters(sb, gdp)); ++ free_in_gdp); return -EIO; } return 0; diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch index a8b4e38..0544193 100644 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch +++ b/ldiskfs/kernel_patches/patches/rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch @@ -260,15 +260,15 @@ index 7282d07..e6805e6 100644 @@ -3599,9 +3608,11 @@ int ext4_mb_check_ondisk_bitmap(struct super_block *sb, void *bitmap, } - if (free != ext4_free_group_clusters(sb, gdp)) { + if (free != free_in_gdp) { - ext4_error(sb, "on-disk bitmap for group %d" - "corrupted: %u blocks free in bitmap, %u - in gd\n", -- group, free, ext4_free_group_clusters(sb, gdp)); +- group, free, free_in_gdp); + ext4_corrupted_block_group(sb, group, + EXT4_GROUP_INFO_BBITMAP_CORRUPT, + "on-disk bitmap for group %d corrupted: %u blocks free in bitmap, %u - in gd\n", + group, free, -+ ext4_free_group_clusters(sb, gdp)); ++ free_in_gdp); return -EIO; } return 0; diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-extra-checks.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-extra-checks.patch index ac71448..c1dd290 100644 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-extra-checks.patch +++ b/ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-extra-checks.patch @@ -152,7 +152,7 @@ Index: linux-3.10.0-123.el7.x86_64/fs/ext4/mballoc.c for (i = 0; i <= 13; i++) seq_printf(seq, " %-5u", i <= sb->s_blocksize_bits + 1 ? sg.info.bb_counters[i] : 0); -@@ -3507,22 +3517,67 @@ static void ext4_mb_generate_from_freeli +@@ -3507,22 +3517,71 @@ static void ext4_mb_generate_from_freeli } /* @@ -166,6 +166,10 @@ Index: linux-3.10.0-123.el7.x86_64/fs/ext4/mballoc.c +{ + unsigned short max = EXT4_CLUSTERS_PER_GROUP(sb); + unsigned short i, first, free = 0; ++ unsigned short free_in_gdp = ext4_free_group_clusters(sb, gdp); ++ ++ if (free_in_gdp == 0 && gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) ++ return 0; + + i = mb_find_next_zero_bit(bitmap, max, 0); + @@ -179,10 +183,10 @@ Index: linux-3.10.0-123.el7.x86_64/fs/ext4/mballoc.c + i = mb_find_next_zero_bit(bitmap, max, i); + } + -+ if (free != ext4_free_group_clusters(sb, gdp)) { ++ if (free != free_in_gdp) { + ext4_error(sb, "on-disk bitmap for group %d" + "corrupted: %u blocks free in bitmap, %u - in gd\n", -+ group, free, ext4_free_group_clusters(sb, gdp)); ++ group, free, free_in_gdp); + return -EIO; + } + return 0; diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch index 2f4a2a8..3b845e2 100644 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch +++ b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch @@ -236,15 +236,15 @@ index 1d77581..4d6558e 100644 @@ -3458,9 +3471,11 @@ int ext4_mb_check_ondisk_bitmap(struct super_block *sb, void *bitmap, } - if (free != ext4_free_blks_count(sb, gdp)) { + if (free != free_in_gdp) { - ext4_error(sb, "on-disk bitmap for group %d" - "corrupted: %u blocks free in bitmap, %u - in gd\n", -- group, free, ext4_free_blks_count(sb, gdp)); +- group, free, free_in_gdp); + ext4_corrupted_block_group(sb, group, + EXT4_GROUP_INFO_BBITMAP_CORRUPT, + "on-disk bitmap for group %d corrupted: %u blocks free in bitmap, %u - in gd\n", + group, free, -+ ext4_free_blks_count(sb, gdp)); ++ free_in_gdp); return -EIO; } return 0; diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-extra-checks.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-extra-checks.patch index fbe60f7..69af7c4 100644 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-extra-checks.patch +++ b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-extra-checks.patch @@ -150,7 +150,7 @@ for (i = 0; i <= 13; i++) seq_printf(seq, " %-5u", i <= sb->s_blocksize_bits + 1 ? sg.info.bb_counters[i] : 0); -@@ -3417,23 +3434,68 @@ static void ext4_mb_generate_from_freeli +@@ -3417,23 +3434,72 @@ static void ext4_mb_generate_from_freeli } /* @@ -164,6 +164,10 @@ +{ + unsigned short max = EXT4_BLOCKS_PER_GROUP(sb); + unsigned short i, first, free = 0; ++ unsigned short free_in_gdp = ext4_free_blks_count(sb, gdp); ++ ++ if (free_in_gdp == 0 && gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) ++ return 0; + + i = mb_find_next_zero_bit(bitmap, max, 0); + @@ -177,10 +181,10 @@ + i = mb_find_next_zero_bit(bitmap, max, i); + } + -+ if (free != ext4_free_blks_count(sb, gdp)) { ++ if (free != free_in_gdp) { + ext4_error(sb, "on-disk bitmap for group %d" + "corrupted: %u blocks free in bitmap, %u - in gd\n", -+ group, free, ext4_free_blks_count(sb, gdp)); ++ group, free, free_in_gdp); + return -EIO; + } + return 0; diff --git a/ldiskfs/kernel_patches/patches/sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch b/ldiskfs/kernel_patches/patches/sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch index a1fcea9..03ef2d3 100644 --- a/ldiskfs/kernel_patches/patches/sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch +++ b/ldiskfs/kernel_patches/patches/sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch @@ -237,15 +237,15 @@ index 7282d07..e6805e6 100644 @@ -3599,9 +3608,11 @@ int ext4_mb_check_ondisk_bitmap(struct super_block *sb, void *bitmap, } - if (free != ext4_free_group_clusters(sb, gdp)) { + if (free != free_in_gdp) { - ext4_error(sb, "on-disk bitmap for group %d" - "corrupted: %u blocks free in bitmap, %u - in gd\n", -- group, free, ext4_free_group_clusters(sb, gdp)); +- group, free, free_in_gdp); + ext4_corrupted_block_group(sb, group, + EXT4_GROUP_INFO_BBITMAP_CORRUPT, + "on-disk bitmap for group %d corrupted: %u blocks free in bitmap, %u - in gd\n", + group, free, -+ ext4_free_group_clusters(sb, gdp)); ++ free_in_gdp); return -EIO; } return 0; diff --git a/ldiskfs/kernel_patches/patches/sles12sp2/ext4-mballoc-extra-checks.patch b/ldiskfs/kernel_patches/patches/sles12sp2/ext4-mballoc-extra-checks.patch index a0dda46..aa4933e 100644 --- a/ldiskfs/kernel_patches/patches/sles12sp2/ext4-mballoc-extra-checks.patch +++ b/ldiskfs/kernel_patches/patches/sles12sp2/ext4-mballoc-extra-checks.patch @@ -148,7 +148,7 @@ Index: linux-3.10.0-123.el7.x86_64/fs/ext4/mballoc.c for (i = 0; i <= 13; i++) seq_printf(seq, " %-5u", i <= sb->s_blocksize_bits + 1 ? sg.info.bb_counters[i] : 0); -@@ -3507,22 +3517,67 @@ static void ext4_mb_generate_from_freeli +@@ -3507,22 +3517,71 @@ static void ext4_mb_generate_from_freeli } /* @@ -162,6 +162,10 @@ Index: linux-3.10.0-123.el7.x86_64/fs/ext4/mballoc.c +{ + unsigned short max = EXT4_CLUSTERS_PER_GROUP(sb); + unsigned short i, first, free = 0; ++ unsigned short free_in_gdp = ext4_free_group_clusters(sb, gdp); ++ ++ if (free_in_gdp == 0 && gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) ++ return 0; + + i = mb_find_next_zero_bit(bitmap, max, 0); + @@ -175,10 +179,10 @@ Index: linux-3.10.0-123.el7.x86_64/fs/ext4/mballoc.c + i = mb_find_next_zero_bit(bitmap, max, i); + } + -+ if (free != ext4_free_group_clusters(sb, gdp)) { ++ if (free != free_in_gdp) { + ext4_error(sb, "on-disk bitmap for group %d" + "corrupted: %u blocks free in bitmap, %u - in gd\n", -+ group, free, ext4_free_group_clusters(sb, gdp)); ++ group, free, free_in_gdp); + return -EIO; + } + return 0; -- 1.8.3.1