]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bcachefs: Plumb more logging through stdio redirect
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 30 May 2024 02:06:00 +0000 (22:06 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 14 Jul 2024 23:00:14 +0000 (19:00 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bcachefs.h
fs/bcachefs/btree_iter.c
fs/bcachefs/super.c

index 33605fa8e70f06094d9f2875b6fda638b71d8cb6..e0e9afb08ef615c7c9d7659ac4bfaa8883c27335 100644 (file)
@@ -267,6 +267,8 @@ do {                                                                        \
 
 #define bch2_fmt(_c, fmt)              bch2_log_msg(_c, fmt "\n")
 
+void bch2_print_str(struct bch_fs *, const char *);
+
 __printf(2, 3)
 void bch2_print_opts(struct bch_opts *, const char *, ...);
 
index 755909f7b55dd3e72b31e8e0905b3a7d5842bb87..849a397bb919048aab6a2fc2fdef285ba74523e3 100644 (file)
@@ -1465,7 +1465,7 @@ void bch2_dump_trans_updates(struct btree_trans *trans)
        struct printbuf buf = PRINTBUF;
 
        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);
 }
 
@@ -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_updates_to_text(&buf, trans);
 
-       bch2_print_string_as_lines(KERN_ERR, buf.buf);
+       bch2_print_str(trans->c, buf.buf);
        printbuf_exit(&buf);
 }
 
index b9f851103297e9467cf479ffae6e65f341f6ec06..c22a8ef2d2e1633fc1370e888a8f2924bd707625 100644 (file)
@@ -89,6 +89,19 @@ const char * const bch2_fs_flag_strs[] = {
        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)
 static void bch2_print_maybe_redirect(struct stdio_redirect *stdio, const char *fmt, va_list args)
 {