summaryrefslogtreecommitdiff
path: root/fs/bcachefs/movinggc.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-04-27 14:03:13 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:02 -0400
commitd4b4422345fcb4e284260bd52166e189c137e846 (patch)
treed21236145694b6485a0aa3610cc3ea6758a8057e /fs/bcachefs/movinggc.c
parentbaa6502905df0acb94afbf6c93f51a1f2aa4c7ca (diff)
downloadlwn-d4b4422345fcb4e284260bd52166e189c137e846.tar.gz
lwn-d4b4422345fcb4e284260bd52166e189c137e846.zip
bcachefs: Change copygc wait amount to be min of per device waits
We're seeing a filesystem get stuck when all devices but one have no more reclaimable buckets - because the copygc wait amount is curretly filesystem wide. This patch should fix that, possibly at the expensive of running too much when only one or a few devices is full and the rebalance thread needs to move data around. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/movinggc.c')
-rw-r--r--fs/bcachefs/movinggc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c
index f9146ccd70ef..acb4d943db79 100644
--- a/fs/bcachefs/movinggc.c
+++ b/fs/bcachefs/movinggc.c
@@ -293,17 +293,19 @@ unsigned long bch2_copygc_wait_amount(struct bch_fs *c)
{
struct bch_dev *ca;
unsigned dev_idx;
- u64 fragmented_allowed = 0, fragmented = 0;
+ s64 wait = S64_MAX, fragmented_allowed, fragmented;
for_each_rw_member(ca, c, dev_idx) {
struct bch_dev_usage usage = bch2_dev_usage_read(ca);
- fragmented_allowed += ((__dev_buckets_reclaimable(ca, usage) *
+ fragmented_allowed = ((__dev_buckets_reclaimable(ca, usage) *
ca->mi.bucket_size) >> 1);
- fragmented += usage.d[BCH_DATA_user].fragmented;
+ fragmented = usage.d[BCH_DATA_user].fragmented;
+
+ wait = min(wait, max(0LL, fragmented_allowed - fragmented));
}
- return max_t(s64, 0, fragmented_allowed - fragmented);
+ return wait;
}
static int bch2_copygc_thread(void *arg)