diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-03-30 15:44:12 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:28 -0400 |
commit | 5aabb32442c44c9cfc41a2c29638aebeb3e9cb26 (patch) | |
tree | fba4b6a5dcf5500e201a025cd6b824197dc91f23 /fs/bcachefs/btree_update_leaf.c | |
parent | 2a6870ada4340c3a72e381143bc67252f4d243a4 (diff) | |
download | lwn-5aabb32442c44c9cfc41a2c29638aebeb3e9cb26.tar.gz lwn-5aabb32442c44c9cfc41a2c29638aebeb3e9cb26.zip |
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>
Diffstat (limited to 'fs/bcachefs/btree_update_leaf.c')
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index d6ec3f6c9be8..2640d3e38a76 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -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; +} |