]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: bch2_trans_updates_to_text()
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 11 Mar 2022 23:38:24 +0000 (18:38 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:27 +0000 (17:09 -0400)
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>
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_iter.h

index f33dc465759006aab4234afeeebd3f9497295f20..cfaab8cbcad0cb04bcbddb8c6717ed02db62aa16 100644 (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
index 72cb694f76fd5b3f0350004904b607628be45db9..30a2a2cef29bc507480e1f22af3a2795a1a6bb3f 100644 (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 *,