Whamcloud - gitweb
libext2fs: set BLOCK_UNINIT for non-last blockgroups if all blocks are free
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 17 Nov 2014 22:41:07 +0000 (17:41 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 17 Nov 2014 22:46:13 +0000 (17:46 -0500)
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 <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/csum.c

index 12f6fe9..6dcefb9 100644 (file)
@@ -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);