bcachefs: bch2_read_bio_to_text

Pretty printer for struct bch_read_bio.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2025-02-02 11:23:07 -05:00
parent 5f0de475f9
commit 989b4c375a
3 changed files with 52 additions and 3 deletions

View 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,

View File

@ -1487,6 +1487,41 @@ int __bch2_read(struct btree_trans *trans, struct bch_read_bio *rbio,
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)

View 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 *);