bcachefs: bch2_trans_updates_to_text()

This turns bch2_dump_trans_updates() into a to_text() method - this way
it can be used by debug tracing.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2022-03-11 18:38:24 -05:00 committed by Kent Overstreet
parent 2158fe463b
commit 8570d775ca
2 changed files with 29 additions and 14 deletions

View File

@ -1793,30 +1793,44 @@ free:
__bch2_path_free(trans, path);
}
noinline __cold
void bch2_dump_trans_updates(struct btree_trans *trans)
void bch2_trans_updates_to_text(struct printbuf *buf, struct btree_trans *trans)
{
struct btree_insert_entry *i;
struct printbuf buf1 = PRINTBUF, buf2 = PRINTBUF;
bch_err(trans->c, "transaction updates:");
pr_buf(buf, "transaction updates for %s journal seq %llu",
trans->fn, trans->journal_res.seq);
pr_newline(buf);
pr_indent_push(buf, 2);
trans_for_each_update(trans, i) {
struct bkey_s_c old = { &i->old_k, i->old_v };
printbuf_reset(&buf1);
printbuf_reset(&buf2);
bch2_bkey_val_to_text(&buf1, trans->c, old);
bch2_bkey_val_to_text(&buf2, trans->c, bkey_i_to_s_c(i->k));
printk(KERN_ERR "update: btree %s %pS\n old %s\n new %s",
pr_buf(buf, "update: btree=%s cached=%u %pS",
bch2_btree_ids[i->btree_id],
(void *) i->ip_allocated,
buf1.buf, buf2.buf);
i->cached,
(void *) i->ip_allocated);
pr_newline(buf);
pr_buf(buf, " old ");
bch2_bkey_val_to_text(buf, trans->c, old);
pr_newline(buf);
pr_buf(buf, " new ");
bch2_bkey_val_to_text(buf, trans->c, bkey_i_to_s_c(i->k));
pr_newline(buf);
}
printbuf_exit(&buf2);
printbuf_exit(&buf1);
pr_indent_pop(buf, 2);
}
noinline __cold
void bch2_dump_trans_updates(struct btree_trans *trans)
{
struct printbuf buf = PRINTBUF;
bch2_trans_updates_to_text(&buf, trans);
bch_err(trans->c, "%s", buf.buf);
printbuf_exit(&buf);
}
noinline __cold

View File

@ -425,6 +425,7 @@ __bch2_btree_iter_peek_and_restart(struct btree_trans *trans,
/* new multiple iterator interface: */
void bch2_trans_updates_to_text(struct printbuf *, struct btree_trans *);
void bch2_dump_trans_updates(struct btree_trans *);
void bch2_dump_trans_paths_updates(struct btree_trans *);
void __bch2_trans_init(struct btree_trans *, struct bch_fs *,