bcachefs: bch2_read_bio_to_text
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 2 Feb 2025 16:23:07 +0000 (11:23 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:14:29 +0000 (20:14 -0400)
Pretty printer for struct bch_read_bio.

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

index c3034338f9e4236c101fb447455eaf927d1749f5..9b44f11fb0d9b2b7d4d425b7bfb18667c9328e5c 100644 (file)
@@ -587,6 +587,10 @@ void bch2_data_update_opts_to_text(struct printbuf *out, struct bch_fs *c,
 
        prt_str_indented(out, "extra replicas:\t");
        prt_u64(out, data_opts->extra_replicas);
+       prt_newline(out);
+
+       prt_str_indented(out, "scrub:\t");
+       prt_u64(out, data_opts->scrub);
 }
 
 void bch2_data_update_to_text(struct printbuf *out, struct data_update *m)
@@ -607,9 +611,17 @@ void bch2_data_update_inflight_to_text(struct printbuf *out, struct data_update
        prt_newline(out);
        printbuf_indent_add(out, 2);
        bch2_data_update_opts_to_text(out, m->op.c, &m->op.opts, &m->data_opts);
-       prt_printf(out, "read_done:\t%u\n", m->read_done);
-       bch2_write_op_to_text(out, &m->op);
-       printbuf_indent_sub(out, 2);
+
+       if (!m->read_done) {
+               prt_printf(out, "read:\n");
+               printbuf_indent_add(out, 2);
+               bch2_read_bio_to_text(out, &m->rbio);
+       } else {
+               prt_printf(out, "write:\n");
+               printbuf_indent_add(out, 2);
+               bch2_write_op_to_text(out, &m->op);
+       }
+       printbuf_indent_sub(out, 4);
 }
 
 int bch2_extent_drop_ptrs(struct btree_trans *trans,
index 136b6d54a2c2c6911e2eb1712ae354961a86781f..df96e2c8ceda26ec967aa149158631b3772b87e7 100644 (file)
@@ -1487,6 +1487,41 @@ err:
        return ret;
 }
 
+static const char * const bch2_read_bio_flags[] = {
+#define x(n)   #n,
+       BCH_READ_FLAGS()
+#undef x
+       NULL
+};
+
+void bch2_read_bio_to_text(struct printbuf *out, struct bch_read_bio *rbio)
+{
+       u64 now = local_clock();
+       prt_printf(out, "start_time:\t%llu\n", rbio->start_time ? now - rbio->start_time : 0);
+       prt_printf(out, "submit_time:\t%llu\n", rbio->submit_time ? now - rbio->submit_time : 0);
+
+       if (!rbio->split)
+               prt_printf(out, "end_io:\t%ps\n", rbio->end_io);
+       else
+               prt_printf(out, "parent:\t%px\n", rbio->parent);
+
+       prt_printf(out, "bi_end_io:\t%ps\n", rbio->bio.bi_end_io);
+
+       prt_printf(out, "promote:\t%u\n",       rbio->promote);
+       prt_printf(out, "bounce:\t%u\n",        rbio->bounce);
+       prt_printf(out, "split:\t%u\n",         rbio->split);
+       prt_printf(out, "have_ioref:\t%u\n",    rbio->have_ioref);
+       prt_printf(out, "narrow_crcs:\t%u\n",   rbio->narrow_crcs);
+       prt_printf(out, "context:\t%u\n",       rbio->context);
+       prt_printf(out, "ret:\t%s\n",           bch2_err_str(rbio->ret));
+
+       prt_printf(out, "flags:\t");
+       bch2_prt_bitflags(out, bch2_read_bio_flags, rbio->flags);
+       prt_newline(out);
+
+       bch2_bio_to_text(out, &rbio->bio);
+}
+
 void bch2_fs_io_read_exit(struct bch_fs *c)
 {
        if (c->promote_table.tbl)
index 1a85b092fd1d3291b3fb8083aa9bc6bc6b41679c..13bb68eb91c4ede27cc0ee0278af7f3da1ad2bde 100644 (file)
@@ -193,6 +193,8 @@ static inline struct bch_read_bio *rbio_init(struct bio *bio,
        return rbio;
 }
 
+void bch2_read_bio_to_text(struct printbuf *, struct bch_read_bio *);
+
 void bch2_fs_io_read_exit(struct bch_fs *);
 int bch2_fs_io_read_init(struct bch_fs *);