• Qu Wenruo's avatar
    btrfs: Refactor find_free_extent loops update into find_free_extent_update_loop · e72d79d6
    Qu Wenruo authored
    We have a complex loop design for find_free_extent(), that has different
    behavior for each loop, some even includes new chunk allocation.
    
    Instead of putting such a long code into find_free_extent() and makes it
    harder to read, just extract them into find_free_extent_update_loop().
    
    With all the cleanups, the main find_free_extent() should be pretty
    barebone:
    
    find_free_extent()
    |- Iterate through all block groups
    |  |- Get a valid block group
    |  |- Try to do clustered allocation in that block group
    |  |- Try to do unclustered allocation in that block group
    |  |- Check if the result is valid
    |  |  |- If valid, then exit
    |  |- Jump to next block group
    |
    |- Push harder to find free extents
       |- If not found, re-iterate all block groups
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Reviewed-by: default avatarSu Yue <suy.fnst@cn.fujitsu.com>
    [ copy callchain from changelog to function comment ]
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    e72d79d6
extent-tree.c 306 KB