Commit 36008d5d authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Plumb more logging through stdio redirect

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent a850bde6
...@@ -267,6 +267,8 @@ do { \ ...@@ -267,6 +267,8 @@ do { \
#define bch2_fmt(_c, fmt) bch2_log_msg(_c, fmt "\n") #define bch2_fmt(_c, fmt) bch2_log_msg(_c, fmt "\n")
void bch2_print_str(struct bch_fs *, const char *);
__printf(2, 3) __printf(2, 3)
void bch2_print_opts(struct bch_opts *, const char *, ...); void bch2_print_opts(struct bch_opts *, const char *, ...);
......
...@@ -1465,7 +1465,7 @@ void bch2_dump_trans_updates(struct btree_trans *trans) ...@@ -1465,7 +1465,7 @@ void bch2_dump_trans_updates(struct btree_trans *trans)
struct printbuf buf = PRINTBUF; struct printbuf buf = PRINTBUF;
bch2_trans_updates_to_text(&buf, trans); bch2_trans_updates_to_text(&buf, trans);
bch2_print_string_as_lines(KERN_ERR, buf.buf); bch2_print_str(trans->c, buf.buf);
printbuf_exit(&buf); printbuf_exit(&buf);
} }
...@@ -1557,7 +1557,7 @@ void __bch2_dump_trans_paths_updates(struct btree_trans *trans, bool nosort) ...@@ -1557,7 +1557,7 @@ void __bch2_dump_trans_paths_updates(struct btree_trans *trans, bool nosort)
__bch2_trans_paths_to_text(&buf, trans, nosort); __bch2_trans_paths_to_text(&buf, trans, nosort);
bch2_trans_updates_to_text(&buf, trans); bch2_trans_updates_to_text(&buf, trans);
bch2_print_string_as_lines(KERN_ERR, buf.buf); bch2_print_str(trans->c, buf.buf);
printbuf_exit(&buf); printbuf_exit(&buf);
} }
......
...@@ -89,6 +89,19 @@ const char * const bch2_fs_flag_strs[] = { ...@@ -89,6 +89,19 @@ const char * const bch2_fs_flag_strs[] = {
NULL NULL
}; };
void bch2_print_str(struct bch_fs *c, const char *str)
{
#ifdef __KERNEL__
struct stdio_redirect *stdio = bch2_fs_stdio_redirect(c);
if (unlikely(stdio)) {
bch2_stdio_redirect_printf(stdio, true, "%s", str);
return;
}
#endif
bch2_print_string_as_lines(KERN_ERR, str);
}
__printf(2, 0) __printf(2, 0)
static void bch2_print_maybe_redirect(struct stdio_redirect *stdio, const char *fmt, va_list args) static void bch2_print_maybe_redirect(struct stdio_redirect *stdio, const char *fmt, va_list args)
{ {
......
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