summaryrefslogtreecommitdiff
path: root/fs/bcachefs/movinggc.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-06-18 01:30:17 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:34 +0300
commit54feff0a7ac5ae44b99e697f0fadf81471b33801 (patch)
tree723f71640ec1643ae257681a5e987e20e9d50b2c /fs/bcachefs/movinggc.c
parentc501fef6deb1de13d45d22a3df32906adf17275b (diff)
downloadlinux-54feff0a7ac5ae44b99e697f0fadf81471b33801.tar.xz
bcachefs: Improve "copygc requested to run" error message
This improves the "copygc requested to run but no buckets found" to show the device that requires copygc to be run on - we'll definitely need to improve this more. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/movinggc.c')
-rw-r--r--fs/bcachefs/movinggc.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c
index 6209cb51efcb..1e2de1e818c1 100644
--- a/fs/bcachefs/movinggc.c
+++ b/fs/bcachefs/movinggc.c
@@ -255,7 +255,28 @@ static int bch2_copygc(struct bch_fs *c)
}
if (!h->used) {
- bch_err_ratelimited(c, "copygc requested to run but found no buckets to move!");
+ s64 wait = S64_MAX, dev_wait;
+ u64 dev_min_wait_fragmented = 0;
+ u64 dev_min_wait_allowed = 0;
+ int dev_min_wait = -1;
+
+ for_each_rw_member(ca, c, dev_idx) {
+ struct bch_dev_usage usage = bch2_dev_usage_read(ca);
+ s64 allowed = ((__dev_buckets_available(ca, usage, RESERVE_none) *
+ ca->mi.bucket_size) >> 1);
+ s64 fragmented = usage.d[BCH_DATA_user].fragmented;
+
+ dev_wait = max(0LL, allowed - fragmented);
+
+ if (dev_min_wait < 0 || dev_wait < wait) {
+ dev_min_wait = dev_idx;
+ dev_min_wait_fragmented = fragmented;
+ dev_min_wait_allowed = allowed;
+ }
+ }
+
+ bch_err_ratelimited(c, "copygc requested to run but found no buckets to move! dev %u fragmented %llu allowed %llu",
+ dev_min_wait, dev_min_wait_fragmented, dev_min_wait_allowed);
return 0;
}