summaryrefslogtreecommitdiff
path: root/fs/bcachefs/compress.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-01-07 05:01:47 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2024-01-21 14:01:45 +0300
commit4f564f4f9fdd4d120ee04678b0c22e40cc8b6b47 (patch)
treee8c593d20f6004d9601bce00d6f02031ffa217ff /fs/bcachefs/compress.h
parente58f963cecbdb08f28334122afba93a7840beabc (diff)
downloadlinux-4f564f4f9fdd4d120ee04678b0c22e40cc8b6b47.tar.xz
bcachefs: bch2_prt_compression_type()
bounds checking helper, since compression types are extensible Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/compress.h')
-rw-r--r--fs/bcachefs/compress.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/bcachefs/compress.h b/fs/bcachefs/compress.h
index 607fd5e232c9..58c2eb45570f 100644
--- a/fs/bcachefs/compress.h
+++ b/fs/bcachefs/compress.h
@@ -47,6 +47,14 @@ static inline enum bch_compression_type bch2_compression_opt_to_type(unsigned v)
return __bch2_compression_opt_to_type[bch2_compression_decode(v).type];
}
+static inline void bch2_prt_compression_type(struct printbuf *out, enum bch_compression_type type)
+{
+ if (type < BCH_COMPRESSION_TYPE_NR)
+ prt_str(out, __bch2_compression_types[type]);
+ else
+ prt_printf(out, "(invalid compression type %u)", type);
+}
+
int bch2_bio_uncompress_inplace(struct bch_fs *, struct bio *,
struct bch_extent_crc_unpacked *);
int bch2_bio_uncompress(struct bch_fs *, struct bio *, struct bio *,