]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bcachefs: rebalance, copygc status also print stacktrace
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 13 Mar 2025 19:21:13 +0000 (15:21 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 16 Mar 2025 17:47:55 +0000 (13:47 -0400)
These are commonly needed when debugging, and saves from having to ask
users to dig.

Also, rebalance_status now includes pending rebalance work.

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

index 0787d04a5fc3873aa540137407ba57778fe1596c..f86fb8ad636a82ebc4b618e8c21aa351c1da5d7a 100644 (file)
@@ -1251,17 +1251,17 @@ void bch2_move_stats_to_text(struct printbuf *out, struct bch_move_stats *stats)
        prt_newline(out);
        printbuf_indent_add(out, 2);
 
-       prt_printf(out, "keys moved:  %llu\n",  atomic64_read(&stats->keys_moved));
-       prt_printf(out, "keys raced:  %llu\n",  atomic64_read(&stats->keys_raced));
-       prt_printf(out, "bytes seen:  ");
+       prt_printf(out, "keys moved:\t%llu\n",  atomic64_read(&stats->keys_moved));
+       prt_printf(out, "keys raced:\t%llu\n",  atomic64_read(&stats->keys_raced));
+       prt_printf(out, "bytes seen:\t");
        prt_human_readable_u64(out, atomic64_read(&stats->sectors_seen) << 9);
        prt_newline(out);
 
-       prt_printf(out, "bytes moved: ");
+       prt_printf(out, "bytes moved:\t");
        prt_human_readable_u64(out, atomic64_read(&stats->sectors_moved) << 9);
        prt_newline(out);
 
-       prt_printf(out, "bytes raced: ");
+       prt_printf(out, "bytes raced:\t");
        prt_human_readable_u64(out, atomic64_read(&stats->sectors_raced) << 9);
        prt_newline(out);
 
@@ -1270,7 +1270,8 @@ void bch2_move_stats_to_text(struct printbuf *out, struct bch_move_stats *stats)
 
 static void bch2_moving_ctxt_to_text(struct printbuf *out, struct bch_fs *c, struct moving_context *ctxt)
 {
-       struct moving_io *io;
+       if (!out->nr_tabstops)
+               printbuf_tabstop_push(out, 32);
 
        bch2_move_stats_to_text(out, ctxt->stats);
        printbuf_indent_add(out, 2);
@@ -1290,6 +1291,7 @@ static void bch2_moving_ctxt_to_text(struct printbuf *out, struct bch_fs *c, str
        printbuf_indent_add(out, 2);
 
        mutex_lock(&ctxt->lock);
+       struct moving_io *io;
        list_for_each_entry(io, &ctxt->ios, io_list)
                bch2_data_update_inflight_to_text(out, &io->write);
        mutex_unlock(&ctxt->lock);
index fa19fc44622c9627a0adbc98d9f3a35f79f0f472..5126c870ce5b5afe7e62d783d761a5e8977d0504 100644 (file)
@@ -317,6 +317,17 @@ void bch2_copygc_wait_to_text(struct printbuf *out, struct bch_fs *c)
        prt_printf(out, "Currently calculated wait:\t");
        prt_human_readable_u64(out, bch2_copygc_wait_amount(c));
        prt_newline(out);
+
+       rcu_read_lock();
+       struct task_struct *t = rcu_dereference(c->copygc_thread);
+       if (t)
+               get_task_struct(t);
+       rcu_read_unlock();
+
+       if (t) {
+               bch2_prt_task_backtrace(out, t, 0, GFP_KERNEL);
+               put_task_struct(t);
+       }
 }
 
 static int bch2_copygc_thread(void *arg)
index 58f6d97e506cbf1f4c7034b724f1588fa66c4cef..8b6795ec82f6e50c723245a94b7ae4666c205396 100644 (file)
@@ -590,8 +590,19 @@ static int bch2_rebalance_thread(void *arg)
 
 void bch2_rebalance_status_to_text(struct printbuf *out, struct bch_fs *c)
 {
+       printbuf_tabstop_push(out, 32);
+
        struct bch_fs_rebalance *r = &c->rebalance;
 
+       /* print pending work */
+       struct disk_accounting_pos acc = { .type = BCH_DISK_ACCOUNTING_rebalance_work, };
+       u64 v;
+       bch2_accounting_mem_read(c, disk_accounting_pos_to_bpos(&acc), &v, 1);
+
+       prt_printf(out, "pending work:\t");
+       prt_human_readable_u64(out, v);
+       prt_printf(out, "\n\n");
+
        prt_str(out, bch2_rebalance_state_strs[r->state]);
        prt_newline(out);
        printbuf_indent_add(out, 2);
@@ -600,15 +611,15 @@ void bch2_rebalance_status_to_text(struct printbuf *out, struct bch_fs *c)
        case BCH_REBALANCE_waiting: {
                u64 now = atomic64_read(&c->io_clock[WRITE].now);
 
-               prt_str(out, "io wait duration:  ");
+               prt_printf(out, "io wait duration:\t");
                bch2_prt_human_readable_s64(out, (r->wait_iotime_end - r->wait_iotime_start) << 9);
                prt_newline(out);
 
-               prt_str(out, "io wait remaining: ");
+               prt_printf(out, "io wait remaining:\t");
                bch2_prt_human_readable_s64(out, (r->wait_iotime_end - now) << 9);
                prt_newline(out);
 
-               prt_str(out, "duration waited:   ");
+               prt_printf(out, "duration waited:\t");
                bch2_pr_time_units(out, ktime_get_real_ns() - r->wait_wallclock_start);
                prt_newline(out);
                break;
@@ -621,6 +632,18 @@ void bch2_rebalance_status_to_text(struct printbuf *out, struct bch_fs *c)
                break;
        }
        prt_newline(out);
+
+       rcu_read_lock();
+       struct task_struct *t = rcu_dereference(c->rebalance.thread);
+       if (t)
+               get_task_struct(t);
+       rcu_read_unlock();
+
+       if (t) {
+               bch2_prt_task_backtrace(out, t, 0, GFP_KERNEL);
+               put_task_struct(t);
+       }
+
        printbuf_indent_sub(out, 2);
 }