]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/opts.h
Update bcachefs sources to d267e10a43b2 bcachefs: __bch2_sb_field_to_text()
[bcachefs-tools-debian] / libbcachefs / opts.h
index e105a742fd443b17cecb271b526b25adcb3e3958..93a24fef42148488cdddb391cd291dd0e0168063 100644 (file)
@@ -8,11 +8,14 @@
 #include <linux/sysfs.h>
 #include "bcachefs_format.h"
 
+struct bch_fs;
+
 extern const char * const bch2_error_actions[];
+extern const char * const bch2_fsck_fix_opts[];
 extern const char * const bch2_version_upgrade_opts[];
 extern const char * const bch2_sb_features[];
 extern const char * const bch2_sb_compat[];
-extern const char * const bch2_btree_ids[];
+extern const char * const __bch2_btree_ids[];
 extern const char * const bch2_csum_types[];
 extern const char * const bch2_csum_opts[];
 extern const char * const bch2_compression_types[];
@@ -67,6 +70,12 @@ enum opt_type {
        BCH_OPT_FN,
 };
 
+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);
+       int (*validate)(u64, struct printbuf *);
+};
+
 /**
  * x(name, shortopt, type, in mem type, mode, sb_opt)
  *
@@ -98,6 +107,18 @@ enum opt_type {
 #define BCACHEFS_VERBOSE_DEFAULT       false
 #endif
 
+#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
+};
+
 #define BCH_OPTS()                                                     \
        x(block_size,                   u16,                            \
          OPT_FS|OPT_FORMAT|                                            \
@@ -154,12 +175,12 @@ enum opt_type {
          NULL,         NULL)                                           \
        x(compression,                  u8,                             \
          OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,            \
-         OPT_STR(bch2_compression_opts),                               \
+         OPT_FN(bch2_opt_compression),                                 \
          BCH_SB_COMPRESSION_TYPE,      BCH_COMPRESSION_OPT_none,       \
          NULL,         NULL)                                           \
        x(background_compression,       u8,                             \
          OPT_FS|OPT_INODE|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,            \
-         OPT_STR(bch2_compression_opts),                               \
+         OPT_FN(bch2_opt_compression),                                 \
          BCH_SB_BACKGROUND_COMPRESSION_TYPE,BCH_COMPRESSION_OPT_none,  \
          NULL,         NULL)                                           \
        x(str_hash,                     u8,                             \
@@ -212,11 +233,6 @@ enum opt_type {
          OPT_BOOL(),                                                   \
          BCH2_NO_SB_OPT,               true,                           \
          NULL,         "Stash pointer to in memory btree node in btree ptr")\
-       x(btree_write_buffer_size, u32,                                 \
-         OPT_FS|OPT_MOUNT,                                             \
-         OPT_UINT(16, (1U << 20) - 1),                                 \
-         BCH2_NO_SB_OPT,               1U << 13,                       \
-         NULL,         "Number of btree write buffer entries")         \
        x(gc_reserve_percent,           u8,                             \
          OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
          OPT_UINT(5, 21),                                              \
@@ -318,8 +334,8 @@ enum opt_type {
          NULL,         "Run fsck on mount")                            \
        x(fix_errors,                   u8,                             \
          OPT_FS|OPT_MOUNT,                                             \
-         OPT_BOOL(),                                                   \
-         BCH2_NO_SB_OPT,               false,                          \
+         OPT_FN(bch2_opt_fix_errors),                                  \
+         BCH2_NO_SB_OPT,               FSCK_FIX_exit,                  \
          NULL,         "Fix errors during fsck without asking")        \
        x(ratelimit_errors,             u8,                             \
          OPT_FS|OPT_MOUNT,                                             \
@@ -373,7 +389,7 @@ enum opt_type {
          BCH2_NO_SB_OPT,               BCH_SB_SECTOR,                  \
          "offset",     "Sector offset of superblock")                  \
        x(read_only,                    u8,                             \
-         OPT_FS,                                                       \
+         OPT_FS|OPT_MOUNT,                                             \
          OPT_BOOL(),                                                   \
          BCH2_NO_SB_OPT,               false,                          \
          NULL,         NULL)                                           \
@@ -398,6 +414,11 @@ enum opt_type {
          OPT_BOOL(),                                                   \
          BCH2_NO_SB_OPT,               false,                          \
          NULL,         "Allocate the buckets_nouse bitmap")            \
+       x(stdio,                        u64,                            \
+         0,                                                            \
+         OPT_UINT(0, S64_MAX),                                         \
+         BCH2_NO_SB_OPT,               false,                          \
+         NULL,         "Pointer to a struct stdio_redirect")           \
        x(project,                      u8,                             \
          OPT_INODE,                                                    \
          OPT_BOOL(),                                                   \
@@ -437,7 +458,13 @@ enum opt_type {
          OPT_UINT(0, BCH_REPLICAS_MAX),                                \
          BCH2_NO_SB_OPT,               1,                              \
          "n",          "Data written to this device will be considered\n"\
-                       "to have already been replicated n times")
+                       "to have already been replicated n times")      \
+       x(btree_node_prefetch,          u8,                             \
+         OPT_FS|OPT_MOUNT|OPT_RUNTIME,                                 \
+         OPT_BOOL(),                                                   \
+         BCH2_NO_SB_OPT,               true,                           \
+         NULL,         "BTREE_ITER_PREFETCH casuse btree nodes to be\n"\
+         " prefetched sequentially")
 
 struct bch_opts {
 #define x(_name, _bits, ...)   unsigned _name##_defined:1;
@@ -449,7 +476,7 @@ struct bch_opts {
 #undef x
 };
 
-static const struct bch_opts bch2_opts_default = {
+static const __maybe_unused struct bch_opts bch2_opts_default = {
 #define x(_name, _bits, _mode, _type, _sb_opt, _default, ...)          \
        ._name##_defined = true,                                        \
        ._name = _default,                                              \
@@ -495,8 +522,8 @@ struct bch_option {
        u64                     min, max;
 
        const char * const *choices;
-       int (*parse)(struct bch_fs *, const char *, u64 *);
-       void (*to_text)(struct printbuf *, struct bch_fs *, struct bch_sb *, u64);
+
+       struct bch_opt_fn       fn;
 
        const char              *hint;
        const char              *help;