]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/opts.h
Update bcachefs sources to aa439f3b94 bcachefs: btree_gc no longer uses main in-memor...
[bcachefs-tools-debian] / libbcachefs / opts.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_OPTS_H
3 #define _BCACHEFS_OPTS_H
4
5 #include <linux/bug.h>
6 #include <linux/log2.h>
7 #include <linux/string.h>
8 #include <linux/sysfs.h>
9 #include "bcachefs_format.h"
10
11 extern const char * const bch2_error_actions[];
12 extern const char * const bch2_sb_features[];
13 extern const char * const bch2_sb_compat[];
14 extern const char * const bch2_btree_ids[];
15 extern const char * const bch2_csum_types[];
16 extern const char * const bch2_csum_opts[];
17 extern const char * const bch2_compression_types[];
18 extern const char * const bch2_compression_opts[];
19 extern const char * const bch2_str_hash_types[];
20 extern const char * const bch2_str_hash_opts[];
21 extern const char * const bch2_data_types[];
22 extern const char * const bch2_member_states[];
23 extern const char * const bch2_jset_entry_types[];
24 extern const char * const bch2_fs_usage_types[];
25 extern const char * const bch2_d_types[];
26
27 static inline const char *bch2_d_type_str(unsigned d_type)
28 {
29         return (d_type < BCH_DT_MAX ? bch2_d_types[d_type] : NULL) ?: "(bad d_type)";
30 }
31
32 /*
33  * Mount options; we also store defaults in the superblock.
34  *
35  * Also exposed via sysfs: if an option is writeable, and it's also stored in
36  * the superblock, changing it via sysfs (currently? might change this) also
37  * updates the superblock.
38  *
39  * We store options as signed integers, where -1 means undefined. This means we
40  * can pass the mount options to bch2_fs_alloc() as a whole struct, and then only
41  * apply the options from that struct that are defined.
42  */
43
44 /* dummy option, for options that aren't stored in the superblock */
45 LE64_BITMASK(NO_SB_OPT,         struct bch_sb, flags[0], 0, 0);
46
47 /* When can be set: */
48 enum opt_flags {
49         OPT_FS          = (1 << 0),     /* Filesystem option */
50         OPT_DEVICE      = (1 << 1),     /* Device option */
51         OPT_INODE       = (1 << 2),     /* Inode option */
52         OPT_FORMAT      = (1 << 3),     /* May be specified at format time */
53         OPT_MOUNT       = (1 << 4),     /* May be specified at mount time */
54         OPT_RUNTIME     = (1 << 5),     /* May be specified at runtime */
55         OPT_HUMAN_READABLE = (1 << 6),
56         OPT_MUST_BE_POW_2 = (1 << 7),   /* Must be power of 2 */
57         OPT_SB_FIELD_SECTORS = (1 << 8),/* Superblock field is >> 9 of actual value */
58         OPT_SB_FIELD_ILOG2 = (1 << 9),  /* Superblock field is ilog2 of actual value */
59 };
60
61 enum opt_type {
62         BCH_OPT_BOOL,
63         BCH_OPT_UINT,
64         BCH_OPT_STR,
65         BCH_OPT_FN,
66 };
67
68 /**
69  * x(name, shortopt, type, in mem type, mode, sb_opt)
70  *
71  * @name        - name of mount option, sysfs attribute, and struct bch_opts
72  *                member
73  *
74  * @mode        - when opt may be set
75  *
76  * @sb_option   - name of corresponding superblock option
77  *
78  * @type        - one of OPT_BOOL, OPT_UINT, OPT_STR
79  */
80
81 /*
82  * XXX: add fields for
83  *  - default value
84  *  - helptext
85  */
86
87 #ifdef __KERNEL__
88 #define RATELIMIT_ERRORS_DEFAULT true
89 #else
90 #define RATELIMIT_ERRORS_DEFAULT false
91 #endif
92
93 #define BCH_OPTS()                                                      \
94         x(block_size,                   u16,                            \
95           OPT_FS|OPT_FORMAT|                                            \
96           OPT_HUMAN_READABLE|OPT_MUST_BE_POW_2|OPT_SB_FIELD_SECTORS,    \
97           OPT_UINT(512, 1U << 16),                                      \
98           BCH_SB_BLOCK_SIZE,            8,                              \
99           "size",       NULL)                                           \
100         x(btree_node_size,              u32,                            \
101           OPT_FS|OPT_FORMAT|                                            \
102           OPT_HUMAN_READABLE|OPT_MUST_BE_POW_2|OPT_SB_FIELD_SECTORS,    \
103           OPT_UINT(512, 1U << 20),                                      \
104           BCH_SB_BTREE_NODE_SIZE,       512,                            \
105           "size",       "Btree node size, default 256k")                \
106         x(errors,                       u8,                             \
107           OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
108           OPT_STR(bch2_error_actions),                                  \
109           BCH_SB_ERROR_ACTION,          BCH_ON_ERROR_ro,                \
110           NULL,         "Action to take on filesystem error")           \
111         x(metadata_replicas,            u8,                             \
112           OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
113           OPT_UINT(1, BCH_REPLICAS_MAX),                                \
114           BCH_SB_META_REPLICAS_WANT,    1,                              \
115           "#",          "Number of metadata replicas")                  \
116         x(data_replicas,                u8,                             \
117           OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,            \
118           OPT_UINT(1, BCH_REPLICAS_MAX),                                \
119           BCH_SB_DATA_REPLICAS_WANT,    1,                              \
120           "#",          "Number of data replicas")                      \
121         x(metadata_replicas_required, u8,                               \
122           OPT_FS|OPT_FORMAT|OPT_MOUNT,                                  \
123           OPT_UINT(1, BCH_REPLICAS_MAX),                                \
124           BCH_SB_META_REPLICAS_REQ,     1,                              \
125           "#",          NULL)                                           \
126         x(data_replicas_required,       u8,                             \
127           OPT_FS|OPT_FORMAT|OPT_MOUNT,                                  \
128           OPT_UINT(1, BCH_REPLICAS_MAX),                                \
129           BCH_SB_DATA_REPLICAS_REQ,     1,                              \
130           "#",          NULL)                                           \
131         x(encoded_extent_max,           u32,                            \
132           OPT_FS|OPT_FORMAT|                                            \
133           OPT_HUMAN_READABLE|OPT_MUST_BE_POW_2|OPT_SB_FIELD_SECTORS|OPT_SB_FIELD_ILOG2,\
134           OPT_UINT(4096, 2U << 20),                                     \
135           BCH_SB_ENCODED_EXTENT_MAX_BITS, 64 << 10,                     \
136           "size",       "Maximum size of checksummed/compressed extents")\
137         x(metadata_checksum,            u8,                             \
138           OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
139           OPT_STR(bch2_csum_opts),                                      \
140           BCH_SB_META_CSUM_TYPE,        BCH_CSUM_OPT_crc32c,            \
141           NULL,         NULL)                                           \
142         x(data_checksum,                u8,                             \
143           OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,            \
144           OPT_STR(bch2_csum_opts),                                      \
145           BCH_SB_DATA_CSUM_TYPE,        BCH_CSUM_OPT_crc32c,            \
146           NULL,         NULL)                                           \
147         x(compression,                  u8,                             \
148           OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,            \
149           OPT_STR(bch2_compression_opts),                               \
150           BCH_SB_COMPRESSION_TYPE,      BCH_COMPRESSION_OPT_none,       \
151           NULL,         NULL)                                           \
152         x(background_compression,       u8,                             \
153           OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,            \
154           OPT_STR(bch2_compression_opts),                               \
155           BCH_SB_BACKGROUND_COMPRESSION_TYPE,BCH_COMPRESSION_OPT_none,  \
156           NULL,         NULL)                                           \
157         x(str_hash,                     u8,                             \
158           OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
159           OPT_STR(bch2_str_hash_opts),                                  \
160           BCH_SB_STR_HASH_TYPE,         BCH_STR_HASH_OPT_siphash,       \
161           NULL,         "Hash function for directory entries and xattrs")\
162         x(metadata_target,              u16,                            \
163           OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,            \
164           OPT_FN(bch2_opt_target),                                      \
165           BCH_SB_METADATA_TARGET,       0,                              \
166           "(target)",   "Device or disk group for metadata writes")     \
167         x(foreground_target,            u16,                            \
168           OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,            \
169           OPT_FN(bch2_opt_target),                                      \
170           BCH_SB_FOREGROUND_TARGET,     0,                              \
171           "(target)",   "Device or disk group for foreground writes")   \
172         x(background_target,            u16,                            \
173           OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,            \
174           OPT_FN(bch2_opt_target),                                      \
175           BCH_SB_BACKGROUND_TARGET,     0,                              \
176           "(target)",   "Device or disk group to move data to in the background")\
177         x(promote_target,               u16,                            \
178           OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,            \
179           OPT_FN(bch2_opt_target),                                      \
180           BCH_SB_PROMOTE_TARGET,        0,                              \
181           "(target)",   "Device or disk group to promote data to on read")\
182         x(erasure_code,                 u16,                            \
183           OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,            \
184           OPT_BOOL(),                                                   \
185           BCH_SB_ERASURE_CODE,          false,                          \
186           NULL,         "Enable erasure coding (DO NOT USE YET)")       \
187         x(inodes_32bit,                 u8,                             \
188           OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
189           OPT_BOOL(),                                                   \
190           BCH_SB_INODE_32BIT,           true,                           \
191           NULL,         "Constrain inode numbers to 32 bits")           \
192         x(shard_inode_numbers,          u8,                             \
193           OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
194           OPT_BOOL(),                                                   \
195           BCH_SB_SHARD_INUMS,           true,                           \
196           NULL,         "Shard new inode numbers by CPU id")            \
197         x(inodes_use_key_cache, u8,                                     \
198           OPT_FS|OPT_FORMAT|OPT_MOUNT,                                  \
199           OPT_BOOL(),                                                   \
200           BCH_SB_INODES_USE_KEY_CACHE,  true,                           \
201           NULL,         "Use the btree key cache for the inodes btree") \
202         x(btree_node_mem_ptr_optimization, u8,                          \
203           OPT_FS|OPT_MOUNT|OPT_RUNTIME,                                 \
204           OPT_BOOL(),                                                   \
205           NO_SB_OPT,                    true,                           \
206           NULL,         "Stash pointer to in memory btree node in btree ptr")\
207         x(gc_reserve_percent,           u8,                             \
208           OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
209           OPT_UINT(5, 21),                                              \
210           BCH_SB_GC_RESERVE,            8,                              \
211           "%",          "Percentage of disk space to reserve for copygc")\
212         x(gc_reserve_bytes,             u64,                            \
213           OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|                      \
214           OPT_HUMAN_READABLE|OPT_SB_FIELD_SECTORS,                      \
215           OPT_UINT(0, U64_MAX),                                         \
216           BCH_SB_GC_RESERVE_BYTES,      0,                              \
217           "%",          "Amount of disk space to reserve for copygc\n"  \
218                         "Takes precedence over gc_reserve_percent if set")\
219         x(root_reserve_percent,         u8,                             \
220           OPT_FS|OPT_FORMAT|OPT_MOUNT,                                  \
221           OPT_UINT(0, 100),                                             \
222           BCH_SB_ROOT_RESERVE,          0,                              \
223           "%",          "Percentage of disk space to reserve for superuser")\
224         x(wide_macs,                    u8,                             \
225           OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
226           OPT_BOOL(),                                                   \
227           BCH_SB_128_BIT_MACS,          false,                          \
228           NULL,         "Store full 128 bits of cryptographic MACs, instead of 80")\
229         x(inline_data,                  u8,                             \
230           OPT_FS|OPT_MOUNT|OPT_RUNTIME,                                 \
231           OPT_BOOL(),                                                   \
232           NO_SB_OPT,                    true,                           \
233           NULL,         "Enable inline data extents")                   \
234         x(acl,                          u8,                             \
235           OPT_FS|OPT_FORMAT|OPT_MOUNT,                                  \
236           OPT_BOOL(),                                                   \
237           BCH_SB_POSIX_ACL,             true,                           \
238           NULL,         "Enable POSIX acls")                            \
239         x(usrquota,                     u8,                             \
240           OPT_FS|OPT_FORMAT|OPT_MOUNT,                                  \
241           OPT_BOOL(),                                                   \
242           BCH_SB_USRQUOTA,              false,                          \
243           NULL,         "Enable user quotas")                           \
244         x(grpquota,                     u8,                             \
245           OPT_FS|OPT_FORMAT|OPT_MOUNT,                                  \
246           OPT_BOOL(),                                                   \
247           BCH_SB_GRPQUOTA,              false,                          \
248           NULL,         "Enable group quotas")                          \
249         x(prjquota,                     u8,                             \
250           OPT_FS|OPT_FORMAT|OPT_MOUNT,                                  \
251           OPT_BOOL(),                                                   \
252           BCH_SB_PRJQUOTA,              false,                          \
253           NULL,         "Enable project quotas")                        \
254         x(degraded,                     u8,                             \
255           OPT_FS|OPT_MOUNT,                                             \
256           OPT_BOOL(),                                                   \
257           NO_SB_OPT,                    false,                          \
258           NULL,         "Allow mounting in degraded mode")              \
259         x(very_degraded,                u8,                             \
260           OPT_FS|OPT_MOUNT,                                             \
261           OPT_BOOL(),                                                   \
262           NO_SB_OPT,                    false,                          \
263           NULL,         "Allow mounting in when data will be missing")  \
264         x(discard,                      u8,                             \
265           OPT_FS|OPT_MOUNT|OPT_DEVICE,                                  \
266           OPT_BOOL(),                                                   \
267           NO_SB_OPT,                    false,                          \
268           NULL,         "Enable discard/TRIM support")                  \
269         x(verbose,                      u8,                             \
270           OPT_FS|OPT_MOUNT,                                             \
271           OPT_BOOL(),                                                   \
272           NO_SB_OPT,                    false,                          \
273           NULL,         "Extra debugging information during mount/recovery")\
274         x(journal_flush_delay,          u32,                            \
275           OPT_FS|OPT_MOUNT|OPT_RUNTIME,                                 \
276           OPT_UINT(0, U32_MAX),                                         \
277           BCH_SB_JOURNAL_FLUSH_DELAY,   1000,                           \
278           NULL,         "Delay in milliseconds before automatic journal commits")\
279         x(journal_flush_disabled,       u8,                             \
280           OPT_FS|OPT_MOUNT|OPT_RUNTIME,                                 \
281           OPT_BOOL(),                                                   \
282           BCH_SB_JOURNAL_FLUSH_DISABLED,false,                          \
283           NULL,         "Disable journal flush on sync/fsync\n"         \
284                         "If enabled, writes can be lost, but only since the\n"\
285                         "last journal write (default 1 second)")        \
286         x(journal_reclaim_delay,        u32,                            \
287           OPT_FS|OPT_MOUNT|OPT_RUNTIME,                                 \
288           OPT_UINT(0, U32_MAX),                                         \
289           BCH_SB_JOURNAL_RECLAIM_DELAY, 100,                            \
290           NULL,         "Delay in milliseconds before automatic journal reclaim")\
291         x(fsck,                         u8,                             \
292           OPT_FS|OPT_MOUNT,                                             \
293           OPT_BOOL(),                                                   \
294           NO_SB_OPT,                    false,                          \
295           NULL,         "Run fsck on mount")                            \
296         x(fix_errors,                   u8,                             \
297           OPT_FS|OPT_MOUNT,                                             \
298           OPT_BOOL(),                                                   \
299           NO_SB_OPT,                    false,                          \
300           NULL,         "Fix errors during fsck without asking")        \
301         x(ratelimit_errors,             u8,                             \
302           OPT_FS|OPT_MOUNT,                                             \
303           OPT_BOOL(),                                                   \
304           NO_SB_OPT,                    RATELIMIT_ERRORS_DEFAULT,       \
305           NULL,         "Ratelimit error messages during fsck")         \
306         x(nochanges,                    u8,                             \
307           OPT_FS|OPT_MOUNT,                                             \
308           OPT_BOOL(),                                                   \
309           NO_SB_OPT,                    false,                          \
310           NULL,         "Super read only mode - no writes at all will be issued,\n"\
311                         "even if we have to replay the journal")        \
312         x(norecovery,                   u8,                             \
313           OPT_FS|OPT_MOUNT,                                             \
314           OPT_BOOL(),                                                   \
315           NO_SB_OPT,                    false,                          \
316           NULL,         "Don't replay the journal")                     \
317         x(rebuild_replicas,             u8,                             \
318           OPT_FS|OPT_MOUNT,                                             \
319           OPT_BOOL(),                                                   \
320           NO_SB_OPT,                    false,                          \
321           NULL,         "Rebuild the superblock replicas section")      \
322         x(keep_journal,                 u8,                             \
323           0,                                                            \
324           OPT_BOOL(),                                                   \
325           NO_SB_OPT,                    false,                          \
326           NULL,         "Don't free journal entries/keys after startup")\
327         x(read_entire_journal,          u8,                             \
328           0,                                                            \
329           OPT_BOOL(),                                                   \
330           NO_SB_OPT,                    false,                          \
331           NULL,         "Read all journal entries, not just dirty ones")\
332         x(journal_transaction_names,    u8,                             \
333           OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
334           OPT_BOOL(),                                                   \
335           BCH_SB_JOURNAL_TRANSACTION_NAMES, false,                      \
336           NULL,         "Log transaction function names in journal")    \
337         x(noexcl,                       u8,                             \
338           OPT_FS|OPT_MOUNT,                                             \
339           OPT_BOOL(),                                                   \
340           NO_SB_OPT,                    false,                          \
341           NULL,         "Don't open device in exclusive mode")          \
342         x(sb,                           u64,                            \
343           OPT_MOUNT,                                                    \
344           OPT_UINT(0, S64_MAX),                                         \
345           NO_SB_OPT,                    BCH_SB_SECTOR,                  \
346           "offset",     "Sector offset of superblock")                  \
347         x(read_only,                    u8,                             \
348           OPT_FS,                                                       \
349           OPT_BOOL(),                                                   \
350           NO_SB_OPT,                    false,                          \
351           NULL,         NULL)                                           \
352         x(nostart,                      u8,                             \
353           0,                                                            \
354           OPT_BOOL(),                                                   \
355           NO_SB_OPT,                    false,                          \
356           NULL,         "Don\'t start filesystem, only open devices")   \
357         x(reconstruct_alloc,            u8,                             \
358           OPT_FS|OPT_MOUNT,                                             \
359           OPT_BOOL(),                                                   \
360           NO_SB_OPT,                    false,                          \
361           NULL,         "Reconstruct alloc btree")                      \
362         x(version_upgrade,              u8,                             \
363           OPT_FS|OPT_MOUNT,                                             \
364           OPT_BOOL(),                                                   \
365           NO_SB_OPT,                    false,                          \
366           NULL,         "Set superblock to latest version,\n"           \
367                         "allowing any new features to be used")         \
368         x(project,                      u8,                             \
369           OPT_INODE,                                                    \
370           OPT_BOOL(),                                                   \
371           NO_SB_OPT,                    false,                          \
372           NULL,         NULL)                                           \
373         x(fs_size,                      u64,                            \
374           OPT_DEVICE,                                                   \
375           OPT_UINT(0, S64_MAX),                                         \
376           NO_SB_OPT,                    0,                              \
377           "size",       "Size of filesystem on device")                 \
378         x(bucket,                       u32,                            \
379           OPT_DEVICE,                                                   \
380           OPT_UINT(0, S64_MAX),                                         \
381           NO_SB_OPT,                    0,                              \
382           "size",       "Size of filesystem on device")                 \
383         x(durability,                   u8,                             \
384           OPT_DEVICE,                                                   \
385           OPT_UINT(0, BCH_REPLICAS_MAX),                                \
386           NO_SB_OPT,                    1,                              \
387           "n",          "Data written to this device will be considered\n"\
388                         "to have already been replicated n times")
389
390 struct bch_opts {
391 #define x(_name, _bits, ...)    unsigned _name##_defined:1;
392         BCH_OPTS()
393 #undef x
394
395 #define x(_name, _bits, ...)    _bits   _name;
396         BCH_OPTS()
397 #undef x
398 };
399
400 static const struct bch_opts bch2_opts_default = {
401 #define x(_name, _bits, _mode, _type, _sb_opt, _default, ...)           \
402         ._name##_defined = true,                                        \
403         ._name = _default,                                              \
404
405         BCH_OPTS()
406 #undef x
407 };
408
409 #define opt_defined(_opts, _name)       ((_opts)._name##_defined)
410
411 #define opt_get(_opts, _name)                                           \
412         (opt_defined(_opts, _name) ? (_opts)._name : bch2_opts_default._name)
413
414 #define opt_set(_opts, _name, _v)                                       \
415 do {                                                                    \
416         (_opts)._name##_defined = true;                                 \
417         (_opts)._name = _v;                                             \
418 } while (0)
419
420 static inline struct bch_opts bch2_opts_empty(void)
421 {
422         return (struct bch_opts) { 0 };
423 }
424
425 void bch2_opts_apply(struct bch_opts *, struct bch_opts);
426
427 enum bch_opt_id {
428 #define x(_name, ...)   Opt_##_name,
429         BCH_OPTS()
430 #undef x
431         bch2_opts_nr
432 };
433
434 struct bch_fs;
435 struct printbuf;
436
437 struct bch_option {
438         struct attribute        attr;
439         u64                     (*get_sb)(const struct bch_sb *);
440         void                    (*set_sb)(struct bch_sb *, u64);
441         enum opt_type           type;
442         enum opt_flags          flags;
443         u64                     min, max;
444
445         union {
446         struct {
447         };
448         struct {
449                 const char * const *choices;
450         };
451         struct {
452                 int (*parse)(struct bch_fs *, const char *, u64 *);
453                 void (*to_text)(struct printbuf *, struct bch_fs *, u64);
454         };
455         };
456
457         const char              *hint;
458         const char              *help;
459
460 };
461
462 extern const struct bch_option bch2_opt_table[];
463
464 bool bch2_opt_defined_by_id(const struct bch_opts *, enum bch_opt_id);
465 u64 bch2_opt_get_by_id(const struct bch_opts *, enum bch_opt_id);
466 void bch2_opt_set_by_id(struct bch_opts *, enum bch_opt_id, u64);
467
468 int bch2_opts_from_sb(struct bch_opts *, struct bch_sb *);
469 void __bch2_opt_set_sb(struct bch_sb *, const struct bch_option *, u64);
470 void bch2_opt_set_sb(struct bch_fs *, const struct bch_option *, u64);
471
472 int bch2_opt_lookup(const char *);
473 int bch2_opt_parse(struct bch_fs *, const char *, const struct bch_option *,
474                    const char *, u64 *);
475
476 #define OPT_SHOW_FULL_LIST      (1 << 0)
477 #define OPT_SHOW_MOUNT_STYLE    (1 << 1)
478
479 void bch2_opt_to_text(struct printbuf *, struct bch_fs *,
480                       const struct bch_option *, u64, unsigned);
481
482 int bch2_opt_check_may_set(struct bch_fs *, int, u64);
483 int bch2_opts_check_may_set(struct bch_fs *);
484 int bch2_parse_mount_opts(struct bch_fs *, struct bch_opts *, char *);
485
486 /* inode opts: */
487
488 struct bch_io_opts {
489 #define x(_name, _bits) unsigned _name##_defined:1;
490         BCH_INODE_OPTS()
491 #undef x
492
493 #define x(_name, _bits) u##_bits _name;
494         BCH_INODE_OPTS()
495 #undef x
496 };
497
498 struct bch_io_opts bch2_opts_to_inode_opts(struct bch_opts);
499 struct bch_opts bch2_inode_opts_to_opts(struct bch_io_opts);
500 void bch2_io_opts_apply(struct bch_io_opts *, struct bch_io_opts);
501 bool bch2_opt_is_inode_opt(enum bch_opt_id);
502
503 #endif /* _BCACHEFS_OPTS_H */