• Josef Bacik's avatar
    btrfs: take overcommit into account in inc_block_group_ro · a30a3d20
    Josef Bacik authored
    inc_block_group_ro does a calculation to see if we have enough room left
    over if we mark this block group as read only in order to see if it's ok
    to mark the block group as read only.
    
    The problem is this calculation _only_ works for data, where our used is
    always less than our total.  For metadata we will overcommit, so this
    will almost always fail for metadata.
    
    Fix this by exporting btrfs_can_overcommit, and then see if we have
    enough space to remove the remaining free space in the block group we
    are trying to mark read only.  If we do then we can mark this block
    group as read only.
    Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    a30a3d20
space-info.c 31.4 KB