Whamcloud - gitweb
mke2fs: set overhead in super block
authorLi Dongyang <dongyangli@ddn.com>
Mon, 27 Jan 2020 03:06:36 +0000 (22:06 -0500)
committerLi Dongyang <dongyangli@ddn.com>
Wed, 27 May 2020 01:20:37 +0000 (11:20 +1000)
commit9046b4dfd0ce4ad589f5dce1135b91c342022de1
treed5a88fe670b8bb24a4d20ca89d2f1a2645f29560
parent742aa217a0461635e140cbed58cbd79d07298302
mke2fs: set overhead in super block

If overhead is not recorded in the super block, it is calculated
during mount in kernel, for bigalloc file systems it takes
O(groups**2) in time.  For a 1PB device with 32K cluster size it takes
~12 mins to mount, with most of the time spent on figuring out
overhead.

While we can not improve the overhead algorithm in kernel due to the
nature of bigalloc, we can work out the overhead during mke2fs and set
it in the super block, avoiding calculating it every time when it
mounts.

Overhead is s_first_data_block plus internal journal blocks plus the
block and inode bitmaps, inode table, super block backups and group
descriptor blocks for every group.  This patch introduces
ext2fs_count_used_clusters(), which calculates the clusters used in
the block bitmap for the given range.

When bad blocks are involved, it gets tricky because the blocks
counted as overhead and the bad blocks can end up in the same
allocation cluster.  In this case we will unmark the bad blocks from
the block bitmap, convert to cluster bitmap and get the overhead, then
mark the bad blocks back in the cluster bitmap.

Reset the overhead to zero when resizing, we can not simply count the
used blocks as overhead like we do when mke2fs.  The overhead can be
calculated by kernel side during mount.

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
35 files changed:
lib/ext2fs/ext2fs.h
lib/ext2fs/gen_bitmap64.c
misc/mke2fs.c
resize/resize2fs.c
tests/f_opt_extent/expect
tests/m_64bit_flexbg/expect.1
tests/m_bigjournal/expect.1
tests/m_dasd_bs/expect.1
tests/m_desc_size_128/expect.1
tests/m_extent_journal/expect.1
tests/m_large_file/expect.1
tests/m_meta_bg/expect.1
tests/m_minrootdir/expect
tests/m_mmp/expect.1
tests/m_no_opt/expect.1
tests/m_quota/expect.1
tests/m_raid_opt/expect.1
tests/m_resize_inode_meta_bg/expect.1
tests/m_root_owner/expect.1
tests/m_rootdir/expect
tests/m_std/expect.1
tests/m_uninit/expect.1
tests/r_32to64bit/expect
tests/r_32to64bit_meta/expect
tests/r_32to64bit_move_itable/expect
tests/r_64to32bit/expect
tests/r_64to32bit_meta/expect
tests/t_disable_mcsum/expect
tests/t_disable_mcsum_noinitbg/expect
tests/t_disable_mcsum_yesinitbg/expect
tests/t_enable_mcsum/expect
tests/t_enable_mcsum_ext3/expect
tests/t_enable_mcsum_initbg/expect
tests/t_iexpand_full/expect
tests/t_iexpand_mcsum/expect