On 2017年12月27日 09:11, Su Yue wrote: > > [snip] >>>> >>>> Manually allocation in advance has its advantage, like we can determine >>>> if there is enough space for new chunk instead of checking every return >>>> value with ENOSPC. >>>> >>>> >>>> However in current case, your metadata usage is limited to the new >>>> chunk >>>> only. >>>> If there extent tree has quite a lot of problem, and the chunk >>>> allocated >>>> is small (if using single profile and small fs), it can easily hit >>>> ENOSPC again, since btrfs doesn't allocate new chunk for later metadata >>>> write. >>>> >>> SAD. After I tried to implement above nice idea, infinite recursive >>> brings me back to the reality. >>> >>> Here is the reason why btrfs_reserve_extent can not allocate chunk >>> by itself if ENOSPC hints: >>> >>> btrfs_cow_block >>> ... >>> btrfs_reserve_extent >>> btrfs_alloc_chunk >>> btrfs_alloc_dev_extent >>> btrfs_insert_empty_item >>> ... >>> btrfs_cow_block >> >> The order is just wrong. >> >> We should first check for the new chunk space, not doing the insert >> right now. >> >> I'll take over the work if you're OK with it. >> > OK. Thanks a lot. > > Thanks, > Su
Well, even after my preparation patches, the situation is still much
complex than my expectation.
Yes, We could delay chunk/extent tree modification so newer chunk
allocation can be used for extent tree CoW.
But a lot of other infrastructure can't handle it well
The main problem is, we break a lot of ctree.c assumption.
For case like a normal tree CoW:
btrfs_search_slot(root=extent_root)
|- btrfs_cow_block()
|- btrfs_alloc_tree_block()
|- btrfs_reserve_extent()
|- btrfs_alloc_chunk()
|- insert block group item
*CoW* extent tree
In above case, extent_root changed even before we cow the extent root.
And will cause later (b == root->node) check fail and trigger a SEGV.
To really address it, we may need a large code rework with dynamic chunk
allocation in mind, which seems to expensive for a rarely used case.
So in short, I'm totally wrong and too optimistic about the feature.
Please use the original way, which is to alloc a new meta chunk manually.
Thanks,
Qu
signature.asc
Description: OpenPGP digital signature
