summaryrefslogtreecommitdiff
path: root/fs/bcachefs/movinggc.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-04-13 16:49:23 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:08:54 +0300
commitcb66fc5fe4cc806d60d8884cb82b67c357b49640 (patch)
tree7259c200084c9baf05d68584f2346abe957165e8 /fs/bcachefs/movinggc.c
parent006d69aa2655f1a0ca4e47666939669f27bb740f (diff)
downloadlinux-cb66fc5fe4cc806d60d8884cb82b67c357b49640.tar.xz
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 <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.c5
1 files changed, 2 insertions, 3 deletions
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;
}