Lines Matching +full:c +full:- +full:define +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0
10 #include "super-io.h"
13 #define x(t, n, ...) [n] = #t,
97 static int bch2_opt_fix_errors_parse(struct bch_fs *c, const char *val, u64 *res, in bch2_opt_fix_errors_parse() argument
103 int ret = match_string(bch2_fsck_fix_opts, -1, val); in bch2_opt_fix_errors_parse()
116 struct bch_fs *c, in bch2_opt_fix_errors_to_text() argument
123 #define bch2_opt_fix_errors (struct bch_opt_fn) { \
153 #define x(_name, ...) \ in bch2_opts_apply()
164 #define x(_name, ...) \ in bch2_opt_defined_by_id()
177 #define x(_name, ...) \ in bch2_opt_get_by_id()
179 return opts->_name; in bch2_opt_get_by_id()
190 #define x(_name, ...) \ in bch2_opt_set_by_id()
202 #define OPT_BOOL() .type = BCH_OPT_BOOL, .min = 0, .max = 2
203 #define OPT_UINT(_min, _max) .type = BCH_OPT_UINT, \
205 #define OPT_STR(_choices) .type = BCH_OPT_STR, \
208 #define OPT_FN(_fn) .type = BCH_OPT_FN, .fn = _fn
210 #define x(_name, _bits, _flags, _type, _sb_opt, _default, _hint, _help) \
213 .name = #_name, \
228 int bch2_opt_lookup(const char *name) in bch2_opt_lookup() argument
235 if (!strcmp(name, i->attr.name)) in bch2_opt_lookup()
236 return i - bch2_opt_table; in bch2_opt_lookup()
238 return -1; in bch2_opt_lookup()
249 static int bch2_mount_opt_lookup(const char *name) in bch2_mount_opt_lookup() argument
256 if (!strcmp(name, i->s1)) in bch2_mount_opt_lookup()
257 name = i->s2; in bch2_mount_opt_lookup()
259 return bch2_opt_lookup(name); in bch2_mount_opt_lookup()
264 if (v < opt->min) { in bch2_opt_validate()
267 opt->attr.name, opt->min); in bch2_opt_validate()
268 return -BCH_ERR_ERANGE_option_too_small; in bch2_opt_validate()
271 if (opt->max && v >= opt->max) { in bch2_opt_validate()
274 opt->attr.name, opt->max); in bch2_opt_validate()
275 return -BCH_ERR_ERANGE_option_too_big; in bch2_opt_validate()
278 if ((opt->flags & OPT_SB_FIELD_SECTORS) && (v & 511)) { in bch2_opt_validate()
281 opt->attr.name); in bch2_opt_validate()
282 return -BCH_ERR_opt_parse_error; in bch2_opt_validate()
285 if ((opt->flags & OPT_MUST_BE_POW_2) && !is_power_of_2(v)) { in bch2_opt_validate()
288 opt->attr.name); in bch2_opt_validate()
289 return -BCH_ERR_opt_parse_error; in bch2_opt_validate()
292 if (opt->fn.validate) in bch2_opt_validate()
293 return opt->fn.validate(v, err); in bch2_opt_validate()
298 int bch2_opt_parse(struct bch_fs *c, in bch2_opt_parse() argument
305 switch (opt->type) { in bch2_opt_parse()
316 prt_printf(err, "%s: must be bool", opt->attr.name); in bch2_opt_parse()
323 opt->attr.name); in bch2_opt_parse()
324 return -EINVAL; in bch2_opt_parse()
327 ret = opt->flags & OPT_HUMAN_READABLE in bch2_opt_parse()
333 opt->attr.name); in bch2_opt_parse()
340 opt->attr.name); in bch2_opt_parse()
341 return -EINVAL; in bch2_opt_parse()
344 ret = match_string(opt->choices, -1, val); in bch2_opt_parse()
348 opt->attr.name); in bch2_opt_parse()
355 ret = opt->fn.parse(c, val, res, err); in bch2_opt_parse()
359 opt->attr.name); in bch2_opt_parse()
368 struct bch_fs *c, struct bch_sb *sb, in bch2_opt_to_text() argument
373 if (opt->type == BCH_OPT_BOOL) { in bch2_opt_to_text()
376 opt->attr.name); in bch2_opt_to_text()
380 prt_printf(out, "%s=", opt->attr.name); in bch2_opt_to_text()
383 switch (opt->type) { in bch2_opt_to_text()
386 if (opt->flags & OPT_HUMAN_READABLE) in bch2_opt_to_text()
393 prt_string_option(out, opt->choices, v); in bch2_opt_to_text()
395 prt_str(out, opt->choices[v]); in bch2_opt_to_text()
398 opt->fn.to_text(out, c, sb, v); in bch2_opt_to_text()
405 int bch2_opt_check_may_set(struct bch_fs *c, int id, u64 v) in bch2_opt_check_may_set() argument
412 ret = bch2_check_set_has_compressed_data(c, v); in bch2_opt_check_may_set()
416 bch2_check_set_feature(c, BCH_FEATURE_ec); in bch2_opt_check_may_set()
423 int bch2_opts_check_may_set(struct bch_fs *c) in bch2_opts_check_may_set() argument
429 ret = bch2_opt_check_may_set(c, i, in bch2_opts_check_may_set()
430 bch2_opt_get_by_id(&c->opts, i)); in bch2_opts_check_may_set()
438 int bch2_parse_mount_opts(struct bch_fs *c, struct bch_opts *opts, in bch2_parse_mount_opts() argument
442 char *opt, *name, *val; in bch2_parse_mount_opts() local
452 * starting with a comma - weird. in bch2_parse_mount_opts()
459 return -1; in bch2_parse_mount_opts()
463 name = strsep(&opt, "="); in bch2_parse_mount_opts()
466 id = bch2_mount_opt_lookup(name); in bch2_parse_mount_opts()
471 !strncmp("no", name, 2)) { in bch2_parse_mount_opts()
472 id = bch2_mount_opt_lookup(name + 2); in bch2_parse_mount_opts()
492 ret = bch2_opt_parse(c, &bch2_opt_table[id], val, &v, &err); in bch2_parse_mount_opts()
503 pr_err("Bad mount option %s", name); in bch2_parse_mount_opts()
504 ret = -1; in bch2_parse_mount_opts()
508 ret = -1; in bch2_parse_mount_opts()
521 v = opt->get_sb(sb); in bch2_opt_from_sb()
523 if (opt->flags & OPT_SB_FIELD_ILOG2) in bch2_opt_from_sb()
526 if (opt->flags & OPT_SB_FIELD_SECTORS) in bch2_opt_from_sb()
533 * Initial options from superblock - here we don't want any options undefined,
543 if (opt->get_sb == BCH2_NO_SB_OPT) in bch2_opts_from_sb()
554 if (opt->set_sb == SET_BCH2_NO_SB_OPT) in __bch2_opt_set_sb()
557 if (opt->flags & OPT_SB_FIELD_SECTORS) in __bch2_opt_set_sb()
560 if (opt->flags & OPT_SB_FIELD_ILOG2) in __bch2_opt_set_sb()
563 opt->set_sb(sb, v); in __bch2_opt_set_sb()
566 void bch2_opt_set_sb(struct bch_fs *c, const struct bch_option *opt, u64 v) in bch2_opt_set_sb() argument
568 if (opt->set_sb == SET_BCH2_NO_SB_OPT) in bch2_opt_set_sb()
571 mutex_lock(&c->sb_lock); in bch2_opt_set_sb()
572 __bch2_opt_set_sb(c->disk_sb.sb, opt, v); in bch2_opt_set_sb()
573 bch2_write_super(c); in bch2_opt_set_sb()
574 mutex_unlock(&c->sb_lock); in bch2_opt_set_sb()
582 #define x(_name, _bits) ._name = src._name, in bch2_opts_to_inode_opts()
591 #define x(_name, _bits) Opt_##_name, in bch2_opt_is_inode_opt()