Lines Matching full:opt

292 int bch2_opt_validate(const struct bch_option *opt, u64 v, struct printbuf *err)  in bch2_opt_validate()  argument
294 if (v < opt->min) { in bch2_opt_validate()
297 opt->attr.name, opt->min); in bch2_opt_validate()
301 if (opt->max && v >= opt->max) { in bch2_opt_validate()
304 opt->attr.name, opt->max); in bch2_opt_validate()
308 if ((opt->flags & OPT_SB_FIELD_SECTORS) && (v & 511)) { in bch2_opt_validate()
311 opt->attr.name); in bch2_opt_validate()
315 if ((opt->flags & OPT_MUST_BE_POW_2) && !is_power_of_2(v)) { in bch2_opt_validate()
318 opt->attr.name); in bch2_opt_validate()
322 if (opt->fn.validate) in bch2_opt_validate()
323 return opt->fn.validate(v, err); in bch2_opt_validate()
329 const struct bch_option *opt, in bch2_opt_parse() argument
335 switch (opt->type) { in bch2_opt_parse()
343 prt_printf(err, "%s: must be bool", opt->attr.name); in bch2_opt_parse()
354 opt->attr.name); in bch2_opt_parse()
358 ret = opt->flags & OPT_HUMAN_READABLE in bch2_opt_parse()
364 opt->attr.name); in bch2_opt_parse()
371 opt->attr.name); in bch2_opt_parse()
375 ret = match_string(opt->choices, -1, val); in bch2_opt_parse()
379 opt->attr.name); in bch2_opt_parse()
386 s64 v = bch2_read_flag_list(val, opt->choices); in bch2_opt_parse()
393 ret = opt->fn.parse(c, val, res, err); in bch2_opt_parse()
401 opt->attr.name); in bch2_opt_parse()
406 return bch2_opt_validate(opt, *res, err); in bch2_opt_parse()
411 const struct bch_option *opt, u64 v, in bch2_opt_to_text() argument
415 if (opt->type == BCH_OPT_BOOL) { in bch2_opt_to_text()
418 opt->attr.name); in bch2_opt_to_text()
422 prt_printf(out, "%s=", opt->attr.name); in bch2_opt_to_text()
425 switch (opt->type) { in bch2_opt_to_text()
428 if (opt->flags & OPT_HUMAN_READABLE) in bch2_opt_to_text()
434 if (v < opt->min || v >= opt->max) in bch2_opt_to_text()
437 prt_string_option(out, opt->choices, v); in bch2_opt_to_text()
439 prt_str(out, opt->choices[v]); in bch2_opt_to_text()
442 prt_bitflags(out, opt->choices, v); in bch2_opt_to_text()
445 opt->fn.to_text(out, c, sb, v); in bch2_opt_to_text()
461 const struct bch_option *opt = &bch2_opt_table[i]; in bch2_opts_to_text() local
463 if ((opt->flags & hide_mask) || !(opt->flags & show_mask)) in bch2_opts_to_text()
474 bch2_opt_to_text(out, c, sb, opt, v, flags); in bch2_opts_to_text()
521 /* Check for the form "noopt", negation of a boolean opt: */ in bch2_parse_one_mount_opt()
584 char *opt, *name, *val; in bch2_parse_mount_opts() local
602 while ((opt = strsep(&copied_opts, ",")) != NULL) { in bch2_parse_mount_opts()
603 if (!*opt) in bch2_parse_mount_opts()
606 name = strsep(&opt, "="); in bch2_parse_mount_opts()
607 val = opt; in bch2_parse_mount_opts()
624 const struct bch_option *opt = bch2_opt_table + id; in bch2_opt_from_sb() local
627 v = opt->get_sb(sb); in bch2_opt_from_sb()
629 if (opt->flags & OPT_SB_FIELD_ILOG2) in bch2_opt_from_sb()
632 if (opt->flags & OPT_SB_FIELD_SECTORS) in bch2_opt_from_sb()
647 const struct bch_option *opt = bch2_opt_table + id; in bch2_opts_from_sb() local
649 if (opt->get_sb == BCH2_NO_SB_OPT) in bch2_opts_from_sb()
669 const struct bch_option *opt, u64 v) in __bch2_opt_set_sb() argument
671 enum bch_opt_id id = opt - bch2_opt_table; in __bch2_opt_set_sb()
673 if (opt->flags & OPT_SB_FIELD_SECTORS) in __bch2_opt_set_sb()
676 if (opt->flags & OPT_SB_FIELD_ILOG2) in __bch2_opt_set_sb()
679 if (opt->flags & OPT_SB_FIELD_ONE_BIAS) in __bch2_opt_set_sb()
682 if (opt->flags & OPT_FS) { in __bch2_opt_set_sb()
683 if (opt->set_sb != SET_BCH2_NO_SB_OPT) in __bch2_opt_set_sb()
684 opt->set_sb(sb, v); in __bch2_opt_set_sb()
687 if ((opt->flags & OPT_DEVICE) && dev_idx >= 0) { in __bch2_opt_set_sb()
690 opt->attr.name, dev_idx)) in __bch2_opt_set_sb()
699 pr_err("option %s cannot be set via opt_set_sb()", opt->attr.name); in __bch2_opt_set_sb()
704 const struct bch_option *opt, u64 v) in bch2_opt_set_sb() argument
707 __bch2_opt_set_sb(c->disk_sb.sb, ca ? ca->dev_idx : -1, opt, v); in bch2_opt_set_sb()