On 02/21/2018 11:56 PM, Qu Wenruo wrote:
On 2018年02月22日 12:52, Qu Wenruo wrote:
btrfs_read_block_groups() is used to build up the block group cache for
all block groups, so it will iterate all block group items in extent
For large filesystem (TB level), it will search for BLOCK_GROUP_ITEM
thousands times, which is the most time consuming part of mounting
So this patch will try to speed it up by:
1) Avoid unnecessary readahead
We were using READA_FORWARD to search for block group item.
However block group items are in fact scattered across quite a lot of
leaves. Doing readahead will just waste our IO (especially important
In real world case, for a filesystem with 3T used space, it would
have about 50K extent tree leaves, but only have 3K block group
items. Meaning we need to iterate 16 leaves to meet one block group
So readahead won't help but waste slow HDD seeks.
2) Use chunk mapping to locate block group items
Since one block group item always has one corresponding chunk item,
we could use chunk mapping to get the block group item size.
With block group item size, we can do a pinpoint tree search, instead
of searching with some uncertain value and do forward search.
In some case, like next BLOCK_GROUP_ITEM is in the next leaf of
current path, we could save such unnecessary tree block read.
Cc: Ellis H. Wilson III <ell...@panasas.com>
Would you please try this patch to see if it helps to speedup the mount
of your large filesystem?
I will try either tomorrow or over the weekend. I'm waiting on hardware
to be able to build and load a custom kernel on.
Thanks so much for taking a stab at this!
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html