• Boris Burkov's avatar
    btrfs: prevent pathological periodic reclaim loops · 813d4c64
    Boris Burkov authored
    Periodic reclaim runs the risk of getting stuck in a state where it
    keeps reclaiming the same block group over and over. This can happen if
    
    1. reclaiming that block_group fails
    2. reclaiming that block_group fails to move any extents into existing
       block_groups and just allocates a fresh chunk and moves everything.
    
    Currently, 1. is a very tight loop inside the reclaim worker. That is
    critical for edge triggered reclaim or else we risk forgetting about a
    reclaimable group. On the other hand, with level triggered reclaim we
    can break out of that loop and get it later.
    
    With that fixed, 2. applies to both failures and "successes" with no
    progress. If we have done a periodic reclaim on a space_info and nothing
    has changed in that space_info, there is not much point to trying again,
    so don't, until enough space gets free, which we capture with a
    heuristic of needing to net free 1 chunk.
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarBoris Burkov <boris@bur.io>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    813d4c64
space-info.c 65 KB