Lines Matching refs:opt

290 int bch2_opt_validate(const struct bch_option *opt, u64 v, struct printbuf *err)  in bch2_opt_validate()  argument
292 if (v < opt->min) { in bch2_opt_validate()
295 opt->attr.name, opt->min); in bch2_opt_validate()
299 if (opt->max && v >= opt->max) { in bch2_opt_validate()
302 opt->attr.name, opt->max); in bch2_opt_validate()
306 if ((opt->flags & OPT_SB_FIELD_SECTORS) && (v & 511)) { in bch2_opt_validate()
309 opt->attr.name); in bch2_opt_validate()
313 if ((opt->flags & OPT_MUST_BE_POW_2) && !is_power_of_2(v)) { in bch2_opt_validate()
316 opt->attr.name); in bch2_opt_validate()
320 if (opt->fn.validate) in bch2_opt_validate()
321 return opt->fn.validate(v, err); in bch2_opt_validate()
327 const struct bch_option *opt, in bch2_opt_parse() argument
333 switch (opt->type) { in bch2_opt_parse()
344 prt_printf(err, "%s: must be bool", opt->attr.name); in bch2_opt_parse()
351 opt->attr.name); in bch2_opt_parse()
355 ret = opt->flags & OPT_HUMAN_READABLE in bch2_opt_parse()
361 opt->attr.name); in bch2_opt_parse()
368 opt->attr.name); in bch2_opt_parse()
372 ret = match_string(opt->choices, -1, val); in bch2_opt_parse()
376 opt->attr.name); in bch2_opt_parse()
383 s64 v = bch2_read_flag_list(val, opt->choices); in bch2_opt_parse()
390 ret = opt->fn.parse(c, val, res, err); in bch2_opt_parse()
398 opt->attr.name); in bch2_opt_parse()
403 return bch2_opt_validate(opt, *res, err); in bch2_opt_parse()
408 const struct bch_option *opt, u64 v, in bch2_opt_to_text() argument
412 if (opt->type == BCH_OPT_BOOL) { in bch2_opt_to_text()
415 opt->attr.name); in bch2_opt_to_text()
419 prt_printf(out, "%s=", opt->attr.name); in bch2_opt_to_text()
422 switch (opt->type) { in bch2_opt_to_text()
425 if (opt->flags & OPT_HUMAN_READABLE) in bch2_opt_to_text()
431 if (v < opt->min || v >= opt->max) in bch2_opt_to_text()
434 prt_string_option(out, opt->choices, v); in bch2_opt_to_text()
436 prt_str(out, opt->choices[v]); in bch2_opt_to_text()
439 prt_bitflags(out, opt->choices, v); in bch2_opt_to_text()
442 opt->fn.to_text(out, c, sb, v); in bch2_opt_to_text()
458 const struct bch_option *opt = &bch2_opt_table[i]; in bch2_opts_to_text() local
460 if ((opt->flags & hide_mask) || !(opt->flags & show_mask)) in bch2_opts_to_text()
471 bch2_opt_to_text(out, c, sb, opt, v, flags); in bch2_opts_to_text()
581 char *opt, *name, *val; in bch2_parse_mount_opts() local
599 while ((opt = strsep(&copied_opts, ",")) != NULL) { in bch2_parse_mount_opts()
600 if (!*opt) in bch2_parse_mount_opts()
603 name = strsep(&opt, "="); in bch2_parse_mount_opts()
604 val = opt; in bch2_parse_mount_opts()
621 const struct bch_option *opt = bch2_opt_table + id; in bch2_opt_from_sb() local
624 v = opt->get_sb(sb); in bch2_opt_from_sb()
626 if (opt->flags & OPT_SB_FIELD_ILOG2) in bch2_opt_from_sb()
629 if (opt->flags & OPT_SB_FIELD_SECTORS) in bch2_opt_from_sb()
644 const struct bch_option *opt = bch2_opt_table + id; in bch2_opts_from_sb() local
646 if (opt->get_sb == BCH2_NO_SB_OPT) in bch2_opts_from_sb()
666 const struct bch_option *opt, u64 v) in __bch2_opt_set_sb() argument
668 enum bch_opt_id id = opt - bch2_opt_table; in __bch2_opt_set_sb()
670 if (opt->flags & OPT_SB_FIELD_SECTORS) in __bch2_opt_set_sb()
673 if (opt->flags & OPT_SB_FIELD_ILOG2) in __bch2_opt_set_sb()
676 if (opt->flags & OPT_SB_FIELD_ONE_BIAS) in __bch2_opt_set_sb()
679 if (opt->flags & OPT_FS) { in __bch2_opt_set_sb()
680 if (opt->set_sb != SET_BCH2_NO_SB_OPT) in __bch2_opt_set_sb()
681 opt->set_sb(sb, v); in __bch2_opt_set_sb()
684 if ((opt->flags & OPT_DEVICE) && dev_idx >= 0) { in __bch2_opt_set_sb()
687 opt->attr.name, dev_idx)) in __bch2_opt_set_sb()
696 pr_err("option %s cannot be set via opt_set_sb()", opt->attr.name); in __bch2_opt_set_sb()
701 const struct bch_option *opt, u64 v) in bch2_opt_set_sb() argument
704 __bch2_opt_set_sb(c->disk_sb.sb, ca ? ca->dev_idx : -1, opt, v); in bch2_opt_set_sb()