Loading fs/bcachefs/opts.c +9 −0 Original line number Diff line number Diff line Loading @@ -230,6 +230,8 @@ const struct bch_option bch2_opt_table[] = { #define OPT_STR_NOLIMIT(_choices) .type = BCH_OPT_STR, \ .min = 0, .max = U64_MAX, \ .choices = _choices #define OPT_BITFIELD(_choices) .type = BCH_OPT_BITFIELD, \ .choices = _choices #define OPT_FN(_fn) .type = BCH_OPT_FN, .fn = _fn #define x(_name, _bits, _flags, _type, _sb_opt, _default, _hint, _help) \ Loading Loading @@ -376,6 +378,13 @@ int bch2_opt_parse(struct bch_fs *c, *res = ret; break; case BCH_OPT_BITFIELD: { s64 v = bch2_read_flag_list(val, opt->choices); if (v < 0) return v; *res = v; break; } case BCH_OPT_FN: ret = opt->fn.parse(c, val, res, err); Loading fs/bcachefs/opts.h +6 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ enum opt_type { BCH_OPT_BOOL, BCH_OPT_UINT, BCH_OPT_STR, BCH_OPT_BITFIELD, BCH_OPT_FN, }; Loading Loading @@ -477,6 +478,11 @@ enum fsck_err_opts { BCH2_NO_SB_OPT, 1, \ "n", "Data written to this device will be considered\n"\ "to have already been replicated n times") \ x(data_allowed, u8, \ OPT_DEVICE, \ OPT_BITFIELD(__bch2_data_types), \ BCH2_NO_SB_OPT, BIT(BCH_DATA_journal)|BIT(BCH_DATA_btree)|BIT(BCH_DATA_user),\ "types", "Allowed data types for this device: journal, btree, and/or user")\ x(btree_node_prefetch, u8, \ OPT_FS|OPT_MOUNT|OPT_RUNTIME, \ OPT_BOOL(), \ Loading fs/bcachefs/util.c +1 −1 Original line number Diff line number Diff line Loading @@ -204,7 +204,7 @@ STRTO_H(strtoll, long long) STRTO_H(strtoull, unsigned long long) STRTO_H(strtou64, u64) u64 bch2_read_flag_list(char *opt, const char * const list[]) u64 bch2_read_flag_list(const char *opt, const char * const list[]) { u64 ret = 0; char *p, *s, *d = kstrdup(opt, GFP_KERNEL); Loading fs/bcachefs/util.h +1 −1 Original line number Diff line number Diff line Loading @@ -195,7 +195,7 @@ static inline int bch2_strtoul_h(const char *cp, long *res) bool bch2_is_zero(const void *, size_t); u64 bch2_read_flag_list(char *, const char * const[]); u64 bch2_read_flag_list(const char *, const char * const[]); void bch2_prt_u64_base2_nbits(struct printbuf *, u64, unsigned); void bch2_prt_u64_base2(struct printbuf *, u64); Loading Loading
fs/bcachefs/opts.c +9 −0 Original line number Diff line number Diff line Loading @@ -230,6 +230,8 @@ const struct bch_option bch2_opt_table[] = { #define OPT_STR_NOLIMIT(_choices) .type = BCH_OPT_STR, \ .min = 0, .max = U64_MAX, \ .choices = _choices #define OPT_BITFIELD(_choices) .type = BCH_OPT_BITFIELD, \ .choices = _choices #define OPT_FN(_fn) .type = BCH_OPT_FN, .fn = _fn #define x(_name, _bits, _flags, _type, _sb_opt, _default, _hint, _help) \ Loading Loading @@ -376,6 +378,13 @@ int bch2_opt_parse(struct bch_fs *c, *res = ret; break; case BCH_OPT_BITFIELD: { s64 v = bch2_read_flag_list(val, opt->choices); if (v < 0) return v; *res = v; break; } case BCH_OPT_FN: ret = opt->fn.parse(c, val, res, err); Loading
fs/bcachefs/opts.h +6 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ enum opt_type { BCH_OPT_BOOL, BCH_OPT_UINT, BCH_OPT_STR, BCH_OPT_BITFIELD, BCH_OPT_FN, }; Loading Loading @@ -477,6 +478,11 @@ enum fsck_err_opts { BCH2_NO_SB_OPT, 1, \ "n", "Data written to this device will be considered\n"\ "to have already been replicated n times") \ x(data_allowed, u8, \ OPT_DEVICE, \ OPT_BITFIELD(__bch2_data_types), \ BCH2_NO_SB_OPT, BIT(BCH_DATA_journal)|BIT(BCH_DATA_btree)|BIT(BCH_DATA_user),\ "types", "Allowed data types for this device: journal, btree, and/or user")\ x(btree_node_prefetch, u8, \ OPT_FS|OPT_MOUNT|OPT_RUNTIME, \ OPT_BOOL(), \ Loading
fs/bcachefs/util.c +1 −1 Original line number Diff line number Diff line Loading @@ -204,7 +204,7 @@ STRTO_H(strtoll, long long) STRTO_H(strtoull, unsigned long long) STRTO_H(strtou64, u64) u64 bch2_read_flag_list(char *opt, const char * const list[]) u64 bch2_read_flag_list(const char *opt, const char * const list[]) { u64 ret = 0; char *p, *s, *d = kstrdup(opt, GFP_KERNEL); Loading
fs/bcachefs/util.h +1 −1 Original line number Diff line number Diff line Loading @@ -195,7 +195,7 @@ static inline int bch2_strtoul_h(const char *cp, long *res) bool bch2_is_zero(const void *, size_t); u64 bch2_read_flag_list(char *, const char * const[]); u64 bch2_read_flag_list(const char *, const char * const[]); void bch2_prt_u64_base2_nbits(struct printbuf *, u64, unsigned); void bch2_prt_u64_base2(struct printbuf *, u64); Loading