diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-09-25 16:43:55 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-03 23:55:19 -0400 |
commit | 64d7794b1b0d45a5825ad2a2516762296d06d161 (patch) | |
tree | fa74071568d500914af41aab08862c5c41ac8135 | |
parent | d3e275713324b596e7a7874581796880a29e7536 (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 | 22 | ||||
-rw-r--r-- | fs/bcachefs/util.h | 2 |
3 files changed, 27 insertions, 4 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index c11e8e8168c4..30a031ca35d8 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1354,7 +1354,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); } @@ -1390,11 +1390,10 @@ void bch2_dump_trans_paths_updates(struct btree_trans *trans) struct printbuf buf = PRINTBUF; bch2_trans_paths_to_text(&buf, trans); + 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 diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index 42da6623d815..81befc433aeb 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,27 @@ 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; + prefix = KERN_CONT; + } + console_unlock(); +} + /* time stats: */ static void bch2_time_stats_update_one(struct time_stats *stats, diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index ab7e43d4bf8b..aa8b416a919a 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -355,6 +355,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) |