mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 21:51:40 +00:00
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>
This commit is contained in:
parent
e9174370d0
commit
a8f3542843
@ -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
|
||||
|
@ -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>
|
||||
@ -244,6 +245,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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user