bcachefs: data_allowed is now an opts.h option
need this so cmd_option in userspace can handle it Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
8573dd3474
commit
afefc986b7
@ -230,6 +230,8 @@ const struct bch_option bch2_opt_table[] = {
|
|||||||
#define OPT_STR_NOLIMIT(_choices) .type = BCH_OPT_STR, \
|
#define OPT_STR_NOLIMIT(_choices) .type = BCH_OPT_STR, \
|
||||||
.min = 0, .max = U64_MAX, \
|
.min = 0, .max = U64_MAX, \
|
||||||
.choices = _choices
|
.choices = _choices
|
||||||
|
#define OPT_BITFIELD(_choices) .type = BCH_OPT_BITFIELD, \
|
||||||
|
.choices = _choices
|
||||||
#define OPT_FN(_fn) .type = BCH_OPT_FN, .fn = _fn
|
#define OPT_FN(_fn) .type = BCH_OPT_FN, .fn = _fn
|
||||||
|
|
||||||
#define x(_name, _bits, _flags, _type, _sb_opt, _default, _hint, _help) \
|
#define x(_name, _bits, _flags, _type, _sb_opt, _default, _hint, _help) \
|
||||||
@ -376,6 +378,13 @@ int bch2_opt_parse(struct bch_fs *c,
|
|||||||
|
|
||||||
*res = ret;
|
*res = ret;
|
||||||
break;
|
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:
|
case BCH_OPT_FN:
|
||||||
ret = opt->fn.parse(c, val, res, err);
|
ret = opt->fn.parse(c, val, res, err);
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ enum opt_type {
|
|||||||
BCH_OPT_BOOL,
|
BCH_OPT_BOOL,
|
||||||
BCH_OPT_UINT,
|
BCH_OPT_UINT,
|
||||||
BCH_OPT_STR,
|
BCH_OPT_STR,
|
||||||
|
BCH_OPT_BITFIELD,
|
||||||
BCH_OPT_FN,
|
BCH_OPT_FN,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -477,6 +478,11 @@ enum fsck_err_opts {
|
|||||||
BCH2_NO_SB_OPT, 1, \
|
BCH2_NO_SB_OPT, 1, \
|
||||||
"n", "Data written to this device will be considered\n"\
|
"n", "Data written to this device will be considered\n"\
|
||||||
"to have already been replicated n times") \
|
"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, \
|
x(btree_node_prefetch, u8, \
|
||||||
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
||||||
OPT_BOOL(), \
|
OPT_BOOL(), \
|
||||||
|
@ -204,7 +204,7 @@ STRTO_H(strtoll, long long)
|
|||||||
STRTO_H(strtoull, unsigned long long)
|
STRTO_H(strtoull, unsigned long long)
|
||||||
STRTO_H(strtou64, u64)
|
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;
|
u64 ret = 0;
|
||||||
char *p, *s, *d = kstrdup(opt, GFP_KERNEL);
|
char *p, *s, *d = kstrdup(opt, GFP_KERNEL);
|
||||||
|
@ -195,7 +195,7 @@ static inline int bch2_strtoul_h(const char *cp, long *res)
|
|||||||
|
|
||||||
bool bch2_is_zero(const void *, size_t);
|
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_nbits(struct printbuf *, u64, unsigned);
|
||||||
void bch2_prt_u64_base2(struct printbuf *, u64);
|
void bch2_prt_u64_base2(struct printbuf *, u64);
|
||||||
|
Loading…
Reference in New Issue
Block a user