btrfs_reserve_extent() will try to allocate new chunk if there is not
enough space (mostly meta space).
However when it tries to allocate new meta chunk, it will always try to
allocate SINGLE meta chunk, and if the fs is using other profile, it
will cause dead allocation which can't be really used.
And when trying to allocate new meta chunk for fs trees, it uses the
@num_bytes which is normally times larger than metadata space.
Fix it by using proper meta profile and calculate based on file extent
other than @num_bytes if we are allocating meta space for file extents.
And all such chunk allocation condition is not explained at all.
Add needed (although maybe a little overkilled) comment for it.
Signed-off-by: Qu Wenruo <wqu@suse.com>
3b731f0