1 ext4: fix block bitmap validation when bigalloc, ^flex_bg
3 From: "Darrick J. Wong" <darrick.wong@oracle.com>
5 On a bigalloc,^flex_bg filesystem, the ext4_valid_block_bitmap
6 function fails to convert from blocks to clusters when spot-checking
7 the validity of the bitmap block that we've just read from disk. This
8 causes ext4 to think that the bitmap is garbage, which results in the
9 block group being taken offline when it's not necessary. Add in the
10 necessary EXT4_B2C() calls to perform the conversions.
12 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
13 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
15 fs/ext4/balloc.c | 12 +++++++-----
16 1 file changed, 7 insertions(+), 5 deletions(-)
19 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
20 index a4950e9..59c3ba8 100644
21 --- a/fs/ext4/balloc.c
22 +++ b/fs/ext4/balloc.c
23 @@ -307,6 +307,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
24 ext4_group_t block_group,
25 struct buffer_head *bh)
27 + struct ext4_sb_info *sbi = EXT4_SB(sb);
29 ext4_grpblk_t next_zero_bit;
31 @@ -326,14 +327,14 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
32 /* check whether block bitmap block number is set */
33 blk = ext4_block_bitmap(sb, desc);
34 offset = blk - group_first_block;
35 - if (!ext4_test_bit(offset, bh->b_data))
36 + if (!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
37 /* bad block bitmap */
40 /* check whether the inode bitmap block number is set */
41 blk = ext4_inode_bitmap(sb, desc);
42 offset = blk - group_first_block;
43 - if (!ext4_test_bit(offset, bh->b_data))
44 + if (!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
45 /* bad block bitmap */
48 @@ -341,9 +342,10 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
49 blk = ext4_inode_table(sb, desc);
50 offset = blk - group_first_block;
51 next_zero_bit = ext4_find_next_zero_bit(bh->b_data,
52 - offset + EXT4_SB(sb)->s_itb_per_group,
54 - if (next_zero_bit < offset + EXT4_SB(sb)->s_itb_per_group)
55 + EXT4_B2C(sbi, offset + EXT4_SB(sb)->s_itb_per_group),
56 + EXT4_B2C(sbi, offset));
58 + EXT4_B2C(sbi, offset + EXT4_SB(sb)->s_itb_per_group))
59 /* bad bitmap for inode tables */
64 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
65 the body of a message to majordomo@vger.kernel.org
66 More majordomo info at http://vger.kernel.org/majordomo-info.html