bcachefs: Improved copygc wait debugging
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 17 Mar 2023 13:59:17 +0000 (09:59 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:58 +0000 (17:09 -0400)
This just adds a line for how long copygc has been waiting to sysfs
copygc_wait, helpful for debugging why copygc isn't running.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bcachefs.h
fs/bcachefs/movinggc.c

index fcbbc88d77c214962006f71a895974db954356ca..db8c0e4fc5a3499e9f21a3e05a926f787408cff4 100644 (file)
@@ -943,6 +943,7 @@ struct bch_fs {
        /* COPYGC */
        struct task_struct      *copygc_thread;
        struct write_point      copygc_write_point;
+       s64                     copygc_wait_at;
        s64                     copygc_wait;
        bool                    copygc_running;
        wait_queue_head_t       copygc_running_wq;
index 4762594f628700681bed06f2b509002ef9b29a3c..e91067b428cd8eb9357d9558e21a9f990a4f82ca 100644 (file)
@@ -269,6 +269,12 @@ void bch2_copygc_wait_to_text(struct printbuf *out, struct bch_fs *c)
                                        atomic64_read(&c->io_clock[WRITE].now)) << 9);
        prt_newline(out);
 
+       prt_printf(out, "Currently waiting since:   ");
+       prt_human_readable_u64(out, max(0LL,
+                                       atomic64_read(&c->io_clock[WRITE].now) -
+                                       c->copygc_wait_at) << 9);
+       prt_newline(out);
+
        prt_printf(out, "Currently calculated wait: ");
        prt_human_readable_u64(out, bch2_copygc_wait_amount(c));
        prt_newline(out);
@@ -317,9 +323,11 @@ static int bch2_copygc_thread(void *arg)
                wait = bch2_copygc_wait_amount(c);
 
                if (wait > clock->max_slop) {
+                       c->copygc_wait_at = last;
+                       c->copygc_wait = last + wait;
+
                        move_buckets_wait(&trans, &ctxt, &move_buckets, 0, true);
                        trace_and_count(c, copygc_wait, c, wait, last + wait);
-                       c->copygc_wait = last + wait;
                        bch2_kthread_io_clock_wait(clock, last + wait,
                                        MAX_SCHEDULE_TIMEOUT);
                        continue;