1 Since we could skip corrupt block groups, this patch
2 use ext4_warning() intead of ext4_error() to make FS not
6 fs/ext4/balloc.c | 10 ++++----
7 fs/ext4/ialloc.c | 6 ++--
8 fs/ext4/mballoc.c | 66 +++++++++++++++++++++---------------------------------
9 3 files changed, 34 insertions(+), 48 deletions(-)
11 --- a/fs/ext4/balloc.c
12 +++ b/fs/ext4/balloc.c
13 @@ -382,7 +382,7 @@ static int ext4_validate_block_bitmap(st
15 ext4_simulate_fail(sb, EXT4_SIM_BBITMAP_CRC))) {
16 ext4_unlock_group(sb, block_group);
17 - ext4_error(sb, "bg %u: bad block bitmap checksum", block_group);
18 + ext4_warning(sb, "bg %u: bad block bitmap checksum", block_group);
19 ext4_mark_group_bitmap_corrupted(sb, block_group,
20 EXT4_GROUP_INFO_BBITMAP_CORRUPT);
22 @@ -390,8 +390,8 @@ static int ext4_validate_block_bitmap(st
23 blk = ext4_valid_block_bitmap(sb, desc, block_group, bh);
24 if (unlikely(blk != 0)) {
25 ext4_unlock_group(sb, block_group);
26 - ext4_error(sb, "bg %u: block %llu: invalid block bitmap",
28 + ext4_warning(sb, "bg %u: block %llu: invalid block bitmap",
30 ext4_mark_group_bitmap_corrupted(sb, block_group,
31 EXT4_GROUP_INFO_BBITMAP_CORRUPT);
33 @@ -467,8 +467,8 @@ ext4_read_block_bitmap_nowait(struct sup
34 ext4_unlock_group(sb, block_group);
37 - ext4_error(sb, "Failed to init block bitmap for group "
38 - "%u: %d", block_group, err);
39 + ext4_warning(sb, "Failed to init block bitmap for group "
40 + "%u: %d", block_group, err);
44 --- a/fs/ext4/ialloc.c
45 +++ b/fs/ext4/ialloc.c
46 @@ -97,8 +97,8 @@ static int ext4_validate_inode_bitmap(st
47 EXT4_INODES_PER_GROUP(sb) / 8) ||
48 ext4_simulate_fail(sb, EXT4_SIM_IBITMAP_CRC)) {
49 ext4_unlock_group(sb, block_group);
50 - ext4_error(sb, "Corrupt inode bitmap - block_group = %u, "
51 - "inode_bitmap = %llu", block_group, blk);
52 + ext4_warning(sb, "Corrupt inode bitmap - block_group = %u, "
53 + "inode_bitmap = %llu", block_group, blk);
54 ext4_mark_group_bitmap_corrupted(sb, block_group,
55 EXT4_GROUP_INFO_IBITMAP_CORRUPT);
57 @@ -345,7 +345,7 @@ out:
61 - ext4_error(sb, "bit already cleared for inode %lu", ino);
62 + ext4_warning(sb, "bit already cleared for inode %lu", ino);
63 ext4_mark_group_bitmap_corrupted(sb, block_group,
64 EXT4_GROUP_INFO_IBITMAP_CORRUPT);
66 --- a/fs/ext4/mballoc.c
67 +++ b/fs/ext4/mballoc.c
68 @@ -802,10 +802,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 @@ -1168,7 +1172,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 @@ -1194,7 +1198,7 @@ ext4_mb_load_buddy_gfp(struct super_bloc
98 ret = ext4_mb_init_group(sb, group, gfp);
105 @@ -1297,6 +1301,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 @@ -3782,9 +3787,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 @@ -4129,16 +4136,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 %d] [freed %u]", pa,
133 - (unsigned long)pa->pa_pstart,
134 - (unsigned long)pa->pa_lstart,
135 - 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 @@ -4199,16 +4198,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_err(sb, -err,
149 - "Error %d reading block bitmap for %u",
154 err = ext4_mb_load_buddy(sb, group, &e4b);
156 - ext4_warning(sb, "Error %d loading buddy information for %u",
161 @@ -4376,17 +4370,12 @@ repeat:
163 err = ext4_mb_load_buddy_gfp(sb, group, &e4b,
164 GFP_NOFS|__GFP_NOFAIL);
166 - ext4_error_err(sb, -err, "Error %d loading buddy information for %u",
172 bitmap_bh = ext4_read_block_bitmap(sb, group);
173 if (IS_ERR(bitmap_bh)) {
174 err = PTR_ERR(bitmap_bh);
175 - ext4_error_err(sb, -err, "Error %d reading block bitmap for %u",
177 ext4_mb_unload_buddy(&e4b);
180 @@ -4681,11 +4670,8 @@ ext4_mb_discard_lg_preallocations(struct
181 group = ext4_get_group_number(sb, pa->pa_pstart);
182 err = ext4_mb_load_buddy_gfp(sb, group, &e4b,
183 GFP_NOFS|__GFP_NOFAIL);
185 - ext4_error_err(sb, -err, "Error %d loading buddy information for %u",
190 ext4_lock_group(sb, group);
191 list_del(&pa->pa_group_list);
192 ext4_get_group_info(sb, group)->bb_prealloc_nr--;
193 @@ -4974,7 +4960,7 @@ errout:
194 * been updated or not when fail case. So can
195 * not revert pa_free back, just mark pa_error*/
199 "Updating bitmap error: [err %d] "
200 "[pa %p] [phy %lu] [logic %lu] "
201 "[len %u] [free %u] [error %u] "
202 @@ -4985,6 +4971,7 @@ errout:
203 (unsigned)pa->pa_free,
204 (unsigned)pa->pa_error,
205 pa->pa_inode ? pa->pa_inode->i_ino : 0);
206 + ext4_mark_group_bitmap_corrupted(sb, 0, 0);
209 ext4_mb_release_context(ac);
210 @@ -5271,7 +5258,7 @@ do_more:
211 err = ext4_mb_load_buddy_gfp(sb, block_group, &e4b,
212 GFP_NOFS|__GFP_NOFAIL);
218 * We need to make sure we don't reuse the freed block until after the
219 @@ -5362,8 +5349,9 @@ do_more:
224 ext4_std_error(sb, err);
230 @@ -5463,7 +5451,7 @@ int ext4_group_add_blocks(handle_t *hand
232 err = ext4_mb_load_buddy(sb, block_group, &e4b);
238 * need to update group_info->bb_free and bitmap
239 @@ -5502,8 +5490,9 @@ int ext4_group_add_blocks(handle_t *hand
244 ext4_std_error(sb, err);
250 @@ -5578,11 +5567,8 @@ ext4_trim_all_free(struct super_block *s
251 trace_ext4_trim_all_free(sb, group, start, max);
253 ret = ext4_mb_load_buddy(sb, group, &e4b);
255 - ext4_warning(sb, "Error %d loading buddy information for %u",
260 bitmap = e4b.bd_bitmap;
262 ext4_lock_group(sb, group);