From: Darrick J. Wong Date: Mon, 17 Nov 2014 22:41:07 +0000 (-0500) Subject: libext2fs: set BLOCK_UNINIT for non-last blockgroups if all blocks are free X-Git-Tag: v1.43-WIP-2015-05-18~135 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=c0ff3a21b6c3b30fbbe16280cf1808864f5803b7;p=tools%2Fe2fsprogs.git libext2fs: set BLOCK_UNINIT for non-last blockgroups if all blocks are free Set BLOCK_UNINIT in any group whose blocks are all unused, so long as it isn't the last group. This helps us speed up future e2fsck runs and mounts because we don't need to read or checksum block bitmaps for these groups. Signed-off-by: Darrick J. Wong Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/csum.c b/lib/ext2fs/csum.c index 12f6fe9..6dcefb9 100644 --- a/lib/ext2fs/csum.c +++ b/lib/ext2fs/csum.c @@ -854,6 +854,11 @@ errcode_t ext2fs_set_gdt_csum(ext2_filsys fs) __u32 old_unused = ext2fs_bg_itable_unused(fs, i); __u32 old_flags = ext2fs_bg_flags(fs, i); __u32 old_free_inodes_count = ext2fs_bg_free_inodes_count(fs, i); + __u32 old_free_blocks_count = ext2fs_bg_free_blocks_count(fs, i); + + if (old_free_blocks_count == sb->s_blocks_per_group && + i != fs->group_desc_count - 1) + ext2fs_bg_flags_set(fs, i, EXT2_BG_BLOCK_UNINIT); if (old_free_inodes_count == sb->s_inodes_per_group) { ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT);