]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: skip start_blk adjustment when stride and flex_bg is set
authorLukas Czerner <lczerner@redhat.com>
Sat, 14 Oct 2017 14:42:30 +0000 (10:42 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 14 Oct 2017 14:42:35 +0000 (10:42 -0400)
Currently some stride optimization is done in
ext2fs_allocate_group_table() by adjusting start_blk block where we
start allocating block, or inode bitmaps.

However in flex_bg case this is currently useless since the values are
going to be overridden anyway. Moreover in flex_bg case the group might
already be full and the stride optimization will fail. As a result file
system resize might fail needlessly in some situations.

It can be shown by this example:

mke2fs -b 1024 -i 1024 -E stride=8192 -t ext4 /dev/loop0 1024000
resize2fs /dev/loop0 102400000
resize2fs 1.43.5 (04-Aug-2017)
Resizing the filesystem on /dev/loop0 to 102400000 (1k) blocks.
./resize/resize2fs: Could not allocate block in ext2 filesystem while trying to resize /dev/loop0
Please run 'e2fsck -fy /dev/loop0' to fix the filesystem
after the aborted resize operation.

Fix this by not doing the stride adjustment in case of flex_bg.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/alloc_tables.c

index 407283f4e3fe53b7e1f9ebfcfbf7280fbffe75f8..0a3663040319129e7bc02c6fa81d8191c844dc59 100644 (file)
@@ -107,7 +107,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
        /*
         * Allocate the block and inode bitmaps, if necessary
         */
-       if (fs->stride) {
+       if (fs->stride && !flexbg_size) {
                retval = ext2fs_get_free_blocks2(fs, group_blk, last_blk,
                                                 1, bmap, &start_blk);
                if (retval)