Whamcloud - gitweb
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)
commitc58a08e673a10d0e5fa4855ca58ab2cbf48fd029
tree84ca6dcf98d45dee1d2131d0caeaea57f1e42fc4
parent98446d738201df0dd24830eaf0781c7b4a26689a
resize2fs: Move all required blocks for ext4 filesystems

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