]> Pileus Git - ~andy/linux/commitdiff
ext4: fix online resize with a non-standard blocks per group setting
authorTheodore Ts'o <tytso@mit.edu>
Sun, 16 Feb 2014 03:42:25 +0000 (22:42 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 16 Feb 2014 03:42:25 +0000 (22:42 -0500)
The set_flexbg_block_bitmap() function assumed that the number of
blocks in a blockgroup was sb->blocksize * 8, which is normally true,
but not always!  Use EXT4_BLOCKS_PER_GROUP(sb) instead, to fix block
bitmap corruption after:

mke2fs -t ext4 -g 3072 -i 4096 /dev/vdd 1G
mount -t ext4 /dev/vdd /vdd
resize2fs /dev/vdd 8G

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: Jon Bernard <jbernard@tuxion.com>
Cc: stable@vger.kernel.org
fs/ext4/resize.c

index 69a62610a6ca56835cd401d424a57d34b428bb77..f3b84cd9de566ff7b1ffb5d16e75483e9b9d06f2 100644 (file)
@@ -409,7 +409,7 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
                start = ext4_group_first_block_no(sb, group);
                group -= flex_gd->groups[0].group;
 
-               count2 = sb->s_blocksize * 8 - (block - start);
+               count2 = EXT4_BLOCKS_PER_GROUP(sb) - (block - start);
                if (count2 > count)
                        count2 = count;