• Boris Burkov's avatar
    btrfs: retry block group reclaim without infinite loop · 4eb4e85c
    Boris Burkov authored
    If inc_block_group_ro systematically fails (e.g. due to ETXTBUSY from
    swap) or btrfs_relocate_chunk systematically fails (from lack of
    space), then this worker becomes an infinite loop.
    
    At the very least, this strands the cleaner thread, but can also result
    in hung tasks/RCU stalls on PREEMPT_NONE kernels and if the
    reclaim_bgs_lock mutex is not contended.
    
    I believe the best long term fix is to manage reclaim via work queue,
    where we queue up a relocation on the triggering condition and re-queue
    on failure. In the meantime, this is an easy fix to apply to avoid the
    immediate pain.
    
    Fixes: 7e271809 ("btrfs: reinsert BGs failed to reclaim")
    CC: stable@vger.kernel.org # 6.6+
    Signed-off-by: default avatarBoris Burkov <boris@bur.io>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    4eb4e85c
block-group.c 138 KB