Commit ed13bb57 authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: bch2_prt_csum_opt()



bounds checking helper

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent c2250847
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1030,7 +1030,7 @@ static inline _Bool bch2_csum_type_is_encryption(enum bch_csum_type type)
	x(crc64,		2)	\
	x(xxhash,		3)

enum bch_csum_opts {
enum bch_csum_opt {
#define x(t, n) BCH_CSUM_OPT_##t = n,
	BCH_CSUM_OPTS()
#undef x
+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ int bch2_enable_encryption(struct bch_fs *, bool);
void bch2_fs_encryption_exit(struct bch_fs *);
int bch2_fs_encryption_init(struct bch_fs *);

static inline enum bch_csum_type bch2_csum_opt_to_type(enum bch_csum_opts type,
static inline enum bch_csum_type bch2_csum_opt_to_type(enum bch_csum_opt type,
						       bool data)
{
	switch (type) {
+2 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ static const char * const __bch2_csum_types[] = {
	NULL
};

const char * const bch2_csum_opts[] = {
const char * const __bch2_csum_opts[] = {
	BCH_CSUM_OPTS()
	NULL
};
@@ -113,6 +113,7 @@ void bch2_prt_##name(struct printbuf *out, type t) \
PRT_STR_OPT_BOUNDSCHECKED(jset_entry_type,	enum bch_jset_entry_type);
PRT_STR_OPT_BOUNDSCHECKED(fs_usage_type,	enum bch_fs_usage_type);
PRT_STR_OPT_BOUNDSCHECKED(data_type,		enum bch_data_type);
PRT_STR_OPT_BOUNDSCHECKED(csum_opt,		enum bch_csum_opt);
PRT_STR_OPT_BOUNDSCHECKED(csum_type,		enum bch_csum_type);
PRT_STR_OPT_BOUNDSCHECKED(compression_type,	enum bch_compression_type);
PRT_STR_OPT_BOUNDSCHECKED(str_hash_type,	enum bch_str_hash_type);
+4 −3
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ extern const char * const bch2_version_upgrade_opts[];
extern const char * const bch2_sb_features[];
extern const char * const bch2_sb_compat[];
extern const char * const __bch2_btree_ids[];
extern const char * const bch2_csum_opts[];
extern const char * const __bch2_csum_opts[];
extern const char * const bch2_compression_opts[];
extern const char * const __bch2_str_hash_types[];
extern const char * const bch2_str_hash_opts[];
@@ -27,6 +27,7 @@ extern const char * const bch2_d_types[];
void bch2_prt_jset_entry_type(struct printbuf *,	enum bch_jset_entry_type);
void bch2_prt_fs_usage_type(struct printbuf *,		enum bch_fs_usage_type);
void bch2_prt_data_type(struct printbuf *,		enum bch_data_type);
void bch2_prt_csum_opt(struct printbuf *,		enum bch_csum_opt);
void bch2_prt_csum_type(struct printbuf *,		enum bch_csum_type);
void bch2_prt_compression_type(struct printbuf *,	enum bch_compression_type);
void bch2_prt_str_hash_type(struct printbuf *,		enum bch_str_hash_type);
@@ -171,12 +172,12 @@ enum fsck_err_opts {
	  "size",	"Maximum size of checksummed/compressed extents")\
	x(metadata_checksum,		u8,				\
	  OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,			\
	  OPT_STR(bch2_csum_opts),					\
	  OPT_STR(__bch2_csum_opts),					\
	  BCH_SB_META_CSUM_TYPE,	BCH_CSUM_OPT_crc32c,		\
	  NULL,		NULL)						\
	x(data_checksum,		u8,				\
	  OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,		\
	  OPT_STR(bch2_csum_opts),					\
	  OPT_STR(__bch2_csum_opts),					\
	  BCH_SB_DATA_CSUM_TYPE,	BCH_CSUM_OPT_crc32c,		\
	  NULL,		NULL)						\
	x(compression,			u8,				\