Whamcloud - gitweb
LU-9510 ldiskfs: to not verify preallocation in umount path 30/27130/12
authorJadhav Vikram <vikramjadhav87@yahoo.co.in>
Wed, 3 Feb 2021 15:24:31 +0000 (23:24 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 22 Sep 2021 04:42:09 +0000 (04:42 +0000)
At umount time while discarding inode preallocation space, panic
occurred due to mismatch found in preallocation space free blocks
i.e pa->pa_free and free blocks calculated by reading on disk
block bitmap within preallocation space length. Similar crash will
occur when user sets errors=panic in mount option and if there is
mismatch in pa space free blocks.

Changes added to not verify mismatch in disk and in-memory
preallocated space unused blocks if the file system is being
umounted.

Seagate-bug-id: MRP-3741
Signed-off-by: Jadhav Vikram <vikramjadhav87@yahoo.co.in>
Signed-off-by: Jadhav Vikram <jadhav.vikram@seagate.com>
Reviewed-by: Alexey Leonidovich Lyashkov <alexey.lyashkov@seagate.com>
Reviewed-by: Ashish Purkar <ashish.purkar@seagate.com>
Tested-by: Elena V. Gryaznova <elena.gryaznova@seagate.com>
Change-Id: I6d43905d49a219d1a5b966ab405e974a1f29b2f3
Reviewed-on: https://review.whamcloud.com/27130
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
ldiskfs/kernel_patches/patches/rhel7.6/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
ldiskfs/kernel_patches/patches/rhel7.6/ext4-mballoc-pa-free-mismatch.patch
ldiskfs/kernel_patches/patches/rhel8.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
ldiskfs/kernel_patches/patches/rhel8/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
ldiskfs/kernel_patches/patches/ubuntu18/ext4-corrupted-inode-block-bitmaps-handling-patches-001.patch
ldiskfs/kernel_patches/patches/ubuntu18/ext4-corrupted-inode-block-bitmaps-handling-patches.patch

index 26a0f6e..31cbc2d 100644 (file)
@@ -240,9 +240,9 @@ Index: linux-stage/fs/ext4/mballoc.c
        }
        return 0;
 @@ -3961,16 +3972,8 @@ ext4_mb_release_inode_pa(struct ext4_bud
-       /* "free < pa->pa_free" means we maybe double alloc the same blocks,
         * otherwise maybe leave some free blocks unavailable, no need to BUG.*/
-       if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) {
+       if (((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) &&
+           atomic_read(&sb->s_active) > 0) {
 -              ext4_error(sb, "pa free mismatch: [pa %p] "
 -                              "[phy %lu] [logic %lu] [len %u] [free %u] "
 -                              "[error %u] [inode %lu] [freed %u]", pa,
index a8aad4a..1e4fdeb 100644 (file)
@@ -28,7 +28,7 @@ Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/mballoc.c
        ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
        grp_blk_start = pa->pa_pstart - EXT4_C2B(sbi, bit);
        BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
-@@ -3891,12 +3895,18 @@ ext4_mb_release_inode_pa(struct ext4_bud
+@@ -3891,12 +3895,19 @@ ext4_mb_release_inode_pa(struct ext4_bud
                mb_free_blocks(pa->pa_inode, e4b, bit, next - bit);
                bit = next + 1;
        }
@@ -41,7 +41,8 @@ Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/mballoc.c
 +
 +      /* "free < pa->pa_free" means we maybe double alloc the same blocks,
 +       * otherwise maybe leave some free blocks unavailable, no need to BUG.*/
-+      if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) {
++      if (((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) &&
++          atomic_read(&sb->s_active) > 0) {
 +              ext4_error(sb, "pa free mismatch: [pa %p] "
 +                              "[phy %lu] [logic %lu] [len %u] [free %u] "
 +                              "[error %u] [inode %lu] [freed %u]", pa,
@@ -58,7 +59,7 @@ Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/mballoc.c
                 */
        }
 +      /* do not verify if the file system is being umounted */
-+      BUG_ON(atomic_read(&sb->s_active) > 0 && pa->pa_free != free);
++      BUG_ON(pa->pa_free != free && atomic_read(&sb->s_active) > 0);
        atomic_add(free, &sbi->s_mb_discarded);
  
        return err;
index 4a7c33e..a3b2627 100644 (file)
@@ -124,9 +124,9 @@ Index: linux-4.18.0-240.1.1.el8/fs/ext4/mballoc.c
        }
        return 0;
 @@ -4037,16 +4044,8 @@ ext4_mb_release_inode_pa(struct ext4_bud
-       /* "free < pa->pa_free" means we maybe double alloc the same blocks,
         * otherwise maybe leave some free blocks unavailable, no need to BUG.*/
-       if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) {
+       if (((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) &&
+           atomic_read(&sb->s_active) > 0) {
 -              ext4_error(sb, "pa free mismatch: [pa %p] "
 -                              "[phy %lu] [logic %lu] [len %u] [free %u] "
 -                              "[error %u] [inode %lu] [freed %u]", pa,
index 38e1862..a9b02c7 100644 (file)
@@ -124,9 +124,9 @@ Index: linux-4.18.0-80.1.2.el8_0/fs/ext4/mballoc.c
        }
        return 0;
 @@ -4016,16 +4023,8 @@ ext4_mb_release_inode_pa(struct ext4_bud
-       /* "free < pa->pa_free" means we maybe double alloc the same blocks,
         * otherwise maybe leave some free blocks unavailable, no need to BUG.*/
-       if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) {
+       if (((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) &&
+           atomic_read(&sb->s_active) > 0) {
 -              ext4_error(sb, "pa free mismatch: [pa %p] "
 -                              "[phy %lu] [logic %lu] [len %u] [free %u] "
 -                              "[error %u] [inode %lu] [freed %u]", pa,
index 8eb7add..91c1b46 100644 (file)
@@ -241,9 +241,9 @@ Index: linux-4.15.0/fs/ext4/mballoc.c
        }
        return 0;
 @@ -4052,16 +4063,8 @@ ext4_mb_release_inode_pa(struct ext4_bud
-       /* "free < pa->pa_free" means we maybe double alloc the same blocks,
         * otherwise maybe leave some free blocks unavailable, no need to BUG.*/
-       if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) {
+       if (((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) &&
+           atomic_read(&sb->s_active) > 0) {
 -              ext4_error(sb, "pa free mismatch: [pa %p] "
 -                              "[phy %lu] [logic %lu] [len %u] [free %u] "
 -                              "[error %u] [inode %lu] [freed %u]", pa,
index 526e8e9..9062641 100644 (file)
@@ -280,9 +280,9 @@ Index: linux-4.15.0/fs/ext4/mballoc.c
        }
        return 0;
 @@ -4052,16 +4063,8 @@ ext4_mb_release_inode_pa(struct ext4_bud
-       /* "free < pa->pa_free" means we maybe double alloc the same blocks,
         * otherwise maybe leave some free blocks unavailable, no need to BUG.*/
-       if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) {
+       if (((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) &&
+           atomic_read(&sb->s_active) > 0) {
 -              ext4_error(sb, "pa free mismatch: [pa %p] "
 -                              "[phy %lu] [logic %lu] [len %u] [free %u] "
 -                              "[error %u] [inode %lu] [freed %u]", pa,