fix bug in add-support-collapse-range
[ext4-patch-queue.git] / fix-resize-nonstd-blocks-per-group
blob4cf862f938f8ea7da388f1d6c5b1e14b2d8bb9f8
1 ext4: fix online resize with a non-standard blocks per group setting
3 The set_flexbg_block_bitmap() function assumed that the number of
4 blocks in a blockgroup was sb->blocksize * 8, which is normally true,
5 but not always!  Use EXT4_BLOCKS_PER_GROUP(sb) instead, to fix block
6 bitmap corruption after:
8 mke2fs -t ext4 -g 3072 -i 4096 /dev/vdd 1G
9 mount -t ext4 /dev/vdd /vdd
10 resize2fs /dev/vdd 8G
12 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 Reported-by: Jon Bernard <jbernard@tuxion.com>
14 Cc: stable@vger.kernel.org
15 ---
16  fs/ext4/resize.c | 2 +-
17  1 file changed, 1 insertion(+), 1 deletion(-)
19 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
20 index 69a6261..f3b84cd 100644
21 --- a/fs/ext4/resize.c
22 +++ b/fs/ext4/resize.c
23 @@ -409,7 +409,7 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
24                 start = ext4_group_first_block_no(sb, group);
25                 group -= flex_gd->groups[0].group;
27 -               count2 = sb->s_blocksize * 8 - (block - start);
28 +               count2 = EXT4_BLOCKS_PER_GROUP(sb) - (block - start);
29                 if (count2 > count)
30                         count2 = count;