bcachefs: Add copygc wait to sysfs
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 13 Apr 2021 18:45:55 +0000 (14:45 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:54 +0000 (17:08 -0400)
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 <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bcachefs.h
fs/bcachefs/movinggc.c
fs/bcachefs/sysfs.c

index 76b72ed693a8f70b48a7b0071a5c4949912be74d..234918fdd717058110d6a094863b4d193e7a0797 100644 (file)
@@ -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];
index b8da600cdc530e377923b3f93550cd72d5201fad..113013d1fc48e55a1c3850ca85aabcb9f3cddd79 100644 (file)
@@ -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;
        }
index 9f75f72f7b12f46784e8bb7868b64a0ce68c071d..1f31458ffec90c2240f3d5a5305b1067179e21aa 100644 (file)
@@ -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,