Skip to content
  • Qu Wenruo's avatar
    btrfs-progs: free-space-cache: Enhance free space cache free space check · 4c7094e0
    Qu Wenruo authored
    
    
    When we found free space difference between free space cache and block
    group item, we just discard this free space cache.
    
    Normally such difference is caused by btrfs_reserve_extent() called by
    delalloc which is out of a transaction.
    And since all btrfs_release_extent() is called with a transaction, under
    heavy race free space cache can have less free space than block group
    item.
    
    Normally kernel will detect such difference and just discard that cache.
    
    However we must be more careful if free space cache has more free space
    cache, and if that happens, paried with above race one invalid free
    space cache can be loaded into kernel.
    
    So if we find any free space cache who has more free space then block
    group item, we report it as an error other than ignoring it.
    
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    4c7094e0