]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
resize2fs: Move all required blocks for ext4 filesystems
authorTheodore Ts'o <tytso@mit.edu>
Mon, 19 Jan 2009 13:43:36 +0000 (08:43 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 19 Jan 2009 13:43:36 +0000 (08:43 -0500)
In the function blocks_to_move(), when checking to see if a block
group's block bitmap is initialized, we need to check the old_fs's
block group descriptors, not the new file system's (already truncated)
group descriptor data structures.  Otherwise we will end up
derferencing past the end of the array boundary, and the resulting
garbage value may indicate that the bitmap is uninitialized, and so
all of the blocks in that block group will be skipped, resulting in
some blocks not getting marked as needing relocation.

This showed up in the following test case:

     mke2fs -t ext4 -b 1024 test.img 1048576
     resize2fs test.img 80000

The journal inode after the resize operation looked like this:

debugfs:  stat <8>
Inode: 8   Type: regular    Mode:  0600   Flags: 0x80000
...
BLOCKS:
(IND):35385, (0-5836):2356-8192, (5837-21959):8454-24576, (21960-32506):24838-35
384, (32507-32767):434177-434437
TOTAL: 32769

The blocks 434177-434437 were not moved because block group 53 was
wrongly thought to have an unitialized block group.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
resize/resize2fs.c

index abe05f57e08b4a9d94718e23a6d132b0faf59da2..e7a08daa84e3639fc843b8a7b351a302b3ad0bbf 100644 (file)
@@ -745,7 +745,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs)
                g = ext2fs_group_of_blk(fs, blk);
                if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
                                               EXT4_FEATURE_RO_COMPAT_GDT_CSUM) &&
-                   (fs->group_desc[g].bg_flags & EXT2_BG_BLOCK_UNINIT)) {
+                   (old_fs->group_desc[g].bg_flags & EXT2_BG_BLOCK_UNINIT)) {
                        /*
                         * The block bitmap is uninitialized, so skip
                         * to the next block group.