mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-04 08:17:46 +00:00
bcachefs: bch2_trans_log_msg()
Add a new helper for logging messages to the journal - a new debugging tool, an alternative to trace_printk(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
2a6870ada4
commit
5aabb32442
2 changed files with 29 additions and 0 deletions
|
@ -83,6 +83,8 @@ void bch2_trans_commit_hook(struct btree_trans *,
|
|||
struct btree_trans_commit_hook *);
|
||||
int __bch2_trans_commit(struct btree_trans *);
|
||||
|
||||
int bch2_trans_log_msg(struct btree_trans *, const char *);
|
||||
|
||||
/**
|
||||
* bch2_trans_commit - insert keys at given iterator positions
|
||||
*
|
||||
|
|
|
@ -1795,3 +1795,30 @@ int bch2_btree_delete_range(struct bch_fs *c, enum btree_id id,
|
|||
bch2_btree_delete_range_trans(&trans, id, start, end,
|
||||
update_flags, journal_seq));
|
||||
}
|
||||
|
||||
int bch2_trans_log_msg(struct btree_trans *trans, const char *msg)
|
||||
{
|
||||
unsigned len = strlen(msg);
|
||||
unsigned u64s = DIV_ROUND_UP(len, sizeof(u64));
|
||||
struct jset_entry_log *l;
|
||||
int ret;
|
||||
|
||||
ret = darray_make_room(&trans->extra_journal_entries, jset_u64s(u64s));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
l = (void *) &darray_top(trans->extra_journal_entries);
|
||||
l->entry.u64s = cpu_to_le16(u64s);
|
||||
l->entry.btree_id = 0;
|
||||
l->entry.level = 1;
|
||||
l->entry.type = BCH_JSET_ENTRY_log;
|
||||
l->entry.pad[0] = 0;
|
||||
l->entry.pad[1] = 0;
|
||||
l->entry.pad[2] = 0;
|
||||
memcpy(l->d, msg, len);
|
||||
while (len & 7)
|
||||
l->d[len++] = '\0';
|
||||
|
||||
trans->extra_journal_entries.nr += jset_u64s(u64s);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue