On 2018年02月23日 00:31, Ellis H. Wilson III wrote:
> 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
>>> tree.
>>> For large filesystem (TB level), it will search for BLOCK_GROUP_ITEM
>>> thousands times, which is the most time consuming part of mounting
>>> btrfs.
>>> 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
>>>     for HDD).
>>>     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
>>>     on average.
>>>     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>
>> Hi Ellis,
>> 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.

If you're using Archlinux, I could build the package for you.

(For other distributions, unfortunately I'm not that familiar with)

> Thanks so much for taking a stab at this!
> ellis

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to