From f7672143843a86656eaed5b9a8b89ce171b99d7a Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Thu, 22 Mar 2018 13:59:55 +0800 Subject: [PATCH] LU-10837 ldiskfs: skip bitmap check if block bitmap is uninitialized See comments in ext4_free_clusters_after_init: /* Return the number of free blocks in a block group. It is used when * the block bitmap is uninitialized, so we can't just count the bits * in the bitmap. */ So extra check we enhanced here is wrong if this block group bitmap is uninitialized, since we only check bitmaps here. Further, Looking at EXT4_BG_BLOCK_UNINIT clear codes, Kernel will reinit free_clusters_count when tried to clear the flag, so extra check for uninited block bitmaps dosen't make much sense. Let's skip uninited block bitmap check if EXT4_BG_BLOCK_UNINIT is set, whatever free count group desc recorded is untrustable somehow Change-Id: I845f2e0e17e53b7e3073399bd8b0a85e3db66ef8 Signed-off-by: Wang Shilong Reviewed-on: https://review.whamcloud.com/31720 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong Tested-by: Maloo --- ldiskfs/kernel_patches/patches/rhel6.3/ext4-mballoc-extra-checks.patch | 2 +- ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-extra-checks.patch | 2 +- .../kernel_patches/patches/sles11sp2/ext4-mballoc-extra-checks.patch | 2 +- .../kernel_patches/patches/sles12sp2/ext4-mballoc-extra-checks.patch | 2 +- .../kernel_patches/patches/sles12sp3/ext4-mballoc-extra-checks.patch | 2 +- 5 files changed, 5 insertions(+), 5 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 d0ef621..4b3104f 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 @@ -164,7 +164,7 @@ Index: linux-stage/fs/ext4/mballoc.c + 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)) ++ if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) + return 0; + + i = mb_find_next_zero_bit(bitmap, max, 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 c1dd290..34bba5c 100644 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-extra-checks.patch +++ b/ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-extra-checks.patch @@ -168,7 +168,7 @@ Index: linux-3.10.0-123.el7.x86_64/fs/ext4/mballoc.c + 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)) ++ if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) + return 0; + + i = mb_find_next_zero_bit(bitmap, max, 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 69af7c4..06029db 100644 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-extra-checks.patch +++ b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-extra-checks.patch @@ -166,7 +166,7 @@ + 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)) ++ if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) + return 0; + + i = mb_find_next_zero_bit(bitmap, max, 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 aa4933e..ba784b4 100644 --- a/ldiskfs/kernel_patches/patches/sles12sp2/ext4-mballoc-extra-checks.patch +++ b/ldiskfs/kernel_patches/patches/sles12sp2/ext4-mballoc-extra-checks.patch @@ -164,7 +164,7 @@ Index: linux-3.10.0-123.el7.x86_64/fs/ext4/mballoc.c + 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)) ++ if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) + return 0; + + i = mb_find_next_zero_bit(bitmap, max, 0); diff --git a/ldiskfs/kernel_patches/patches/sles12sp3/ext4-mballoc-extra-checks.patch b/ldiskfs/kernel_patches/patches/sles12sp3/ext4-mballoc-extra-checks.patch index cde9058..2092afc 100644 --- a/ldiskfs/kernel_patches/patches/sles12sp3/ext4-mballoc-extra-checks.patch +++ b/ldiskfs/kernel_patches/patches/sles12sp3/ext4-mballoc-extra-checks.patch @@ -164,7 +164,7 @@ Index: linux-3.10.0-123.el7.x86_64/fs/ext4/mballoc.c + 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)) ++ if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) + return 0; + + i = mb_find_next_zero_bit(bitmap, max, 0); -- 1.8.3.1