• Filipe Manana's avatar
    btrfs: accurately calculate number of delayed refs when flushing · 007145ff
    Filipe Manana authored
    When flushing a limited number of delayed references (FLUSH_DELAYED_REFS_NR
    state), we are assuming each delayed reference is holding a number of bytes
    matching the needed space for inserting for a single metadata item (the
    result of btrfs_calc_insert_metadata_size()). That is not correct when
    using the free space tree, as in that case we have to multiply that value
    by 2 since we need to touch the free space tree as well. This is the same
    computation as we do at btrfs_update_delayed_refs_rsv() and at
    btrfs_delayed_refs_rsv_release().
    
    So correct the computation for the amount of delayed references we need to
    flush in case we have the free space tree. This does not fix a functional
    issue, instead it makes the flush code flush less delayed references, only
    the minimum necessary to satisfy a ticket.
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    007145ff
space-info.c 58.1 KB