On Wed, Dec 09, 2020 at 07:48:09PM +0800, brookxu wrote: > > Maybe I missed something. If i% meta_bg_size is used instead, if > flex_size <64, then we will miss some flex_bg. There seems to be > a contradiction here. In the scenario where only flex_bg is > enabled, it may not be appropriate to use meta_bg_size. In the > scenario where only meta_bg is enabled, it may not be appropriate > to use flex_size. > > As you said before, it maybe better to remove > > if ((i <5) || ((i% flex_size) == 0)) > > and do it for all groups. I don't think the original (i % flex_size) made any sense in the first place. What flex_bg does is that it collects the allocation bitmaps and inode tables for each block group and locates them within the first block group in a flex_bg. It doesn't have anything to do with whether or not a particular block group has a backup copy of the superblock and block group descriptor table --- in non-meta_bg file systems and the meta_bg file systems where the block group is less than s_first_meta_bg * EXT4_DESC_PER_BLOCK(sb). And the condition in question is only about whether or not to add the backup superblock and backup block group descriptors. So checking for i % flex_size made no sense, and I'm not sure that check was there in the first place. > In this way weh won't miss some flex_bg, meta_bg, and sparse_bg. > I tested it on an 80T disk and found that the performance loss > was small: > > unpatched kernel: > ext4_setup_system_zone() takes 524ms, > > patched kernel: > ext4_setup_system_zone() takes 552ms, I don't really care that much about the time it takes to execute ext4_setup_system_zone(). The really interesting question is how large is the rb_tree constructed by that function, and what is the percentage increase of time that the ext4_inode_block_valid() function takes. (e.g., how much additional memory is the system_blks tree taking, and how deep is that tree, since ext4_inode_block_valid() gets called every time we allocate or free a block, and every time we need to validate an extent tree node. Cheers, - Ted