Re: [PATCH 2/2] btrfs: do not do preemptive flushing if the majority is global rsv
From: Nikolay Borisov <hidden>
Date: 2021-08-17 08:39:16
On 11.08.21 г. 21:37, Josef Bacik wrote:
quoted hunk ↗ jump to hunk
A common characteristic of the bug report where preemptive flushing was going full tilt was the fact that the vast majority of the free metadata space was used up by the global reserve. The hard 90% threshold would cover the majority of these cases, but to be even smarter we should take into account how much of the outstanding reservations are covered by the global block reserve. If the global block reserve accounts for the vast majority of outstanding reservations, skip preemptive flushing, as it will likely just cause churn and pain. Link: https://bugzilla.kernel.org/show_bug.cgi?id=212185 Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/space-info.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index ddb4878e94df..2fce15d58b55 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c@@ -741,6 +741,20 @@ static bool need_preemptive_reclaim(struct btrfs_fs_info *fs_info, global_rsv_size) >= thresh) return false; + used = space_info->bytes_may_use + space_info->bytes_pinned;
But global_rsv_size is accounted entirely in bytes_may_use (per btrfs_update_global_block_rsv logic), so why add bytes_pinned?
+ + /* The total reservation belongs to the global rsv, don't flush. */ + if (global_rsv_size >= used) + return false; + + /* + * 128m is 1/4 of the maximum global rsv size. If we have less than + * that devoted to other reservations then there's no sense in flushing, + * we don't have a lot of things that need flushing. + */ + if ((used - global_rsv_size) <= SZ_128M) + return false; + /* * We have tickets queued, bail so we don't compete with the async * flushers.