]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bcachefs: trace_io_move_write_fail
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 15 Mar 2025 23:24:44 +0000 (19:24 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 24 Mar 2025 13:50:34 +0000 (09:50 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/io_write.c
fs/bcachefs/move.c
fs/bcachefs/sb-counters_format.h
fs/bcachefs/trace.h

index 48befbae0226bfc9b268e3900bbc9e9f45a605eb..a2e6b30530e3df51b3f3ff40f14bd03e4e05ed55 100644 (file)
@@ -1742,20 +1742,26 @@ static const char * const bch2_write_flags[] = {
 
 void bch2_write_op_to_text(struct printbuf *out, struct bch_write_op *op)
 {
-       prt_str(out, "pos: ");
+       if (!out->nr_tabstops)
+               printbuf_tabstop_push(out, 32);
+
+       prt_printf(out, "pos:\t");
        bch2_bpos_to_text(out, op->pos);
        prt_newline(out);
        printbuf_indent_add(out, 2);
 
-       prt_str(out, "started: ");
+       prt_printf(out, "started:\t");
        bch2_pr_time_units(out, local_clock() - op->start_time);
        prt_newline(out);
 
-       prt_str(out, "flags: ");
+       prt_printf(out, "flags:\t");
        prt_bitflags(out, bch2_write_flags, op->flags);
        prt_newline(out);
 
-       prt_printf(out, "ref: %u\n", closure_nr_remaining(&op->cl));
+       prt_printf(out, "nr_replicas:\t%u\n", op->nr_replicas);
+       prt_printf(out, "nr_replicas_required:\t%u\n", op->nr_replicas_required);
+
+       prt_printf(out, "ref:\t%u\n", closure_nr_remaining(&op->cl));
 
        printbuf_indent_sub(out, 2);
 }
index 10843a2ebb88948eac7a1a3653fe945ba617e02e..2d9ce7fb581897ffae3c4f517056ec1a37d4a30b 100644 (file)
@@ -101,13 +101,25 @@ static void move_free(struct moving_io *io)
 static void move_write_done(struct bch_write_op *op)
 {
        struct moving_io *io = container_of(op, struct moving_io, write.op);
+       struct bch_fs *c = op->c;
        struct moving_context *ctxt = io->write.ctxt;
 
-       if (io->write.op.error)
+       if (op->error) {
+               if (trace_io_move_write_fail_enabled()) {
+                       struct printbuf buf = PRINTBUF;
+
+                       bch2_write_op_to_text(&buf, op);
+                       prt_printf(&buf, "ret\t%s\n", bch2_err_str(op->error));
+                       trace_io_move_write_fail(c, buf.buf);
+                       printbuf_exit(&buf);
+               }
+               this_cpu_inc(c->counters[BCH_COUNTER_io_move_write_fail]);
+
                ctxt->write_error = true;
+       }
 
-       atomic_sub(io->write_sectors, &io->write.ctxt->write_sectors);
-       atomic_dec(&io->write.ctxt->write_ios);
+       atomic_sub(io->write_sectors, &ctxt->write_sectors);
+       atomic_dec(&ctxt->write_ios);
        move_free(io);
        closure_put(&ctxt->cl);
 }
index c82a891026d35d22c4d84c7e2c9a3b35e490a90f..fa27ec59a6474b011876b494994a211f033c01bc 100644 (file)
@@ -22,6 +22,7 @@ enum counters_flags {
        x(io_move_write,                                36,     TYPE_SECTORS)   \
        x(io_move_finish,                               37,     TYPE_SECTORS)   \
        x(io_move_fail,                                 38,     TYPE_COUNTER)   \
+       x(io_move_write_fail,                           82,     TYPE_COUNTER)   \
        x(io_move_start_fail,                           39,     TYPE_COUNTER)   \
        x(bucket_invalidate,                            3,      TYPE_COUNTER)   \
        x(bucket_discard,                               4,      TYPE_COUNTER)   \
index c8669a6b9cec2c23d4ca1d9b9d6d9160c04f0f11..519d00d62ae7484262befe01ad44e74c30a203b3 100644 (file)
@@ -846,6 +846,11 @@ DEFINE_EVENT(fs_str, io_move_fail,
        TP_ARGS(c, str)
 );
 
+DEFINE_EVENT(fs_str, io_move_write_fail,
+       TP_PROTO(struct bch_fs *c, const char *str),
+       TP_ARGS(c, str)
+);
+
 DEFINE_EVENT(fs_str, io_move_start_fail,
        TP_PROTO(struct bch_fs *c, const char *str),
        TP_ARGS(c, str)