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_dev_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 bch_fs_alloc() as a whole struct, and then only
26 * apply the options from that struct that are defined.
29 /* dummy option, for options that aren't stored in the superblock */
30 LE64_BITMASK(NO_SB_OPT, struct bch_sb, flags[0], 0, 0);
33 * BCH_OPT(name, mode, sb_opt, type, ...)
35 * @name - name of mount option, sysfs attribute, and struct bch_opts
38 * @mode - sysfs attr permissions
40 * @sb_option - name of corresponding superblock option
42 * @type - one of OPT_BOOL, OPT_UINT, OPT_STR
51 #define BCH_VISIBLE_OPTS() \
52 BCH_OPT(errors, 0644, BCH_SB_ERROR_ACTION, \
53 s8, OPT_STR(bch_error_actions)) \
54 BCH_OPT(metadata_replicas, 0444, BCH_SB_META_REPLICAS_WANT,\
55 s8, OPT_UINT(0, BCH_REPLICAS_MAX)) \
56 BCH_OPT(data_replicas, 0444, BCH_SB_DATA_REPLICAS_WANT,\
57 s8, OPT_UINT(0, BCH_REPLICAS_MAX)) \
58 BCH_OPT(metadata_checksum, 0644, BCH_SB_META_CSUM_TYPE, \
59 s8, OPT_STR(bch_csum_types)) \
60 BCH_OPT(data_checksum, 0644, BCH_SB_DATA_CSUM_TYPE, \
61 s8, OPT_STR(bch_csum_types)) \
62 BCH_OPT(compression, 0644, BCH_SB_COMPRESSION_TYPE,\
63 s8, OPT_STR(bch_compression_types)) \
64 BCH_OPT(str_hash, 0644, BCH_SB_STR_HASH_TYPE, \
65 s8, OPT_STR(bch_str_hash_types)) \
66 BCH_OPT(inodes_32bit, 0644, BCH_SB_INODE_32BIT, \
68 BCH_OPT(gc_reserve_percent, 0444, BCH_SB_GC_RESERVE, \
69 s8, OPT_UINT(5, 21)) \
70 BCH_OPT(root_reserve_percent, 0444, BCH_SB_ROOT_RESERVE, \
71 s8, OPT_UINT(0, 100)) \
72 BCH_OPT(wide_macs, 0644, BCH_SB_128_BIT_MACS, \
74 BCH_OPT(verbose_recovery, 0444, NO_SB_OPT, \
76 BCH_OPT(posix_acl, 0444, NO_SB_OPT, \
78 BCH_OPT(journal_flush_disabled, 0644, NO_SB_OPT, \
80 BCH_OPT(nofsck, 0444, NO_SB_OPT, \
82 BCH_OPT(fix_errors, 0444, NO_SB_OPT, \
84 BCH_OPT(nochanges, 0444, NO_SB_OPT, \
86 BCH_OPT(noreplay, 0444, NO_SB_OPT, \
88 BCH_OPT(norecovery, 0444, NO_SB_OPT, \
92 BCH_OPT(read_only, 0444, NO_SB_OPT, \
97 #define BCH_OPT(_name, _mode, _sb_opt, _bits, ...) \
105 #define BCH_OPT(_name, ...) \
114 void (*set_sb)(struct bch_sb *, u64);
122 const char * const *choices;
128 extern const struct bch_option bch_opt_table[];
130 static inline struct bch_opts bch_opts_empty(void)
134 memset(&ret, 255, sizeof(ret));
138 static inline void bch_opts_apply(struct bch_opts *dst, struct bch_opts src)
140 #define BCH_OPT(_name, ...) \
141 if (src._name >= 0) \
142 dst->_name = src._name;
148 void bch_opt_set(struct bch_opts *, enum bch_opt_id, u64);
149 struct bch_opts bch_sb_opts(struct bch_sb *);
151 int bch_parse_mount_opts(struct bch_opts *, char *);
152 enum bch_opt_id bch_parse_sysfs_opt(const char *, const char *, u64 *);
154 ssize_t bch_opt_show(struct bch_opts *, const char *, char *, size_t);
156 #endif /* _BCACHE_OPTS_H */