• Josef Bacik's avatar
    btrfs: don't use global reserve for chunk allocation · 450114fc
    Josef Bacik authored
    We've done this forever because of the voodoo around knowing how much
    space we have.  However, we have better ways of doing this now, and on
    normal file systems we'll easily have a global reserve of 512MiB, and
    since metadata chunks are usually 1GiB that means we'll allocate
    metadata chunks more readily.  Instead use the actual used amount when
    determining if we need to allocate a chunk or not.
    
    This has a side effect for mixed block group fs'es where we are no
    longer allocating enough chunks for the data/metadata requirements.  To
    deal with this add a ALLOC_CHUNK_FORCE step to the flushing state
    machine.  This will only get used if we've already made a full loop
    through the flushing machinery and tried committing the transaction.
    
    If we have then we can try and force a chunk allocation since we likely
    need it to make progress.  This resolves issues I was seeing with
    the mixed bg tests in xfstests without the new flushing state.
    Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
    Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
    [ merged with patch "add ALLOC_CHUNK_FORCE to the flushing code" ]
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    450114fc
ctree.h 130 KB