1 Since we could skip corrupt block groups, this patch
2 use ext4_warning() intead of ext4_error() to make FS not
5 Index: linux-4.18.0-80.1.2.el8_0/fs/ext4/balloc.c
6 ===================================================================
7 --- linux-4.18.0-80.1.2.el8_0.orig/fs/ext4/balloc.c
8 +++ linux-4.18.0-80.1.2.el8_0/fs/ext4/balloc.c
9 @@ -373,7 +373,7 @@ static int ext4_validate_block_bitmap(st
10 if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group,
12 ext4_unlock_group(sb, block_group);
13 - ext4_error(sb, "bg %u: bad block bitmap checksum", block_group);
14 + ext4_warning(sb, "bg %u: bad block bitmap checksum", block_group);
15 ext4_mark_group_bitmap_corrupted(sb, block_group,
16 EXT4_GROUP_INFO_BBITMAP_CORRUPT);
18 @@ -381,8 +381,8 @@ static int ext4_validate_block_bitmap(st
19 blk = ext4_valid_block_bitmap(sb, desc, block_group, bh);
20 if (unlikely(blk != 0)) {
21 ext4_unlock_group(sb, block_group);
22 - ext4_error(sb, "bg %u: block %llu: invalid block bitmap",
24 + ext4_warning(sb, "bg %u: block %llu: invalid block bitmap",
26 ext4_mark_group_bitmap_corrupted(sb, block_group,
27 EXT4_GROUP_INFO_BBITMAP_CORRUPT);
29 @@ -458,8 +458,8 @@ ext4_read_block_bitmap_nowait(struct sup
30 ext4_unlock_group(sb, block_group);
33 - ext4_error(sb, "Failed to init block bitmap for group "
34 - "%u: %d", block_group, err);
35 + ext4_warning(sb, "Failed to init block bitmap for group "
36 + "%u: %d", block_group, err);
40 Index: linux-4.18.0-80.1.2.el8_0/fs/ext4/ialloc.c
41 ===================================================================
42 --- linux-4.18.0-80.1.2.el8_0.orig/fs/ext4/ialloc.c
43 +++ linux-4.18.0-80.1.2.el8_0/fs/ext4/ialloc.c
44 @@ -96,8 +96,8 @@ static int ext4_validate_inode_bitmap(st
45 if (!ext4_inode_bitmap_csum_verify(sb, block_group, desc, bh,
46 EXT4_INODES_PER_GROUP(sb) / 8)) {
47 ext4_unlock_group(sb, block_group);
48 - ext4_error(sb, "Corrupt inode bitmap - block_group = %u, "
49 - "inode_bitmap = %llu", block_group, blk);
50 + ext4_warning(sb, "Corrupt inode bitmap - block_group = %u, "
51 + "inode_bitmap = %llu", block_group, blk);
52 ext4_mark_group_bitmap_corrupted(sb, block_group,
53 EXT4_GROUP_INFO_IBITMAP_CORRUPT);
55 @@ -346,7 +346,7 @@ out:
59 - ext4_error(sb, "bit already cleared for inode %lu", ino);
60 + ext4_warning(sb, "bit already cleared for inode %lu", ino);
61 ext4_mark_group_bitmap_corrupted(sb, block_group,
62 EXT4_GROUP_INFO_IBITMAP_CORRUPT);
64 Index: linux-4.18.0-80.1.2.el8_0/fs/ext4/mballoc.c
65 ===================================================================
66 --- linux-4.18.0-80.1.2.el8_0.orig/fs/ext4/mballoc.c
67 +++ linux-4.18.0-80.1.2.el8_0/fs/ext4/mballoc.c
68 @@ -741,10 +741,14 @@ int ext4_mb_generate_buddy(struct super_
69 grp->bb_fragments = fragments;
71 if (free != grp->bb_free) {
72 - ext4_grp_locked_error(sb, group, 0, 0,
73 - "block bitmap and bg descriptor "
74 - "inconsistent: %u vs %u free clusters",
75 - free, grp->bb_free);
76 + struct ext4_group_desc *gdp;
77 + gdp = ext4_get_group_desc(sb, group, NULL);
78 + ext4_warning(sb, "group %lu: block bitmap and bg descriptor "
79 + "inconsistent: %u vs %u free clusters "
80 + "%u in gd, %lu pa's",
81 + (long unsigned int)group, free, grp->bb_free,
82 + ext4_free_group_clusters(sb, gdp),
83 + grp->bb_prealloc_nr);
85 * If we intend to continue, we consider group descriptor
86 * corrupt and update bb_free using bitmap value
87 @@ -1107,7 +1111,7 @@ ext4_mb_load_buddy_gfp(struct super_bloc
92 + struct page *page = NULL;
94 struct ext4_group_info *grp;
95 struct ext4_sb_info *sbi = EXT4_SB(sb);
96 @@ -1133,7 +1137,7 @@ ext4_mb_load_buddy_gfp(struct super_bloc
98 ret = ext4_mb_init_group(sb, group, gfp);
105 @@ -1236,6 +1240,7 @@ err:
106 put_page(e4b->bd_buddy_page);
107 e4b->bd_buddy = NULL;
108 e4b->bd_bitmap = NULL;
109 + ext4_warning(sb, "Error loading buddy information for %u", group);
113 @@ -3654,9 +3659,11 @@ int ext4_mb_check_ondisk_bitmap(struct s
116 if (free != free_in_gdp) {
117 - ext4_error(sb, "on-disk bitmap for group %d"
118 + ext4_warning(sb, "on-disk bitmap for group %d"
119 "corrupted: %u blocks free in bitmap, %u - in gd\n",
120 group, free, free_in_gdp);
121 + ext4_mark_group_bitmap_corrupted(sb, group,
122 + EXT4_GROUP_INFO_BBITMAP_CORRUPT);
126 @@ -4016,16 +4023,8 @@ ext4_mb_release_inode_pa(struct ext4_bud
127 /* "free < pa->pa_free" means we maybe double alloc the same blocks,
128 * otherwise maybe leave some free blocks unavailable, no need to BUG.*/
129 if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) {
130 - ext4_error(sb, "pa free mismatch: [pa %p] "
131 - "[phy %lu] [logic %lu] [len %u] [free %u] "
132 - "[error %u] [inode %lu] [freed %u]", pa,
133 - (unsigned long)pa->pa_pstart,
134 - (unsigned long)pa->pa_lstart,
135 - (unsigned)pa->pa_len, (unsigned)pa->pa_free,
136 - (unsigned)pa->pa_error, pa->pa_inode->i_ino,
138 ext4_grp_locked_error(sb, group, 0, 0, "free %u, pa_free %u",
139 - free, pa->pa_free);
140 + free, pa->pa_free);
142 * pa is already deleted so we use the value obtained
143 * from the bitmap and continue.
144 @@ -4087,15 +4086,11 @@ ext4_mb_discard_group_preallocations(str
145 bitmap_bh = ext4_read_block_bitmap(sb, group);
146 if (IS_ERR(bitmap_bh)) {
147 err = PTR_ERR(bitmap_bh);
148 - ext4_error(sb, "Error %d reading block bitmap for %u",
153 err = ext4_mb_load_buddy(sb, group, &e4b);
155 - ext4_warning(sb, "Error %d loading buddy information for %u",
160 @@ -4256,17 +4251,12 @@ repeat:
162 err = ext4_mb_load_buddy_gfp(sb, group, &e4b,
163 GFP_NOFS|__GFP_NOFAIL);
165 - ext4_error(sb, "Error %d loading buddy information for %u",
171 bitmap_bh = ext4_read_block_bitmap(sb, group);
172 if (IS_ERR(bitmap_bh)) {
173 err = PTR_ERR(bitmap_bh);
174 - ext4_error(sb, "Error %d reading block bitmap for %u",
176 ext4_mb_unload_buddy(&e4b);
179 @@ -4529,11 +4519,8 @@ ext4_mb_discard_lg_preallocations(struct
180 group = ext4_get_group_number(sb, pa->pa_pstart);
181 err = ext4_mb_load_buddy_gfp(sb, group, &e4b,
182 GFP_NOFS|__GFP_NOFAIL);
184 - ext4_error(sb, "Error %d loading buddy information for %u",
189 ext4_lock_group(sb, group);
190 list_del(&pa->pa_group_list);
191 ext4_get_group_info(sb, group)->bb_prealloc_nr--;
192 @@ -4786,7 +4773,7 @@ errout:
193 * been updated or not when fail case. So can
194 * not revert pa_free back, just mark pa_error*/
198 "Updating bitmap error: [err %d] "
199 "[pa %p] [phy %lu] [logic %lu] "
200 "[len %u] [free %u] [error %u] "
201 @@ -4797,6 +4784,7 @@ errout:
202 (unsigned)pa->pa_free,
203 (unsigned)pa->pa_error,
204 pa->pa_inode ? pa->pa_inode->i_ino : 0);
205 + ext4_mark_group_bitmap_corrupted(sb, 0, 0);
208 ext4_mb_release_context(ac);
209 @@ -5082,7 +5070,7 @@ do_more:
210 err = ext4_mb_load_buddy_gfp(sb, block_group, &e4b,
211 GFP_NOFS|__GFP_NOFAIL);
217 * We need to make sure we don't reuse the freed block until after the
218 @@ -5164,8 +5152,9 @@ do_more:
223 ext4_std_error(sb, err);
229 @@ -5265,7 +5254,7 @@ int ext4_group_add_blocks(handle_t *hand
231 err = ext4_mb_load_buddy(sb, block_group, &e4b);
237 * need to update group_info->bb_free and bitmap
238 @@ -5303,8 +5292,9 @@ int ext4_group_add_blocks(handle_t *hand
243 ext4_std_error(sb, err);
249 @@ -5379,11 +5369,8 @@ ext4_trim_all_free(struct super_block *s
250 trace_ext4_trim_all_free(sb, group, start, max);
252 ret = ext4_mb_load_buddy(sb, group, &e4b);
254 - ext4_warning(sb, "Error %d loading buddy information for %u",
259 bitmap = e4b.bd_bitmap;
261 ext4_lock_group(sb, group);