4 #include <linux/bcache.h>
6 #include <linux/log2.h>
7 #include <linux/string.h>
9 extern const char * const bch_error_actions[];
10 extern const char * const bch_csum_types[];
11 extern const char * const bch_compression_types[];
12 extern const char * const bch_str_hash_types[];
13 extern const char * const bch_cache_replacement_policies[];
14 extern const char * const bch_cache_modes[];
15 extern const char * const bch_cache_state[];
18 * Mount options; we also store defaults in the superblock.
20 * Also exposed via sysfs: if an option is writeable, and it's also stored in
21 * the superblock, changing it via sysfs (currently? might change this) also
22 * updates the superblock.
24 * We store options as signed integers, where -1 means undefined. This means we
25 * can pass the mount options to cache_set_alloc() as a whole struct, and then
26 * only apply the options from that struct that are defined.
29 extern const char * const bch_bool_opt[];
30 extern const char * const bch_uint_opt[];
32 /* dummy option, for options that aren't stored in the superblock */
33 LE64_BITMASK(NO_SB_OPT, struct bch_sb, flags[0], 0, 0);
35 #define BCH_VISIBLE_OPTS() \
36 BCH_OPT(verbose_recovery, \
42 BCH_OPT(journal_flush_disabled, \
68 struct cache_set_opts {
69 #define BCH_OPT(_name, _choices, _min, _max, _sb_opt, _perm)\
76 static inline struct cache_set_opts cache_set_opts_empty(void)
78 struct cache_set_opts ret;
80 memset(&ret, 255, sizeof(ret));
85 * Initial options from superblock - here we don't want any options undefined,
86 * any options the superblock doesn't specify are set to 0:
88 static inline struct cache_set_opts cache_superblock_opts(struct bch_sb *sb)
90 return (struct cache_set_opts) {
91 #define BCH_OPT(_name, _choices, _min, _max, _sb_opt, _perm)\
92 ._name = _sb_opt##_BITS ? _sb_opt(sb) : 0,
99 static inline void cache_set_opts_apply(struct cache_set_opts *dst,
100 struct cache_set_opts src)
102 #define BCH_OPT(_name, _choices, _min, _max, _sb_opt, _perm)\
103 BUILD_BUG_ON(_max > S8_MAX); \
104 if (src._name >= 0) \
105 dst->_name = src._name;
111 int bch_parse_options(struct cache_set_opts *, int, char *);
113 #endif /* _BCACHE_OPTS_H */