On Wed, Nov 20, 2019 at 04:35:27AM +0000, Li Dongyang wrote: > If overhead is not recorded in the super block, it is caculated > during mount in kernel, for bigalloc file systems the it takes > O(groups**2) in time. > For a 1PB deivce with 32K cluste 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 simplly 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@xxxxxxx> Applied, but I had to fix up a number of spelling errors in the commit description, and fix up a large number of test failures caused by this change. - Ted