]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/opts.h
Update bcachefs sources to 8ffb42b3d0 bcachefs: Finish writing journal after journal...
[bcachefs-tools-debian] / libbcachefs / opts.h
index 87114277876356d966bb64c5d7256ac3c6a28681..bafacf6b46a2a962688bb49974d481ee136c6b62 100644 (file)
@@ -19,8 +19,9 @@ extern const char * const bch2_compression_opts[];
 extern const char * const bch2_str_hash_types[];
 extern const char * const bch2_str_hash_opts[];
 extern const char * const bch2_data_types[];
-extern const char * const bch2_cache_replacement_policies[];
 extern const char * const bch2_member_states[];
+extern const char * const bch2_jset_entry_types[];
+extern const char * const bch2_fs_usage_types[];
 extern const char * const bch2_d_types[];
 
 static inline const char *bch2_d_type_str(unsigned d_type)
@@ -44,19 +45,22 @@ static inline const char *bch2_d_type_str(unsigned d_type)
 LE64_BITMASK(NO_SB_OPT,                struct bch_sb, flags[0], 0, 0);
 
 /* When can be set: */
-enum opt_mode {
+enum opt_flags {
        OPT_FS          = (1 << 0),     /* Filesystem option */
        OPT_DEVICE      = (1 << 1),     /* Device option */
        OPT_INODE       = (1 << 2),     /* Inode option */
        OPT_FORMAT      = (1 << 3),     /* May be specified at format time */
        OPT_MOUNT       = (1 << 4),     /* May be specified at mount time */
        OPT_RUNTIME     = (1 << 5),     /* May be specified at runtime */
+       OPT_HUMAN_READABLE = (1 << 6),
+       OPT_MUST_BE_POW_2 = (1 << 7),   /* Must be power of 2 */
+       OPT_SB_FIELD_SECTORS = (1 << 8),/* Superblock field is >> 9 of actual value */
+       OPT_SB_FIELD_ILOG2 = (1 << 9),  /* Superblock field is ilog2 of actual value */
 };
 
 enum opt_type {
        BCH_OPT_BOOL,
        BCH_OPT_UINT,
-       BCH_OPT_SECTORS,
        BCH_OPT_STR,
        BCH_OPT_FN,
 };
@@ -88,13 +92,15 @@ enum opt_type {
 
 #define BCH_OPTS()                                                     \
        x(block_size,                   u16,                            \
-         OPT_FS|OPT_FORMAT,                                            \
-         OPT_SECTORS(1, 128),                                          \
+         OPT_FS|OPT_FORMAT|                                            \
+         OPT_HUMAN_READABLE|OPT_MUST_BE_POW_2|OPT_SB_FIELD_SECTORS,    \
+         OPT_UINT(512, 1U << 16),                                      \
          BCH_SB_BLOCK_SIZE,            8,                              \
          "size",       NULL)                                           \
-       x(btree_node_size,              u16,                            \
-         OPT_FS|OPT_FORMAT,                                            \
-         OPT_SECTORS(1, 512),                                          \
+       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),                                      \
          BCH_SB_BTREE_NODE_SIZE,       512,                            \
          "size",       "Btree node size, default 256k")                \
        x(errors,                       u8,                             \
@@ -122,6 +128,12 @@ enum opt_type {
          OPT_UINT(1, BCH_REPLICAS_MAX),                                \
          BCH_SB_DATA_REPLICAS_REQ,     1,                              \
          "#",          NULL)                                           \
+       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")\
        x(metadata_checksum,            u8,                             \
          OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
          OPT_STR(bch2_csum_opts),                                      \
@@ -198,8 +210,9 @@ enum opt_type {
          BCH_SB_GC_RESERVE,            8,                              \
          "%",          "Percentage of disk space to reserve for copygc")\
        x(gc_reserve_bytes,             u64,                            \
-         OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                      \
-         OPT_SECTORS(0, U64_MAX),                                      \
+         OPT_FS|OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|                      \
+         OPT_HUMAN_READABLE|OPT_SB_FIELD_SECTORS,                      \
+         OPT_UINT(0, U64_MAX),                                         \
          BCH_SB_GC_RESERVE_BYTES,      0,                              \
          "%",          "Amount of disk space to reserve for copygc\n"  \
                        "Takes precedence over gc_reserve_percent if set")\
@@ -316,6 +329,16 @@ enum opt_type {
          OPT_BOOL(),                                                   \
          NO_SB_OPT,                    false,                          \
          NULL,         "Read all journal entries, not just dirty ones")\
+       x(read_journal_only,            u8,                             \
+         0,                                                            \
+         OPT_BOOL(),                                                   \
+         NO_SB_OPT,                    false,                          \
+         NULL,         "Only read the journal, skip the rest of recovery")\
+       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")    \
        x(noexcl,                       u8,                             \
          OPT_FS|OPT_MOUNT,                                             \
          OPT_BOOL(),                                                   \
@@ -347,6 +370,11 @@ enum opt_type {
          NO_SB_OPT,                    false,                          \
          NULL,         "Set superblock to latest version,\n"           \
                        "allowing any new features to be used")         \
+       x(buckets_nouse,                u8,                             \
+         0,                                                            \
+         OPT_BOOL(),                                                   \
+         NO_SB_OPT,                    false,                          \
+         NULL,         "Allocate the buckets_nouse bitmap")            \
        x(project,                      u8,                             \
          OPT_INODE,                                                    \
          OPT_BOOL(),                                                   \
@@ -354,12 +382,12 @@ enum opt_type {
          NULL,         NULL)                                           \
        x(fs_size,                      u64,                            \
          OPT_DEVICE,                                                   \
-         OPT_SECTORS(0, S64_MAX),                                      \
+         OPT_UINT(0, S64_MAX),                                         \
          NO_SB_OPT,                    0,                              \
          "size",       "Size of filesystem on device")                 \
        x(bucket,                       u32,                            \
          OPT_DEVICE,                                                   \
-         OPT_SECTORS(0, S64_MAX),                                      \
+         OPT_UINT(0, S64_MAX),                                         \
          NO_SB_OPT,                    0,                              \
          "size",       "Size of filesystem on device")                 \
        x(durability,                   u8,                             \
@@ -418,13 +446,14 @@ struct printbuf;
 
 struct bch_option {
        struct attribute        attr;
+       u64                     (*get_sb)(const struct bch_sb *);
        void                    (*set_sb)(struct bch_sb *, u64);
-       enum opt_mode           mode;
        enum opt_type           type;
+       enum opt_flags          flags;
+       u64                     min, max;
 
        union {
        struct {
-               u64             min, max;
        };
        struct {
                const char * const *choices;
@@ -446,10 +475,13 @@ 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);
 
-struct bch_opts bch2_opts_from_sb(struct bch_sb *);
+int bch2_opts_from_sb(struct bch_opts *, struct bch_sb *);
+void __bch2_opt_set_sb(struct bch_sb *, const struct bch_option *, u64);
+void bch2_opt_set_sb(struct bch_fs *, const struct bch_option *, u64);
 
 int bch2_opt_lookup(const char *);
-int bch2_opt_parse(struct bch_fs *, const struct bch_option *, const char *, u64 *);
+int bch2_opt_parse(struct bch_fs *, const char *, const struct bch_option *,
+                  const char *, u64 *);
 
 #define OPT_SHOW_FULL_LIST     (1 << 0)
 #define OPT_SHOW_MOUNT_STYLE   (1 << 1)