mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-02 23:44:27 -05:00
bcachefs: Improve trace_trans_restart_upgrade
- Convert to a 'fs_str' tracepoint that just emits as a string: this lets us build up the tracepoint with a printbuf, using our pretty printers, and they're much easier to manage - Include locks_held, before and after - Include the btree node pointer we failed on (error pointer, null, or real node) Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
@@ -631,6 +631,7 @@ int __bch2_btree_path_upgrade(struct btree_trans *trans,
|
||||
unsigned new_locks_want)
|
||||
{
|
||||
struct get_locks_fail f = {};
|
||||
unsigned old_locks = path->nodes_locked;
|
||||
unsigned old_locks_want = path->locks_want;
|
||||
int ret = 0;
|
||||
|
||||
@@ -670,8 +671,26 @@ int __bch2_btree_path_upgrade(struct btree_trans *trans,
|
||||
}
|
||||
}
|
||||
|
||||
trace_and_count(trans->c, trans_restart_upgrade, trans, _THIS_IP_, path,
|
||||
old_locks_want, new_locks_want, &f);
|
||||
count_event(trans->c, trans_restart_upgrade);
|
||||
if (trace_trans_restart_upgrade_enabled()) {
|
||||
struct printbuf buf = PRINTBUF;
|
||||
|
||||
prt_printf(&buf, "%s %pS\n", trans->fn, (void *) _RET_IP_);
|
||||
prt_printf(&buf, "btree %s pos\n", bch2_btree_id_str(path->btree_id));
|
||||
bch2_bpos_to_text(&buf, path->pos);
|
||||
prt_printf(&buf, "locks want %u -> %u level %u\n",
|
||||
old_locks_want, new_locks_want, f.l);
|
||||
prt_printf(&buf, "nodes_locked %x -> %x\n",
|
||||
old_locks, path->nodes_locked);
|
||||
prt_printf(&buf, "node %s ", IS_ERR(f.b) ? bch2_err_str(PTR_ERR(f.b)) :
|
||||
!f.b ? "(null)" : "(node)");
|
||||
prt_printf(&buf, "path seq %u node seq %u\n",
|
||||
IS_ERR_OR_NULL(f.b) ? 0 : f.b->c.lock.seq,
|
||||
path->l[f.l].lock_seq);
|
||||
|
||||
trace_trans_restart_upgrade(trans->c, buf.buf);
|
||||
printbuf_exit(&buf);
|
||||
}
|
||||
ret = btree_trans_restart(trans, BCH_ERR_transaction_restart_upgrade);
|
||||
out:
|
||||
bch2_trans_verify_locks(trans);
|
||||
|
||||
@@ -1127,51 +1127,9 @@ DEFINE_EVENT(transaction_restart_iter, trans_restart_btree_node_split,
|
||||
TP_ARGS(trans, caller_ip, path)
|
||||
);
|
||||
|
||||
TRACE_EVENT(trans_restart_upgrade,
|
||||
TP_PROTO(struct btree_trans *trans,
|
||||
unsigned long caller_ip,
|
||||
struct btree_path *path,
|
||||
unsigned old_locks_want,
|
||||
unsigned new_locks_want,
|
||||
struct get_locks_fail *f),
|
||||
TP_ARGS(trans, caller_ip, path, old_locks_want, new_locks_want, f),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__array(char, trans_fn, 32 )
|
||||
__field(unsigned long, caller_ip )
|
||||
__field(u8, btree_id )
|
||||
__field(u8, old_locks_want )
|
||||
__field(u8, new_locks_want )
|
||||
__field(u8, level )
|
||||
__field(u32, path_seq )
|
||||
__field(u32, node_seq )
|
||||
TRACE_BPOS_entries(pos)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
|
||||
__entry->caller_ip = caller_ip;
|
||||
__entry->btree_id = path->btree_id;
|
||||
__entry->old_locks_want = old_locks_want;
|
||||
__entry->new_locks_want = new_locks_want;
|
||||
__entry->level = f->l;
|
||||
__entry->path_seq = path->l[f->l].lock_seq;
|
||||
__entry->node_seq = IS_ERR_OR_NULL(f->b) ? 0 : f->b->c.lock.seq;
|
||||
TRACE_BPOS_assign(pos, path->pos)
|
||||
),
|
||||
|
||||
TP_printk("%s %pS btree %s pos %llu:%llu:%u locks_want %u -> %u level %u path seq %u node seq %u",
|
||||
__entry->trans_fn,
|
||||
(void *) __entry->caller_ip,
|
||||
bch2_btree_id_str(__entry->btree_id),
|
||||
__entry->pos_inode,
|
||||
__entry->pos_offset,
|
||||
__entry->pos_snapshot,
|
||||
__entry->old_locks_want,
|
||||
__entry->new_locks_want,
|
||||
__entry->level,
|
||||
__entry->path_seq,
|
||||
__entry->node_seq)
|
||||
DEFINE_EVENT(fs_str, trans_restart_upgrade,
|
||||
TP_PROTO(struct bch_fs *c, const char *str),
|
||||
TP_ARGS(c, str)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(trans_str, trans_restart_relock,
|
||||
|
||||
Reference in New Issue
Block a user