diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-09-25 16:43:55 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-03-13 11:34:37 -0400 |
commit | ca1d15624b9a33affc4ebbeff04a0102d93418af (patch) | |
tree | ac3fe9d2c0a323fc695f3852a5f7feb3af176cd9 | |
parent | d1e24ee89c33dcd190a25fd5f8267e00f8672dbe (diff) |
bcachefs: bch2_print_string_as_lines()
This adds a helper for printing a large buffer one line at a time, to
avoid the 1k printk limit.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/btree_iter.c | 7 | ||||
-rw-r--r-- | fs/bcachefs/util.c | 21 | ||||
-rw-r--r-- | fs/bcachefs/util.h | 2 |
3 files changed, 26 insertions, 4 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 3a564c4a5f5e..38b3c7037e5d 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1334,7 +1334,7 @@ void bch2_dump_trans_updates(struct btree_trans *trans) struct printbuf buf = PRINTBUF; bch2_trans_updates_to_text(&buf, trans); - bch_err(trans->c, "%s", buf.buf); + bch2_print_string_as_lines(KERN_ERR, buf.buf); printbuf_exit(&buf); } @@ -1382,11 +1382,10 @@ void __bch2_dump_trans_paths_updates(struct btree_trans *trans, bool nosort) struct printbuf buf = PRINTBUF; __bch2_trans_paths_to_text(&buf, trans, nosort); + bch2_trans_updates_to_text(&buf, trans); - printk(KERN_ERR "%s", buf.buf); + bch2_print_string_as_lines(KERN_ERR, buf.buf); printbuf_exit(&buf); - - bch2_dump_trans_updates(trans); } noinline __cold diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index 7b08b742387b..ae580bccf650 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -8,6 +8,7 @@ #include <linux/bio.h> #include <linux/blkdev.h> +#include <linux/console.h> #include <linux/ctype.h> #include <linux/debugfs.h> #include <linux/freezer.h> @@ -274,6 +275,26 @@ void bch2_prt_u64_binary(struct printbuf *out, u64 v, unsigned nr_bits) prt_char(out, '0' + ((v >> --nr_bits) & 1)); } +void bch2_print_string_as_lines(const char *prefix, const char *lines) +{ + const char *p; + + if (!lines) { + printk("%s (null)\n", prefix); + return; + } + + console_lock(); + while (1) { + p = strchrnul(lines, '\n'); + printk("%s%.*s\n", prefix, (int) (p - lines), lines); + if (!*p) + break; + lines = p + 1; + } + console_unlock(); +} + /* time stats: */ #ifndef CONFIG_BCACHEFS_NO_LATENCY_ACCT diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index 192d8b53f2ca..a16f8bb9d415 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -382,6 +382,8 @@ u64 bch2_read_flag_list(char *, const char * const[]); void bch2_prt_u64_binary(struct printbuf *, u64, unsigned); +void bch2_print_string_as_lines(const char *prefix, const char *lines); + #define NR_QUANTILES 15 #define QUANTILE_IDX(i) inorder_to_eytzinger0(i, NR_QUANTILES) #define QUANTILE_FIRST eytzinger0_first(NR_QUANTILES) |