From: Kent Overstreet Date: Tue, 13 Apr 2021 18:45:55 +0000 (-0400) Subject: bcachefs: Add copygc wait to sysfs X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5bbe4bf95bdd18500c5de52e5d38a91fbb5f6234;p=linux.git bcachefs: Add copygc wait to sysfs Currently debugging an issue with copygc not running when it's supposed to, and this is an obvious first step. Signed-off-by: Kent Overstreet Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index 76b72ed693a8f..234918fdd7170 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -773,6 +773,7 @@ mempool_t bio_bounce_pages; copygc_heap copygc_heap; struct bch_pd_controller copygc_pd; struct write_point copygc_write_point; + s64 copygc_wait; /* STRIPES: */ GENRADIX(struct stripe) stripes[2]; diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c index b8da600cdc530..113013d1fc48e 100644 --- a/fs/bcachefs/movinggc.c +++ b/fs/bcachefs/movinggc.c @@ -311,11 +311,14 @@ static int bch2_copygc_thread(void *arg) wait = bch2_copygc_wait_amount(c); if (wait > clock->max_slop) { + c->copygc_wait = last + wait; bch2_kthread_io_clock_wait(clock, last + wait, MAX_SCHEDULE_TIMEOUT); continue; } + c->copygc_wait = 0; + if (bch2_copygc(c)) break; } diff --git a/fs/bcachefs/sysfs.c b/fs/bcachefs/sysfs.c index 9f75f72f7b12f..1f31458ffec90 100644 --- a/fs/bcachefs/sysfs.c +++ b/fs/bcachefs/sysfs.c @@ -188,6 +188,7 @@ rw_attribute(cache_replacement_policy); rw_attribute(label); rw_attribute(copy_gc_enabled); +read_attribute(copy_gc_wait); sysfs_pd_controller_attribute(copy_gc); rw_attribute(rebalance_enabled); @@ -336,6 +337,9 @@ SHOW(bch2_fs) sysfs_printf(rebalance_enabled, "%i", c->rebalance.enabled); sysfs_pd_controller_show(rebalance, &c->rebalance.pd); /* XXX */ sysfs_pd_controller_show(copy_gc, &c->copygc_pd); + sysfs_hprint(copy_gc_wait, + max(0LL, c->copygc_wait - + atomic64_read(&c->io_clock[WRITE].now)) << 9); if (attr == &sysfs_rebalance_work) { bch2_rebalance_work_to_text(&out, c); @@ -563,6 +567,7 @@ struct attribute *bch2_fs_internal_files[] = { &sysfs_prune_cache, &sysfs_copy_gc_enabled, + &sysfs_copy_gc_wait, &sysfs_rebalance_enabled, &sysfs_rebalance_work,