07 Oct, 2020

1 commit

  • Create a new function btrfs_reserve_data_bytes() in order to handle data
    reservations. This uses the new flush types and flush states to handle
    making data reservations.

    This patch specifically does not change any functionality, and is
    purposefully not cleaned up in order to make bisection easier for the
    future patches. The new helper is identical to the old helper in how it
    handles data reservations. We first try to force a chunk allocation,
    and then we run through the flush states all at once and in the same
    order that they were done with the old helper.

    Subsequent patches will clean this up and change the behavior of the
    flushing, and it is important to keep those changes separate so we can
    easily bisect down to the patch that caused the regression, rather than
    the patch that made us start using the new infrastructure.

    Reviewed-by: Nikolay Borisov
    Tested-by: Nikolay Borisov
    Reviewed-by: Johannes Thumshirn
    Signed-off-by: Josef Bacik
    Signed-off-by: David Sterba

    Josef Bacik
     

25 May, 2020

1 commit

  • For unlink transactions and block group removal
    btrfs_start_transaction_fallback_global_rsv will first try to start an
    ordinary transaction and if it fails it will fall back to reserving the
    required amount by stealing from the global reserve. This is problematic
    because of all the same reasons we had with previous iterations of the
    ENOSPC handling, thundering herd. We get a bunch of failures all at
    once, everybody tries to allocate from the global reserve, some win and
    some lose, we get an ENSOPC.

    Fix this behavior by introducing BTRFS_RESERVE_FLUSH_ALL_STEAL. It's
    used to mark unlink reservation. To fix this we need to integrate this
    logic into the normal ENOSPC infrastructure. We still go through all of
    the normal flushing work, and at the moment we begin to fail all the
    tickets we try to satisfy any tickets that are allowed to steal by
    stealing from the global reserve. If this works we start the flushing
    system over again just like we would with a normal ticket satisfaction.
    This serializes our global reserve stealing, so we don't have the
    thundering herd problem.

    Reviewed-by: Nikolay Borisov
    Tested-by: Nikolay Borisov
    Signed-off-by: Josef Bacik
    Signed-off-by: David Sterba

    Josef Bacik
     

24 Mar, 2020

1 commit

  • Instead of iterating all pending tickets on the normal/priority list to
    sum their total size the cost can be amortized across ticket addition/
    removal. This turns O(n) + O(m) (where n is the size of the normal list
    and m of the priority list) into O(1). This will mostly have effect in
    workloads that experience heavy flushing.

    Signed-off-by: Nikolay Borisov
    Reviewed-by: David Sterba
    Signed-off-by: David Sterba

    Nikolay Borisov
     

31 Jan, 2020

1 commit

  • 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: Qu Wenruo
    Signed-off-by: Josef Bacik
    Reviewed-by: David Sterba
    Signed-off-by: David Sterba

    Josef Bacik
     

19 Nov, 2019

1 commit


18 Nov, 2019

1 commit

  • The attribute is more relaxed than const and the functions could
    dereference pointers, as long as the observable state is not changed. We
    do have such functions, based on -Wsuggest-attribute=pure .

    The visible effects of this patch are negligible, there are differences
    in the assembly but hard to summarize.

    Reviewed-by: Nikolay Borisov
    Signed-off-by: David Sterba

    David Sterba
     

09 Sep, 2019

4 commits

  • This name doesn't really fit with how the space reservation stuff works
    now, rename it to btrfs_space_info_free_bytes_may_use so it's clear what
    the function is doing.

    Reviewed-by: Nikolay Borisov
    Signed-off-by: Josef Bacik
    Reviewed-by: David Sterba
    Signed-off-by: David Sterba

    Josef Bacik
     
  • Now that we do not do partial filling of tickets simply remove
    orig_bytes, it is no longer needed.

    Reviewed-by: Nikolay Borisov
    Signed-off-by: Josef Bacik
    Signed-off-by: David Sterba

    Josef Bacik
     
  • Now that btrfs_space_info_add_old_bytes simply checks if we can make the
    reservation and updates bytes_may_use, there's no reason to have both
    helpers in place.

    Factor out the ticket wakeup logic into it's own helper, make
    btrfs_space_info_add_old_bytes() update bytes_may_use and then call the
    wakeup helper, and replace all calls to btrfs_space_info_add_new_bytes()
    with the wakeup helper.

    Reviewed-by: Nikolay Borisov
    Signed-off-by: Josef Bacik
    Signed-off-by: David Sterba

    Josef Bacik
     
  • We duplicate this tracepoint everywhere we call these helpers, so update
    the helper to have the tracepoint as well.

    Signed-off-by: Josef Bacik
    Reviewed-by: David Sterba
    Signed-off-by: David Sterba

    Josef Bacik
     

02 Jul, 2019

9 commits