Commit afbc7194 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Improve bch2_btree_trans_to_text()

This is just a formatting/readability improvement.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 8b31e4fc
...@@ -2947,7 +2947,7 @@ void bch2_trans_exit(struct btree_trans *trans) ...@@ -2947,7 +2947,7 @@ void bch2_trans_exit(struct btree_trans *trans)
} }
static void __maybe_unused static void __maybe_unused
bch2_btree_path_node_to_text(struct printbuf *out, bch2_btree_bkey_cached_common_to_text(struct printbuf *out,
struct btree_bkey_cached_common *b) struct btree_bkey_cached_common *b)
{ {
struct six_lock_count c = six_lock_counts(&b->lock); struct six_lock_count c = six_lock_counts(&b->lock);
...@@ -2959,10 +2959,12 @@ bch2_btree_path_node_to_text(struct printbuf *out, ...@@ -2959,10 +2959,12 @@ bch2_btree_path_node_to_text(struct printbuf *out,
pid = owner ? owner->pid : 0;; pid = owner ? owner->pid : 0;;
rcu_read_unlock(); rcu_read_unlock();
prt_printf(out, " l=%u %s:", prt_tab(out);
prt_printf(out, "%px %c l=%u %s:", b, b->cached ? 'c' : 'b',
b->level, bch2_btree_ids[b->btree_id]); b->level, bch2_btree_ids[b->btree_id]);
bch2_bpos_to_text(out, btree_node_pos(b)); bch2_bpos_to_text(out, btree_node_pos(b));
prt_tab(out);
prt_printf(out, " locks %u:%u:%u held by pid %u", prt_printf(out, " locks %u:%u:%u held by pid %u",
c.n[0], c.n[1], c.n[2], pid); c.n[0], c.n[1], c.n[2], pid);
} }
...@@ -2974,6 +2976,11 @@ void bch2_btree_trans_to_text(struct printbuf *out, struct btree_trans *trans) ...@@ -2974,6 +2976,11 @@ void bch2_btree_trans_to_text(struct printbuf *out, struct btree_trans *trans)
static char lock_types[] = { 'r', 'i', 'w' }; static char lock_types[] = { 'r', 'i', 'w' };
unsigned l; unsigned l;
if (!out->nr_tabstops) {
printbuf_tabstop_push(out, 16);
printbuf_tabstop_push(out, 32);
}
prt_printf(out, "%i %s\n", trans->locking_wait.task->pid, trans->fn); prt_printf(out, "%i %s\n", trans->locking_wait.task->pid, trans->fn);
trans_for_each_path(trans, path) { trans_for_each_path(trans, path) {
...@@ -2986,24 +2993,26 @@ void bch2_btree_trans_to_text(struct printbuf *out, struct btree_trans *trans) ...@@ -2986,24 +2993,26 @@ void bch2_btree_trans_to_text(struct printbuf *out, struct btree_trans *trans)
path->level, path->level,
bch2_btree_ids[path->btree_id]); bch2_btree_ids[path->btree_id]);
bch2_bpos_to_text(out, path->pos); bch2_bpos_to_text(out, path->pos);
prt_printf(out, "\n"); prt_newline(out);
for (l = 0; l < BTREE_MAX_DEPTH; l++) { for (l = 0; l < BTREE_MAX_DEPTH; l++) {
if (btree_node_locked(path, l) && if (btree_node_locked(path, l) &&
!IS_ERR_OR_NULL(b = (void *) READ_ONCE(path->l[l].b))) { !IS_ERR_OR_NULL(b = (void *) READ_ONCE(path->l[l].b))) {
prt_printf(out, " %c l=%u ", prt_printf(out, " %c l=%u ",
lock_types[btree_node_locked_type(path, l)], l); lock_types[btree_node_locked_type(path, l)], l);
bch2_btree_path_node_to_text(out, b); bch2_btree_bkey_cached_common_to_text(out, b);
prt_printf(out, "\n"); prt_newline(out);
} }
} }
} }
b = READ_ONCE(trans->locking); b = READ_ONCE(trans->locking);
if (b) { if (b) {
prt_printf(out, " locking node "); prt_str(out, " want");
bch2_btree_path_node_to_text(out, b); prt_newline(out);
prt_printf(out, "\n"); prt_printf(out, " %c", lock_types[trans->locking_wait.lock_want]);
bch2_btree_bkey_cached_common_to_text(out, b);
prt_newline(out);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment