diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-08-14 20:44:17 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:09:38 +0200 |
commit | d0b50524f1d9b60318b92830546b45cd3325cfe2 (patch) | |
tree | 06b1e2c3ee3838177342d1139be73713e65a5cf9 /fs/bcachefs/util.c | |
parent | bcachefs: Add assertions for unexpected transaction restarts (diff) | |
download | linux-d0b50524f1d9b60318b92830546b45cd3325cfe2.tar.xz linux-d0b50524f1d9b60318b92830546b45cd3325cfe2.zip |
bcachefs: bch2_bkey_packed_to_binary_text()
For debugging the eytzinger search tree code, and low level bkey packing
code, it can be helpful to see things in binary: this patch improves our
helpers for doing so.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/util.c')
-rw-r--r-- | fs/bcachefs/util.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index cb07ef2ceb59..61cd44c5a6b4 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -238,6 +238,12 @@ bool bch2_is_zero(const void *_p, size_t n) return true; } +void bch2_prt_u64_binary(struct printbuf *out, u64 v, unsigned nr_bits) +{ + while (nr_bits) + prt_char(out, '0' + ((v >> --nr_bits) & 1)); +} + /* time stats: */ #ifndef CONFIG_BCACHEFS_NO_LATENCY_ACCT |