btrfs: implement space clamping for preemptive flushing
authorJosef Bacik <josef@toxicpanda.com>
Fri, 9 Oct 2020 13:28:27 +0000 (09:28 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Feb 2021 21:58:59 +0000 (22:58 +0100)
commit88a777a6e5272106bdc96b1032d89b0ddc0e526f
tree717a835899027c6bf53cdf996adfa59244ca181a
parent2e294c60497f29ab8791f4b99f348b22d70dd3c3
btrfs: implement space clamping for preemptive flushing

Starting preemptive flushing at 50% of available free space is a good
start, but some workloads are particularly abusive and can quickly
overwhelm the preemptive flushing code and drive us into using tickets.

Handle this by clamping down on our threshold for starting and
continuing to run preemptive flushing.  This is particularly important
for our overcommit case, as we can really drive the file system into
overages and then it's more difficult to pull it back as we start to
actually fill up the file system.

The clamping is essentially 2^CLAMP, but we start at 1 so whatever we
calculate for overcommit is the baseline.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/space-info.c
fs/btrfs/space-info.h