2017-03-16 22:18:50 -08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _BCACHEFS_OPTS_H
|
|
|
|
#define _BCACHEFS_OPTS_H
|
|
|
|
|
|
|
|
#include <linux/bug.h>
|
|
|
|
#include <linux/log2.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/sysfs.h>
|
|
|
|
#include "bcachefs_format.h"
|
|
|
|
|
2023-07-12 21:48:32 -04:00
|
|
|
struct bch_fs;
|
|
|
|
|
2017-03-16 22:18:50 -08:00
|
|
|
extern const char * const bch2_error_actions[];
|
2025-04-06 13:50:20 -04:00
|
|
|
extern const char * const bch2_degraded_actions[];
|
2023-07-11 23:47:29 -04:00
|
|
|
extern const char * const bch2_fsck_fix_opts[];
|
2023-06-27 23:34:02 -04:00
|
|
|
extern const char * const bch2_version_upgrade_opts[];
|
2019-12-28 20:17:06 -05:00
|
|
|
extern const char * const bch2_sb_features[];
|
2021-04-04 21:57:35 -04:00
|
|
|
extern const char * const bch2_sb_compat[];
|
2023-10-19 22:49:08 -04:00
|
|
|
extern const char * const __bch2_btree_ids[];
|
2025-03-24 16:40:22 -04:00
|
|
|
extern const char * const __bch2_csum_types[];
|
2024-10-28 01:14:53 -04:00
|
|
|
extern const char * const __bch2_csum_opts[];
|
2024-11-14 23:03:40 -05:00
|
|
|
extern const char * const __bch2_compression_types[];
|
2019-12-28 20:17:06 -05:00
|
|
|
extern const char * const bch2_compression_opts[];
|
2024-09-28 14:44:06 -04:00
|
|
|
extern const char * const __bch2_str_hash_types[];
|
2021-11-11 12:11:33 -05:00
|
|
|
extern const char * const bch2_str_hash_opts[];
|
2024-01-06 20:57:43 -05:00
|
|
|
extern const char * const __bch2_data_types[];
|
2021-02-20 19:47:58 -05:00
|
|
|
extern const char * const bch2_member_states[];
|
2021-07-05 22:18:07 -04:00
|
|
|
extern const char * const bch2_d_types[];
|
2017-03-16 22:18:50 -08:00
|
|
|
|
2024-04-12 15:17:00 -04:00
|
|
|
void bch2_prt_jset_entry_type(struct printbuf *, enum bch_jset_entry_type);
|
|
|
|
void bch2_prt_fs_usage_type(struct printbuf *, enum bch_fs_usage_type);
|
|
|
|
void bch2_prt_data_type(struct printbuf *, enum bch_data_type);
|
2024-10-28 01:14:53 -04:00
|
|
|
void bch2_prt_csum_opt(struct printbuf *, enum bch_csum_opt);
|
2024-04-12 15:17:00 -04:00
|
|
|
void bch2_prt_csum_type(struct printbuf *, enum bch_csum_type);
|
|
|
|
void bch2_prt_compression_type(struct printbuf *, enum bch_compression_type);
|
2024-09-28 14:44:06 -04:00
|
|
|
void bch2_prt_str_hash_type(struct printbuf *, enum bch_str_hash_type);
|
2024-04-12 15:17:00 -04:00
|
|
|
|
2021-10-28 16:16:55 -04:00
|
|
|
static inline const char *bch2_d_type_str(unsigned d_type)
|
|
|
|
{
|
|
|
|
return (d_type < BCH_DT_MAX ? bch2_d_types[d_type] : NULL) ?: "(bad d_type)";
|
|
|
|
}
|
|
|
|
|
2017-03-16 22:18:50 -08:00
|
|
|
/*
|
|
|
|
* Mount options; we also store defaults in the superblock.
|
|
|
|
*
|
|
|
|
* Also exposed via sysfs: if an option is writeable, and it's also stored in
|
|
|
|
* the superblock, changing it via sysfs (currently? might change this) also
|
|
|
|
* updates the superblock.
|
|
|
|
*
|
|
|
|
* We store options as signed integers, where -1 means undefined. This means we
|
|
|
|
* can pass the mount options to bch2_fs_alloc() as a whole struct, and then only
|
|
|
|
* apply the options from that struct that are defined.
|
|
|
|
*/
|
|
|
|
|
2018-12-19 12:58:56 -05:00
|
|
|
/* When can be set: */
|
2021-12-14 14:24:41 -05:00
|
|
|
enum opt_flags {
|
2024-07-15 19:54:51 -04:00
|
|
|
OPT_FS = BIT(0), /* Filesystem option */
|
|
|
|
OPT_DEVICE = BIT(1), /* Device option */
|
|
|
|
OPT_INODE = BIT(2), /* Inode option */
|
|
|
|
OPT_FORMAT = BIT(3), /* May be specified at format time */
|
|
|
|
OPT_MOUNT = BIT(4), /* May be specified at mount time */
|
|
|
|
OPT_RUNTIME = BIT(5), /* May be specified at runtime */
|
|
|
|
OPT_HUMAN_READABLE = BIT(6),
|
|
|
|
OPT_MUST_BE_POW_2 = BIT(7), /* Must be power of 2 */
|
|
|
|
OPT_SB_FIELD_SECTORS = BIT(8), /* Superblock field is >> 9 of actual value */
|
|
|
|
OPT_SB_FIELD_ILOG2 = BIT(9), /* Superblock field is ilog2 of actual value */
|
|
|
|
OPT_SB_FIELD_ONE_BIAS = BIT(10), /* 0 means default value */
|
|
|
|
OPT_HIDDEN = BIT(11),
|
2017-03-16 22:18:50 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum opt_type {
|
|
|
|
BCH_OPT_BOOL,
|
|
|
|
BCH_OPT_UINT,
|
|
|
|
BCH_OPT_STR,
|
2024-07-15 16:53:49 -04:00
|
|
|
BCH_OPT_BITFIELD,
|
2017-03-16 22:18:50 -08:00
|
|
|
BCH_OPT_FN,
|
|
|
|
};
|
|
|
|
|
2023-07-12 21:48:32 -04:00
|
|
|
struct bch_opt_fn {
|
|
|
|
int (*parse)(struct bch_fs *, const char *, u64 *, struct printbuf *);
|
|
|
|
void (*to_text)(struct printbuf *, struct bch_fs *, struct bch_sb *, u64);
|
2023-10-22 18:29:54 -04:00
|
|
|
int (*validate)(u64, struct printbuf *);
|
2023-07-12 21:48:32 -04:00
|
|
|
};
|
|
|
|
|
2017-03-16 22:18:50 -08:00
|
|
|
/**
|
2018-12-19 12:58:56 -05:00
|
|
|
* x(name, shortopt, type, in mem type, mode, sb_opt)
|
2017-03-16 22:18:50 -08:00
|
|
|
*
|
|
|
|
* @name - name of mount option, sysfs attribute, and struct bch_opts
|
|
|
|
* member
|
|
|
|
*
|
|
|
|
* @mode - when opt may be set
|
|
|
|
*
|
|
|
|
* @sb_option - name of corresponding superblock option
|
|
|
|
*
|
|
|
|
* @type - one of OPT_BOOL, OPT_UINT, OPT_STR
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: add fields for
|
|
|
|
* - default value
|
|
|
|
* - helptext
|
|
|
|
*/
|
|
|
|
|
2019-11-06 15:32:11 -05:00
|
|
|
#ifdef __KERNEL__
|
2021-12-10 15:41:38 -05:00
|
|
|
#define RATELIMIT_ERRORS_DEFAULT true
|
2019-11-06 15:32:11 -05:00
|
|
|
#else
|
2021-12-10 15:41:38 -05:00
|
|
|
#define RATELIMIT_ERRORS_DEFAULT false
|
2019-11-06 15:32:11 -05:00
|
|
|
#endif
|
|
|
|
|
2023-03-07 07:25:12 -05:00
|
|
|
#ifdef CONFIG_BCACHEFS_DEBUG
|
|
|
|
#define BCACHEFS_VERBOSE_DEFAULT true
|
|
|
|
#else
|
|
|
|
#define BCACHEFS_VERBOSE_DEFAULT false
|
|
|
|
#endif
|
|
|
|
|
2023-07-11 23:47:29 -04:00
|
|
|
#define BCH_FIX_ERRORS_OPTS() \
|
|
|
|
x(exit, 0) \
|
|
|
|
x(yes, 1) \
|
|
|
|
x(no, 2) \
|
|
|
|
x(ask, 3)
|
|
|
|
|
|
|
|
enum fsck_err_opts {
|
|
|
|
#define x(t, n) FSCK_FIX_##t,
|
|
|
|
BCH_FIX_ERRORS_OPTS()
|
|
|
|
#undef x
|
|
|
|
};
|
|
|
|
|
2017-03-16 22:18:50 -08:00
|
|
|
#define BCH_OPTS() \
|
2018-12-19 12:58:56 -05:00
|
|
|
x(block_size, u16, \
|
2021-12-14 14:24:41 -05:00
|
|
|
OPT_FS|OPT_FORMAT| \
|
|
|
|
OPT_HUMAN_READABLE|OPT_MUST_BE_POW_2|OPT_SB_FIELD_SECTORS, \
|
|
|
|
OPT_UINT(512, 1U << 16), \
|
2025-03-19 12:33:40 -04:00
|
|
|
BCH_SB_BLOCK_SIZE, 4 << 10, \
|
2018-12-19 12:58:56 -05:00
|
|
|
"size", NULL) \
|
2021-12-14 14:24:41 -05:00
|
|
|
x(btree_node_size, u32, \
|
|
|
|
OPT_FS|OPT_FORMAT| \
|
|
|
|
OPT_HUMAN_READABLE|OPT_MUST_BE_POW_2|OPT_SB_FIELD_SECTORS, \
|
|
|
|
OPT_UINT(512, 1U << 20), \
|
2025-03-19 12:33:40 -04:00
|
|
|
BCH_SB_BTREE_NODE_SIZE, 256 << 10, \
|
2018-12-19 12:58:56 -05:00
|
|
|
"size", "Btree node size, default 256k") \
|
|
|
|
x(errors, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_STR(bch2_error_actions), \
|
2024-06-19 09:55:48 -04:00
|
|
|
BCH_SB_ERROR_ACTION, BCH_ON_ERROR_fix_safe, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Action to take on filesystem error") \
|
2025-02-26 18:44:23 -05:00
|
|
|
x(write_error_timeout, u16, \
|
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
|
|
|
OPT_UINT(1, 300), \
|
|
|
|
BCH_SB_WRITE_ERROR_TIMEOUT, 30, \
|
|
|
|
NULL, "Number of consecutive write errors allowed before kicking out a device")\
|
2018-12-19 12:58:56 -05:00
|
|
|
x(metadata_replicas, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
|
|
|
BCH_SB_META_REPLICAS_WANT, 1, \
|
|
|
|
"#", "Number of metadata replicas") \
|
|
|
|
x(data_replicas, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
|
|
|
BCH_SB_DATA_REPLICAS_WANT, 1, \
|
|
|
|
"#", "Number of data replicas") \
|
|
|
|
x(metadata_replicas_required, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
|
|
|
BCH_SB_META_REPLICAS_REQ, 1, \
|
|
|
|
"#", NULL) \
|
|
|
|
x(data_replicas_required, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_UINT(1, BCH_REPLICAS_MAX), \
|
|
|
|
BCH_SB_DATA_REPLICAS_REQ, 1, \
|
|
|
|
"#", NULL) \
|
2021-12-14 14:34:03 -05:00
|
|
|
x(encoded_extent_max, u32, \
|
|
|
|
OPT_FS|OPT_FORMAT| \
|
|
|
|
OPT_HUMAN_READABLE|OPT_MUST_BE_POW_2|OPT_SB_FIELD_SECTORS|OPT_SB_FIELD_ILOG2,\
|
|
|
|
OPT_UINT(4096, 2U << 20), \
|
|
|
|
BCH_SB_ENCODED_EXTENT_MAX_BITS, 64 << 10, \
|
|
|
|
"size", "Maximum size of checksummed/compressed extents")\
|
2018-12-19 12:58:56 -05:00
|
|
|
x(metadata_checksum, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2024-10-28 01:14:53 -04:00
|
|
|
OPT_STR(__bch2_csum_opts), \
|
2021-02-20 19:47:58 -05:00
|
|
|
BCH_SB_META_CSUM_TYPE, BCH_CSUM_OPT_crc32c, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, NULL) \
|
|
|
|
x(data_checksum, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2024-10-28 01:14:53 -04:00
|
|
|
OPT_STR(__bch2_csum_opts), \
|
2021-02-20 19:47:58 -05:00
|
|
|
BCH_SB_DATA_CSUM_TYPE, BCH_CSUM_OPT_crc32c, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, NULL) \
|
2025-03-08 12:56:43 -05:00
|
|
|
x(checksum_err_retry_nr, u8, \
|
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
|
|
|
OPT_UINT(0, 32), \
|
|
|
|
BCH_SB_CSUM_ERR_RETRY_NR, 3, \
|
|
|
|
NULL, NULL) \
|
2018-12-19 12:58:56 -05:00
|
|
|
x(compression, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2023-07-12 22:27:16 -04:00
|
|
|
OPT_FN(bch2_opt_compression), \
|
2019-12-28 20:17:06 -05:00
|
|
|
BCH_SB_COMPRESSION_TYPE, BCH_COMPRESSION_OPT_none, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, NULL) \
|
|
|
|
x(background_compression, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2023-07-12 22:27:16 -04:00
|
|
|
OPT_FN(bch2_opt_compression), \
|
2019-12-28 20:17:06 -05:00
|
|
|
BCH_SB_BACKGROUND_COMPRESSION_TYPE,BCH_COMPRESSION_OPT_none, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, NULL) \
|
|
|
|
x(str_hash, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2021-11-11 12:11:33 -05:00
|
|
|
OPT_STR(bch2_str_hash_opts), \
|
2021-02-20 19:47:58 -05:00
|
|
|
BCH_SB_STR_HASH_TYPE, BCH_STR_HASH_OPT_siphash, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Hash function for directory entries and xattrs")\
|
2021-01-29 15:37:28 -05:00
|
|
|
x(metadata_target, u16, \
|
2025-02-10 11:55:33 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2021-01-29 15:37:28 -05:00
|
|
|
OPT_FN(bch2_opt_target), \
|
|
|
|
BCH_SB_METADATA_TARGET, 0, \
|
2022-05-25 14:57:39 +12:00
|
|
|
"(target)", "Device or label for metadata writes") \
|
2018-12-19 12:58:56 -05:00
|
|
|
x(foreground_target, u16, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_FN(bch2_opt_target), \
|
|
|
|
BCH_SB_FOREGROUND_TARGET, 0, \
|
2022-05-25 14:57:39 +12:00
|
|
|
"(target)", "Device or label for foreground writes") \
|
2018-12-19 12:58:56 -05:00
|
|
|
x(background_target, u16, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_FN(bch2_opt_target), \
|
|
|
|
BCH_SB_BACKGROUND_TARGET, 0, \
|
2022-05-25 14:57:39 +12:00
|
|
|
"(target)", "Device or label to move data to in the background")\
|
2018-12-19 12:58:56 -05:00
|
|
|
x(promote_target, u16, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_FN(bch2_opt_target), \
|
|
|
|
BCH_SB_PROMOTE_TARGET, 0, \
|
2022-05-25 14:57:39 +12:00
|
|
|
"(target)", "Device or label to promote data to on read") \
|
2018-12-19 12:58:56 -05:00
|
|
|
x(erasure_code, u16, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH_SB_ERASURE_CODE, false, \
|
|
|
|
NULL, "Enable erasure coding (DO NOT USE YET)") \
|
2025-04-20 12:15:15 -04:00
|
|
|
x(casefold, u8, \
|
|
|
|
OPT_FS|OPT_INODE|OPT_FORMAT, \
|
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH_SB_CASEFOLD, false, \
|
|
|
|
NULL, "Dirent lookups are casefolded") \
|
2025-06-26 09:46:35 -04:00
|
|
|
x(casefold_disabled, u8, \
|
|
|
|
OPT_FS|OPT_MOUNT, \
|
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH2_NO_SB_OPT, false, \
|
|
|
|
NULL, "Disable casefolding filesystem wide") \
|
2018-12-19 12:58:56 -05:00
|
|
|
x(inodes_32bit, u8, \
|
2024-12-01 21:44:38 -05:00
|
|
|
OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
2021-05-27 20:20:20 -04:00
|
|
|
BCH_SB_INODE_32BIT, true, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Constrain inode numbers to 32 bits") \
|
2024-12-01 21:44:38 -05:00
|
|
|
x(shard_inode_numbers_bits, u8, \
|
|
|
|
OPT_FS|OPT_FORMAT, \
|
|
|
|
OPT_UINT(0, 8), \
|
|
|
|
BCH_SB_SHARD_INUMS_NBITS, 0, \
|
2021-05-27 20:20:20 -04:00
|
|
|
NULL, "Shard new inode numbers by CPU id") \
|
2021-06-13 17:07:18 -04:00
|
|
|
x(inodes_use_key_cache, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT, \
|
2021-06-13 17:07:18 -04:00
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH_SB_INODES_USE_KEY_CACHE, true, \
|
|
|
|
NULL, "Use the btree key cache for the inodes btree") \
|
2021-07-26 15:52:41 -04:00
|
|
|
x(btree_node_mem_ptr_optimization, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
2021-07-26 15:52:41 -04:00
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, true, \
|
2021-07-26 15:52:41 -04:00
|
|
|
NULL, "Stash pointer to in memory btree node in btree ptr")\
|
2018-12-19 12:58:56 -05:00
|
|
|
x(gc_reserve_percent, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_UINT(5, 21), \
|
|
|
|
BCH_SB_GC_RESERVE, 8, \
|
|
|
|
"%", "Percentage of disk space to reserve for copygc")\
|
|
|
|
x(gc_reserve_bytes, u64, \
|
2021-12-14 14:24:41 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME| \
|
|
|
|
OPT_HUMAN_READABLE|OPT_SB_FIELD_SECTORS, \
|
|
|
|
OPT_UINT(0, U64_MAX), \
|
2018-12-19 12:58:56 -05:00
|
|
|
BCH_SB_GC_RESERVE_BYTES, 0, \
|
|
|
|
"%", "Amount of disk space to reserve for copygc\n" \
|
|
|
|
"Takes precedence over gc_reserve_percent if set")\
|
|
|
|
x(root_reserve_percent, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_UINT(0, 100), \
|
|
|
|
BCH_SB_ROOT_RESERVE, 0, \
|
|
|
|
"%", "Percentage of disk space to reserve for superuser")\
|
|
|
|
x(wide_macs, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH_SB_128_BIT_MACS, false, \
|
|
|
|
NULL, "Store full 128 bits of cryptographic MACs, instead of 80")\
|
2019-11-29 13:48:09 -05:00
|
|
|
x(inline_data, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
2019-11-29 13:48:09 -05:00
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, true, \
|
2019-11-29 13:48:09 -05:00
|
|
|
NULL, "Enable inline data extents") \
|
2024-07-31 23:56:04 -04:00
|
|
|
x(promote_whole_extents, u8, \
|
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH_SB_PROMOTE_WHOLE_EXTENTS, true, \
|
|
|
|
NULL, "Promote whole extents, instead of just part being read")\
|
2018-12-19 12:58:56 -05:00
|
|
|
x(acl, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH_SB_POSIX_ACL, true, \
|
|
|
|
NULL, "Enable POSIX acls") \
|
|
|
|
x(usrquota, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
2021-10-27 13:05:56 -04:00
|
|
|
BCH_SB_USRQUOTA, false, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Enable user quotas") \
|
|
|
|
x(grpquota, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
2021-10-27 13:05:56 -04:00
|
|
|
BCH_SB_GRPQUOTA, false, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Enable group quotas") \
|
|
|
|
x(prjquota, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
2021-10-27 13:05:56 -04:00
|
|
|
BCH_SB_PRJQUOTA, false, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Enable project quotas") \
|
|
|
|
x(degraded, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT, \
|
2025-04-06 13:50:20 -04:00
|
|
|
OPT_STR(bch2_degraded_actions), \
|
|
|
|
BCH_SB_DEGRADED_ACTION, BCH_DEGRADED_ask, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Allow mounting in degraded mode") \
|
2024-03-08 16:03:19 -05:00
|
|
|
x(no_splitbrain_check, u8, \
|
|
|
|
OPT_FS|OPT_MOUNT, \
|
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH2_NO_SB_OPT, false, \
|
|
|
|
NULL, "Don't kick drives out when splitbrain detected")\
|
2018-12-19 12:58:56 -05:00
|
|
|
x(verbose, u8, \
|
2022-06-22 17:56:25 -04:00
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
2023-03-07 07:25:12 -05:00
|
|
|
BCH2_NO_SB_OPT, BCACHEFS_VERBOSE_DEFAULT, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Extra debugging information during mount/recovery")\
|
2021-12-04 20:07:19 -05:00
|
|
|
x(journal_flush_delay, u32, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
2022-03-21 00:27:10 -04:00
|
|
|
OPT_UINT(1, U32_MAX), \
|
2021-12-04 20:07:19 -05:00
|
|
|
BCH_SB_JOURNAL_FLUSH_DELAY, 1000, \
|
|
|
|
NULL, "Delay in milliseconds before automatic journal commits")\
|
2018-12-19 12:58:56 -05:00
|
|
|
x(journal_flush_disabled, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
2021-12-04 20:07:19 -05:00
|
|
|
BCH_SB_JOURNAL_FLUSH_DISABLED,false, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Disable journal flush on sync/fsync\n" \
|
|
|
|
"If enabled, writes can be lost, but only since the\n"\
|
|
|
|
"last journal write (default 1 second)") \
|
2021-12-04 20:07:19 -05:00
|
|
|
x(journal_reclaim_delay, u32, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
2021-12-04 20:07:19 -05:00
|
|
|
OPT_UINT(0, U32_MAX), \
|
|
|
|
BCH_SB_JOURNAL_RECLAIM_DELAY, 100, \
|
|
|
|
NULL, "Delay in milliseconds before automatic journal reclaim")\
|
2022-06-19 23:03:07 -04:00
|
|
|
x(move_bytes_in_flight, u32, \
|
|
|
|
OPT_HUMAN_READABLE|OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
|
|
|
OPT_UINT(1024, U32_MAX), \
|
|
|
|
BCH2_NO_SB_OPT, 1U << 20, \
|
2023-01-09 01:45:18 -05:00
|
|
|
NULL, "Maximum Amount of IO to keep in flight by the move path")\
|
|
|
|
x(move_ios_in_flight, u32, \
|
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
|
|
|
OPT_UINT(1, 1024), \
|
|
|
|
BCH2_NO_SB_OPT, 32, \
|
|
|
|
NULL, "Maximum number of IOs to keep in flight by the move path")\
|
2018-12-19 12:58:56 -05:00
|
|
|
x(fsck, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, false, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Run fsck on mount") \
|
2024-01-23 00:01:07 -05:00
|
|
|
x(fsck_memory_usage_percent, u8, \
|
|
|
|
OPT_FS|OPT_MOUNT, \
|
|
|
|
OPT_UINT(20, 70), \
|
|
|
|
BCH2_NO_SB_OPT, 50, \
|
|
|
|
NULL, "Maximum percentage of system ram fsck is allowed to pin")\
|
2018-12-19 12:58:56 -05:00
|
|
|
x(fix_errors, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT, \
|
2023-07-11 23:47:29 -04:00
|
|
|
OPT_FN(bch2_opt_fix_errors), \
|
|
|
|
BCH2_NO_SB_OPT, FSCK_FIX_exit, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Fix errors during fsck without asking") \
|
2019-11-06 15:32:11 -05:00
|
|
|
x(ratelimit_errors, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT, \
|
2019-11-06 15:32:11 -05:00
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, RATELIMIT_ERRORS_DEFAULT, \
|
2019-11-06 15:32:11 -05:00
|
|
|
NULL, "Ratelimit error messages during fsck") \
|
2018-12-19 12:58:56 -05:00
|
|
|
x(nochanges, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, false, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Super read only mode - no writes at all will be issued,\n"\
|
|
|
|
"even if we have to replay the journal") \
|
|
|
|
x(norecovery, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, false, \
|
2024-03-28 21:34:14 -04:00
|
|
|
NULL, "Exit recovery immediately prior to journal replay")\
|
bcachefs: opts.journal_rewind
Add a mount option for rewinding the journal, bringing the entire
filesystem to where it was at a previous point in time.
This is for extreme disaster recovery scenarios - it's not intended as
an undelete operation.
The option takes a journal sequence number; the desired sequence number
can be determined with 'bcachefs list_journal'
Caveats:
- The 'journal_transaction_names' option must have been enabled (it's on
by default). The option controls emitting of extra debug info in the
journal, so we can see what individual transactions were doing;
It also enables journalling of keys being overwritten, which is what
we rely on here.
- A full fsck run will be automatically triggered since alloc info will
be inconsistent. Only leaf node updates to non-alloc btrees are
rewound, since rewinding interior btree updates isn't possible or
desirable.
- We can't do anything about data that was deleted and overwritten.
Lots of metadata updates after the point in time we're rewinding to
shouldn't cause a problem, since we segragate data and metadata
allocations (this is in order to make repair by btree node scan
practical on larger filesystems; there's a small 64-bit per device
bitmap in the superblock of device ranges with btree nodes, and we try
to keep this small).
However, having discards enabled will cause problems, since buckets
are discarded as soon as they become empty (this is why we don't
implement fstrim: we don't need it).
Hopefully, this feature will be a one-off thing that's never used
again: this was implemented for recovering from the "vfs i_nlink 0 ->
subvol deletion" bug, and that bug was unusually disastrous and
additional safeguards have since been implemented.
But if it does turn out that we need this more in the future, I'll
have to implement an option so that empty buckets aren't discarded
immediately - lagging by perhaps 1% of device capacity.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-07 19:16:12 -04:00
|
|
|
x(journal_rewind, u64, \
|
|
|
|
OPT_FS|OPT_MOUNT, \
|
|
|
|
OPT_UINT(0, U64_MAX), \
|
|
|
|
BCH2_NO_SB_OPT, 0, \
|
|
|
|
NULL, "Rewind journal") \
|
2024-09-01 22:39:42 -04:00
|
|
|
x(recovery_passes, u64, \
|
|
|
|
OPT_FS|OPT_MOUNT, \
|
|
|
|
OPT_BITFIELD(bch2_recovery_passes), \
|
|
|
|
BCH2_NO_SB_OPT, 0, \
|
|
|
|
NULL, "Recovery passes to run explicitly") \
|
|
|
|
x(recovery_passes_exclude, u64, \
|
|
|
|
OPT_FS|OPT_MOUNT, \
|
|
|
|
OPT_BITFIELD(bch2_recovery_passes), \
|
|
|
|
BCH2_NO_SB_OPT, 0, \
|
|
|
|
NULL, "Recovery passes to exclude") \
|
2024-03-28 21:34:14 -04:00
|
|
|
x(recovery_pass_last, u8, \
|
|
|
|
OPT_FS|OPT_MOUNT, \
|
|
|
|
OPT_STR_NOLIMIT(bch2_recovery_passes), \
|
|
|
|
BCH2_NO_SB_OPT, 0, \
|
|
|
|
NULL, "Exit recovery after specified pass") \
|
2024-03-11 23:11:46 -04:00
|
|
|
x(retain_recovery_info, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
0, \
|
2020-03-25 16:12:33 -04:00
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, false, \
|
2024-03-11 23:11:46 -04:00
|
|
|
NULL, "Don't free journal entries/keys, scanned btree nodes after startup")\
|
2020-06-13 18:43:14 -04:00
|
|
|
x(read_entire_journal, u8, \
|
|
|
|
0, \
|
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, false, \
|
2020-06-13 18:43:14 -04:00
|
|
|
NULL, "Read all journal entries, not just dirty ones")\
|
2022-02-19 05:15:53 -05:00
|
|
|
x(read_journal_only, u8, \
|
|
|
|
0, \
|
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, false, \
|
2022-02-19 05:15:53 -05:00
|
|
|
NULL, "Only read the journal, skip the rest of recovery")\
|
2021-12-31 16:12:54 -05:00
|
|
|
x(journal_transaction_names, u8, \
|
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH_SB_JOURNAL_TRANSACTION_NAMES, true, \
|
|
|
|
NULL, "Log transaction function names in journal") \
|
2024-08-07 13:58:57 -04:00
|
|
|
x(allocator_stuck_timeout, u16, \
|
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
|
|
|
OPT_UINT(0, U16_MAX), \
|
|
|
|
BCH_SB_ALLOCATOR_STUCK_TIMEOUT, 30, \
|
|
|
|
NULL, "Default timeout in seconds for stuck allocator messages")\
|
2018-12-19 12:58:56 -05:00
|
|
|
x(noexcl, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, false, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Don't open device in exclusive mode") \
|
2022-07-21 15:41:29 -04:00
|
|
|
x(direct_io, u8, \
|
|
|
|
OPT_FS|OPT_MOUNT, \
|
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH2_NO_SB_OPT, true, \
|
|
|
|
NULL, "Use O_DIRECT (userspace only)") \
|
2018-12-19 12:58:56 -05:00
|
|
|
x(sb, u64, \
|
|
|
|
OPT_MOUNT, \
|
|
|
|
OPT_UINT(0, S64_MAX), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, BCH_SB_SECTOR, \
|
2018-12-19 12:58:56 -05:00
|
|
|
"offset", "Sector offset of superblock") \
|
|
|
|
x(read_only, u8, \
|
2024-06-28 18:10:47 -04:00
|
|
|
OPT_FS|OPT_MOUNT|OPT_HIDDEN, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, false, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, NULL) \
|
|
|
|
x(nostart, u8, \
|
|
|
|
0, \
|
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, false, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Don\'t start filesystem, only open devices") \
|
2019-08-28 13:20:31 -04:00
|
|
|
x(reconstruct_alloc, u8, \
|
2021-12-04 21:53:13 -05:00
|
|
|
OPT_FS|OPT_MOUNT, \
|
2019-08-28 13:20:31 -04:00
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, false, \
|
2019-08-28 13:20:31 -04:00
|
|
|
NULL, "Reconstruct alloc btree") \
|
2018-12-19 12:58:56 -05:00
|
|
|
x(version_upgrade, u8, \
|
2025-04-15 10:20:46 -04:00
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
2023-06-27 23:34:02 -04:00
|
|
|
OPT_STR(bch2_version_upgrade_opts), \
|
|
|
|
BCH_SB_VERSION_UPGRADE, BCH_VERSION_UPGRADE_compatible, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Set superblock to latest version,\n" \
|
|
|
|
"allowing any new features to be used") \
|
2023-12-31 10:04:54 -05:00
|
|
|
x(stdio, u64, \
|
2023-12-04 20:15:23 -05:00
|
|
|
0, \
|
|
|
|
OPT_UINT(0, S64_MAX), \
|
|
|
|
BCH2_NO_SB_OPT, false, \
|
2023-12-31 10:04:54 -05:00
|
|
|
NULL, "Pointer to a struct stdio_redirect") \
|
2018-12-19 12:58:56 -05:00
|
|
|
x(project, u8, \
|
|
|
|
OPT_INODE, \
|
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, false, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, NULL) \
|
bcachefs: Nocow support
This adds support for nocow mode, where we do writes in-place when
possible. Patch components:
- New boolean filesystem and inode option, nocow: note that when nocow
is enabled, data checksumming and compression are implicitly disabled
- To prevent in-place writes from racing with data moves
(data_update.c) or bucket reuse (i.e. a bucket being reused and
re-allocated while a nocow write is in flight, we have a new locking
mechanism.
Buckets can be locked for either data update or data move, using a
fixed size hash table of two_state_shared locks. We don't have any
chaining, meaning updates and moves to different buckets that hash to
the same lock will wait unnecessarily - we'll want to watch for this
becoming an issue.
- The allocator path also needs to check for in-place writes in flight
to a given bucket before giving it out: thus we add another counter
to bucket_alloc_state so we can track this.
- Fsync now may need to issue cache flushes to block devices instead of
flushing the journal. We add a device bitmask to bch_inode_info,
ei_devs_need_flush, which tracks devices that need to have flushes
issued - note that this will lead to unnecessary flushes when other
codepaths have already issued flushes, we may want to replace this with
a sequence number.
- New nocow write path: look up extents, and if they're writable write
to them - otherwise fall back to the normal COW write path.
XXX: switch to sequence numbers instead of bitmask for devs needing
journal flush
XXX: ei_quota_lock being a mutex means bch2_nocow_write_done() needs to
run in process context - see if we can improve this
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2022-11-02 17:12:00 -04:00
|
|
|
x(nocow, u8, \
|
|
|
|
OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
|
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH_SB_NOCOW, false, \
|
|
|
|
NULL, "Nocow mode: Writes will be done in place when possible.\n"\
|
|
|
|
"Snapshots and reflink will still caused writes to be COW\n"\
|
|
|
|
"Implicitly disables data checksumming, compression and encryption")\
|
2023-02-24 19:07:21 -05:00
|
|
|
x(nocow_enabled, u8, \
|
|
|
|
OPT_FS|OPT_MOUNT, \
|
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH2_NO_SB_OPT, true, \
|
|
|
|
NULL, "Enable nocow mode: enables runtime locking in\n"\
|
|
|
|
"data move path needed if nocow will ever be in use\n")\
|
2024-10-24 01:06:53 -04:00
|
|
|
x(copygc_enabled, u8, \
|
2025-01-25 17:19:38 -05:00
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
2024-10-24 01:06:53 -04:00
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH2_NO_SB_OPT, true, \
|
|
|
|
NULL, "Enable copygc: disable for debugging, or to\n"\
|
|
|
|
"quiet the system when doing performance testing\n")\
|
|
|
|
x(rebalance_enabled, u8, \
|
2025-01-25 17:19:38 -05:00
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
2024-10-24 01:06:53 -04:00
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH2_NO_SB_OPT, true, \
|
|
|
|
NULL, "Enable rebalance: disable for debugging, or to\n"\
|
|
|
|
"quiet the system when doing performance testing\n")\
|
2025-05-05 20:35:36 -04:00
|
|
|
x(rebalance_on_ac_only, u8, \
|
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH_SB_REBALANCE_AC_ONLY, false, \
|
|
|
|
NULL, "Enable rebalance while on mains power only\n") \
|
2025-05-07 14:26:18 -04:00
|
|
|
x(auto_snapshot_deletion, u8, \
|
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH2_NO_SB_OPT, true, \
|
|
|
|
NULL, "Enable automatic snapshot deletion: disable for debugging, or to\n"\
|
|
|
|
"quiet the system when doing performance testing\n")\
|
2018-12-19 12:58:56 -05:00
|
|
|
x(no_data_io, u8, \
|
|
|
|
OPT_MOUNT, \
|
|
|
|
OPT_BOOL(), \
|
2022-03-05 12:01:16 -05:00
|
|
|
BCH2_NO_SB_OPT, false, \
|
2018-12-19 12:58:56 -05:00
|
|
|
NULL, "Skip submit_bio() for data reads and writes, " \
|
|
|
|
"for performance testing purposes") \
|
2025-03-13 12:05:50 -04:00
|
|
|
x(state, u64, \
|
2025-03-13 00:55:52 -04:00
|
|
|
OPT_DEVICE|OPT_RUNTIME, \
|
2025-03-13 12:05:50 -04:00
|
|
|
OPT_STR(bch2_member_states), \
|
|
|
|
BCH_MEMBER_STATE, BCH_MEMBER_STATE_rw, \
|
|
|
|
"state", "rw,ro,failed,spare") \
|
|
|
|
x(bucket_size, u32, \
|
|
|
|
OPT_DEVICE|OPT_HUMAN_READABLE|OPT_SB_FIELD_SECTORS, \
|
2021-12-14 14:24:41 -05:00
|
|
|
OPT_UINT(0, S64_MAX), \
|
2025-03-13 12:05:50 -04:00
|
|
|
BCH_MEMBER_BUCKET_SIZE, 0, \
|
2024-10-16 09:50:26 +08:00
|
|
|
"size", "Specifies the bucket size; must be greater than the btree node size")\
|
2018-12-19 12:58:56 -05:00
|
|
|
x(durability, u8, \
|
2025-03-13 12:05:50 -04:00
|
|
|
OPT_DEVICE|OPT_RUNTIME|OPT_SB_FIELD_ONE_BIAS, \
|
2018-12-19 12:58:56 -05:00
|
|
|
OPT_UINT(0, BCH_REPLICAS_MAX), \
|
2025-03-13 12:05:50 -04:00
|
|
|
BCH_MEMBER_DURABILITY, 1, \
|
2018-12-19 12:58:56 -05:00
|
|
|
"n", "Data written to this device will be considered\n"\
|
2024-01-03 15:21:45 -05:00
|
|
|
"to have already been replicated n times") \
|
2024-07-15 16:53:49 -04:00
|
|
|
x(data_allowed, u8, \
|
|
|
|
OPT_DEVICE, \
|
|
|
|
OPT_BITFIELD(__bch2_data_types), \
|
2025-03-13 12:05:50 -04:00
|
|
|
BCH_MEMBER_DATA_ALLOWED, BIT(BCH_DATA_journal)|BIT(BCH_DATA_btree)|BIT(BCH_DATA_user),\
|
2024-07-15 16:53:49 -04:00
|
|
|
"types", "Allowed data types for this device: journal, btree, and/or user")\
|
2025-03-13 12:05:50 -04:00
|
|
|
x(discard, u8, \
|
2025-04-02 15:12:49 -04:00
|
|
|
OPT_MOUNT|OPT_FS|OPT_DEVICE|OPT_RUNTIME, \
|
2025-03-13 12:05:50 -04:00
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH_MEMBER_DISCARD, true, \
|
|
|
|
NULL, "Enable discard/TRIM support") \
|
2024-01-03 15:21:45 -05:00
|
|
|
x(btree_node_prefetch, u8, \
|
|
|
|
OPT_FS|OPT_MOUNT|OPT_RUNTIME, \
|
|
|
|
OPT_BOOL(), \
|
|
|
|
BCH2_NO_SB_OPT, true, \
|
2025-04-02 15:12:49 -04:00
|
|
|
NULL, "BTREE_ITER_prefetch causes btree nodes to be\n"\
|
2024-01-03 15:21:45 -05:00
|
|
|
" prefetched sequentially")
|
2017-03-16 22:18:50 -08:00
|
|
|
|
|
|
|
struct bch_opts {
|
2018-12-19 12:58:56 -05:00
|
|
|
#define x(_name, _bits, ...) unsigned _name##_defined:1;
|
2017-03-16 22:18:50 -08:00
|
|
|
BCH_OPTS()
|
2018-12-19 12:58:56 -05:00
|
|
|
#undef x
|
2017-03-16 22:18:50 -08:00
|
|
|
|
2018-12-19 12:58:56 -05:00
|
|
|
#define x(_name, _bits, ...) _bits _name;
|
2017-03-16 22:18:50 -08:00
|
|
|
BCH_OPTS()
|
2018-12-19 12:58:56 -05:00
|
|
|
#undef x
|
2017-03-16 22:18:50 -08:00
|
|
|
};
|
|
|
|
|
2024-05-27 22:36:11 -06:00
|
|
|
struct bch2_opts_parse {
|
|
|
|
struct bch_opts opts;
|
|
|
|
|
|
|
|
/* to save opts that can't be parsed before the FS is opened: */
|
|
|
|
struct printbuf parse_later;
|
|
|
|
};
|
|
|
|
|
2023-09-12 18:41:22 -04:00
|
|
|
static const __maybe_unused struct bch_opts bch2_opts_default = {
|
2018-12-19 12:58:56 -05:00
|
|
|
#define x(_name, _bits, _mode, _type, _sb_opt, _default, ...) \
|
2017-03-16 22:18:50 -08:00
|
|
|
._name##_defined = true, \
|
|
|
|
._name = _default, \
|
|
|
|
|
|
|
|
BCH_OPTS()
|
2018-12-19 12:58:56 -05:00
|
|
|
#undef x
|
2017-03-16 22:18:50 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define opt_defined(_opts, _name) ((_opts)._name##_defined)
|
|
|
|
|
|
|
|
#define opt_get(_opts, _name) \
|
|
|
|
(opt_defined(_opts, _name) ? (_opts)._name : bch2_opts_default._name)
|
|
|
|
|
|
|
|
#define opt_set(_opts, _name, _v) \
|
|
|
|
do { \
|
|
|
|
(_opts)._name##_defined = true; \
|
|
|
|
(_opts)._name = _v; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
static inline struct bch_opts bch2_opts_empty(void)
|
|
|
|
{
|
|
|
|
return (struct bch_opts) { 0 };
|
|
|
|
}
|
|
|
|
|
|
|
|
void bch2_opts_apply(struct bch_opts *, struct bch_opts);
|
|
|
|
|
|
|
|
enum bch_opt_id {
|
2018-12-19 12:58:56 -05:00
|
|
|
#define x(_name, ...) Opt_##_name,
|
2017-03-16 22:18:50 -08:00
|
|
|
BCH_OPTS()
|
2018-12-19 12:58:56 -05:00
|
|
|
#undef x
|
2017-03-16 22:18:50 -08:00
|
|
|
bch2_opts_nr
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bch_fs;
|
2018-11-09 01:24:07 -05:00
|
|
|
struct printbuf;
|
2017-03-16 22:18:50 -08:00
|
|
|
|
|
|
|
struct bch_option {
|
|
|
|
struct attribute attr;
|
|
|
|
enum opt_type type;
|
2021-12-14 14:24:41 -05:00
|
|
|
enum opt_flags flags;
|
|
|
|
u64 min, max;
|
2017-03-16 22:18:50 -08:00
|
|
|
|
2022-05-03 16:50:57 -06:00
|
|
|
const char * const *choices;
|
2023-07-12 21:48:32 -04:00
|
|
|
|
|
|
|
struct bch_opt_fn fn;
|
2017-03-16 22:18:50 -08:00
|
|
|
|
2018-12-19 12:58:56 -05:00
|
|
|
const char *hint;
|
|
|
|
const char *help;
|
|
|
|
|
2025-03-13 12:05:50 -04:00
|
|
|
u64 (*get_sb)(const struct bch_sb *);
|
|
|
|
void (*set_sb)(struct bch_sb *, u64);
|
|
|
|
|
|
|
|
u64 (*get_member)(const struct bch_member *);
|
|
|
|
void (*set_member)(struct bch_member *, u64);
|
|
|
|
|
2017-03-16 22:18:50 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct bch_option bch2_opt_table[];
|
|
|
|
|
|
|
|
bool bch2_opt_defined_by_id(const struct bch_opts *, enum bch_opt_id);
|
|
|
|
u64 bch2_opt_get_by_id(const struct bch_opts *, enum bch_opt_id);
|
|
|
|
void bch2_opt_set_by_id(struct bch_opts *, enum bch_opt_id, u64);
|
|
|
|
|
2025-03-13 12:05:50 -04:00
|
|
|
u64 bch2_opt_from_sb(struct bch_sb *, enum bch_opt_id, int);
|
2021-12-14 14:24:41 -05:00
|
|
|
int bch2_opts_from_sb(struct bch_opts *, struct bch_sb *);
|
2025-04-15 09:54:01 -04:00
|
|
|
bool __bch2_opt_set_sb(struct bch_sb *, int, const struct bch_option *, u64);
|
2024-07-15 19:26:46 -04:00
|
|
|
|
|
|
|
struct bch_dev;
|
2025-04-15 09:54:01 -04:00
|
|
|
bool bch2_opt_set_sb(struct bch_fs *, struct bch_dev *, const struct bch_option *, u64);
|
2017-03-16 22:18:50 -08:00
|
|
|
|
|
|
|
int bch2_opt_lookup(const char *);
|
2022-03-21 00:15:38 -04:00
|
|
|
int bch2_opt_validate(const struct bch_option *, u64, struct printbuf *);
|
|
|
|
int bch2_opt_parse(struct bch_fs *, const struct bch_option *,
|
|
|
|
const char *, u64 *, struct printbuf *);
|
2017-03-16 22:18:50 -08:00
|
|
|
|
|
|
|
#define OPT_SHOW_FULL_LIST (1 << 0)
|
|
|
|
#define OPT_SHOW_MOUNT_STYLE (1 << 1)
|
|
|
|
|
2022-03-05 12:01:16 -05:00
|
|
|
void bch2_opt_to_text(struct printbuf *, struct bch_fs *, struct bch_sb *,
|
2018-11-09 01:24:07 -05:00
|
|
|
const struct bch_option *, u64, unsigned);
|
2024-09-07 20:27:23 -04:00
|
|
|
void bch2_opts_to_text(struct printbuf *,
|
|
|
|
struct bch_opts,
|
|
|
|
struct bch_fs *, struct bch_sb *,
|
|
|
|
unsigned, unsigned, unsigned);
|
2017-03-16 22:18:50 -08:00
|
|
|
|
2025-04-15 09:54:01 -04:00
|
|
|
int bch2_opt_hook_pre_set(struct bch_fs *, struct bch_dev *, enum bch_opt_id, u64);
|
|
|
|
int bch2_opts_hooks_pre_set(struct bch_fs *);
|
|
|
|
void bch2_opt_hook_post_set(struct bch_fs *, struct bch_dev *, u64,
|
|
|
|
struct bch_opts *, enum bch_opt_id);
|
|
|
|
|
2024-05-27 22:36:09 -06:00
|
|
|
int bch2_parse_one_mount_opt(struct bch_fs *, struct bch_opts *,
|
|
|
|
struct printbuf *, const char *, const char *);
|
|
|
|
int bch2_parse_mount_opts(struct bch_fs *, struct bch_opts *, struct printbuf *,
|
2025-03-25 13:19:40 -04:00
|
|
|
char *, bool);
|
2017-03-16 22:18:50 -08:00
|
|
|
|
|
|
|
/* inode opts: */
|
|
|
|
|
|
|
|
struct bch_io_opts {
|
2018-12-13 06:01:30 -05:00
|
|
|
#define x(_name, _bits) u##_bits _name;
|
2017-03-16 22:18:50 -08:00
|
|
|
BCH_INODE_OPTS()
|
2018-12-13 06:01:30 -05:00
|
|
|
#undef x
|
2024-10-19 23:26:11 -04:00
|
|
|
#define x(_name, _bits) u64 _name##_from_inode:1;
|
|
|
|
BCH_INODE_OPTS()
|
|
|
|
#undef x
|
2017-03-16 22:18:50 -08:00
|
|
|
};
|
|
|
|
|
2024-10-20 01:21:43 -04:00
|
|
|
static inline void bch2_io_opts_fixups(struct bch_io_opts *opts)
|
2024-01-16 16:20:21 -05:00
|
|
|
{
|
2024-10-20 01:21:43 -04:00
|
|
|
if (!opts->background_target)
|
|
|
|
opts->background_target = opts->foreground_target;
|
|
|
|
if (!opts->background_compression)
|
|
|
|
opts->background_compression = opts->compression;
|
|
|
|
if (opts->nocow) {
|
|
|
|
opts->compression = opts->background_compression = 0;
|
|
|
|
opts->data_checksum = 0;
|
|
|
|
opts->erasure_code = 0;
|
|
|
|
}
|
2024-01-16 16:20:21 -05:00
|
|
|
}
|
|
|
|
|
2017-03-16 22:18:50 -08:00
|
|
|
struct bch_io_opts bch2_opts_to_inode_opts(struct bch_opts);
|
|
|
|
bool bch2_opt_is_inode_opt(enum bch_opt_id);
|
|
|
|
|
|
|
|
#endif /* _BCACHEFS_OPTS_H */
|