From cb66fc5fe4cc806d60d8884cb82b67c357b49640 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Tue, 13 Apr 2021 09:49:23 -0400 Subject: bcachefs: Fix copygc threshold Awhile back the meaning of is_available_bucket() and thus also bch_dev_usage->buckets_unavailable changed to include buckets that are owned by the allocator - this was so that the stat could be persisted like other allocation information, and wouldn't have to be regenerated by walking each bucket at mount time. This broke copygc, which needs to consider buckets that are reclaimable and haven't yet been grabbed by the allocator thread and moved onta freelist. This patch fixes that by adding dev_buckets_reclaimable() for copygc and the allocator thread, and cleans up some of the callers a bit. Signed-off-by: Kent Overstreet Signed-off-by: Kent Overstreet --- fs/bcachefs/movinggc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'fs/bcachefs/movinggc.c') diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c index 65a8cd14ee75..b8da600cdc53 100644 --- a/fs/bcachefs/movinggc.c +++ b/fs/bcachefs/movinggc.c @@ -282,13 +282,12 @@ unsigned long bch2_copygc_wait_amount(struct bch_fs *c) { struct bch_dev *ca; unsigned dev_idx; - u64 fragmented_allowed = c->copygc_threshold; - u64 fragmented = 0; + u64 fragmented_allowed = 0, fragmented = 0; for_each_rw_member(ca, c, dev_idx) { struct bch_dev_usage usage = bch2_dev_usage_read(ca); - fragmented_allowed += ((__dev_buckets_available(ca, usage) * + fragmented_allowed += ((__dev_buckets_reclaimable(ca, usage) * ca->mi.bucket_size) >> 1); fragmented += usage.d[BCH_DATA_user].fragmented; } -- cgit v1.2.3