mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
bcachefs: bch2_prt_compression_type()
bounds checking helper, since compression types are extensible Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
e58f963cec
commit
4f564f4f9f
@ -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 *,
|
||||
|
@ -1018,12 +1018,12 @@ void bch2_bkey_ptrs_to_text(struct printbuf *out, struct bch_fs *c,
|
||||
struct bch_extent_crc_unpacked crc =
|
||||
bch2_extent_crc_unpack(k.k, entry_to_crc(entry));
|
||||
|
||||
prt_printf(out, "crc: c_size %u size %u offset %u nonce %u csum %s compress %s",
|
||||
prt_printf(out, "crc: c_size %u size %u offset %u nonce %u csum %s compress ",
|
||||
crc.compressed_size,
|
||||
crc.uncompressed_size,
|
||||
crc.offset, crc.nonce,
|
||||
bch2_csum_types[crc.csum_type],
|
||||
bch2_compression_types[crc.compression_type]);
|
||||
bch2_csum_types[crc.csum_type]);
|
||||
bch2_prt_compression_type(out, crc.compression_type);
|
||||
break;
|
||||
}
|
||||
case BCH_EXTENT_ENTRY_stripe_ptr: {
|
||||
|
@ -52,7 +52,7 @@ const char * const bch2_csum_opts[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
const char * const bch2_compression_types[] = {
|
||||
const char * const __bch2_compression_types[] = {
|
||||
BCH_COMPRESSION_TYPES()
|
||||
NULL
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ extern const char * const bch2_sb_compat[];
|
||||
extern const char * const __bch2_btree_ids[];
|
||||
extern const char * const bch2_csum_types[];
|
||||
extern const char * const bch2_csum_opts[];
|
||||
extern const char * const bch2_compression_types[];
|
||||
extern const char * const __bch2_compression_types[];
|
||||
extern const char * const bch2_compression_opts[];
|
||||
extern const char * const bch2_str_hash_types[];
|
||||
extern const char * const bch2_str_hash_opts[];
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "btree_gc.h"
|
||||
#include "buckets.h"
|
||||
#include "clock.h"
|
||||
#include "compress.h"
|
||||
#include "disk_groups.h"
|
||||
#include "ec.h"
|
||||
#include "inode.h"
|
||||
@ -330,7 +331,7 @@ static int bch2_compression_stats_to_text(struct printbuf *out, struct bch_fs *c
|
||||
prt_newline(out);
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(s); i++) {
|
||||
prt_str(out, bch2_compression_types[i]);
|
||||
bch2_prt_compression_type(out, i);
|
||||
prt_tab(out);
|
||||
|
||||
prt_human_readable_u64(out, s[i].sectors_compressed << 9);
|
||||
|
Loading…
Reference in New Issue
Block a user