Skip to content

Commit 1146239

Browse files
josefbacikkdave
authored andcommitted
btrfs: do not do preemptive flushing if the majority is global rsv
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. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212185 Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 93c60b1 commit 1146239

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fs/btrfs/space-info.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,20 @@ static bool need_preemptive_reclaim(struct btrfs_fs_info *fs_info,
741741
global_rsv_size) >= thresh)
742742
return false;
743743

744+
used = space_info->bytes_may_use + space_info->bytes_pinned;
745+
746+
/* The total flushable belongs to the global rsv, don't flush. */
747+
if (global_rsv_size >= used)
748+
return false;
749+
750+
/*
751+
* 128MiB is 1/4 of the maximum global rsv size. If we have less than
752+
* that devoted to other reservations then there's no sense in flushing,
753+
* we don't have a lot of things that need flushing.
754+
*/
755+
if (used - global_rsv_size <= SZ_128M)
756+
return false;
757+
744758
/*
745759
* We have tickets queued, bail so we don't compete with the async
746760
* flushers.

0 commit comments

Comments
 (0)