/*
* Mark the blocks used for the inode table
*/
- if (ext2fs_inode_table_loc(fs, i)) {
+ if (!ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) &&
+ ext2fs_inode_table_loc(fs, i)) {
+ unsigned int end = (unsigned) fs->inode_blocks_per_group;
+ /* skip unused blocks */
+ if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+ EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
+ end -= (ext2fs_bg_itable_unused(fs, i) /
+ EXT2_INODES_PER_BLOCK(fs->super));
for (j = 0, b = ext2fs_inode_table_loc(fs, i);
- j < (unsigned) fs->inode_blocks_per_group;
- j++, b++)
+ j < end;
+ j++, b++) {
ext2fs_mark_block_bitmap2(meta_block_map, b);
- meta_blocks_count += fs->inode_blocks_per_group;
+ meta_blocks_count++;
+ }
}
/*
* Mark block used for the block bitmap
*/
- if (ext2fs_block_bitmap_loc(fs, i)) {
+ if (!ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) &&
+ ext2fs_block_bitmap_loc(fs, i)) {
ext2fs_mark_block_bitmap2(meta_block_map,
ext2fs_block_bitmap_loc(fs, i));
meta_blocks_count++;
/*
* Mark block used for the inode bitmap
*/
- if (ext2fs_inode_bitmap_loc(fs, i)) {
+ if (!ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) &&
+ ext2fs_inode_bitmap_loc(fs, i)) {
ext2fs_mark_block_bitmap2(meta_block_map,
ext2fs_inode_bitmap_loc(fs, i));
meta_blocks_count++;