bcachefs: Convert some enums to x-macros
authorKent Overstreet <kent.overstreet@gmail.com>
Sun, 29 Dec 2019 01:17:06 +0000 (20:17 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:33 +0000 (17:08 -0400)
Helps for preventing things from getting out of sync.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
15 files changed:
fs/bcachefs/bcachefs.h
fs/bcachefs/bcachefs_format.h
fs/bcachefs/checksum.h
fs/bcachefs/compress.c
fs/bcachefs/extents.c
fs/bcachefs/fsck.c
fs/bcachefs/io.c
fs/bcachefs/journal_seq_blacklist.c
fs/bcachefs/move.c
fs/bcachefs/opts.c
fs/bcachefs/opts.h
fs/bcachefs/recovery.c
fs/bcachefs/reflink.c
fs/bcachefs/str_hash.h
fs/bcachefs/sysfs.c

index 3fa053531344e6ad9ec57d3a82a361a59e40bd61..0d4a8b75ff42beb2e650e332da25cdf2ba0affcd 100644 (file)
@@ -718,7 +718,7 @@ struct bch_fs {
        struct rhashtable       promote_table;
 
        mempool_t               compression_bounce[2];
-       mempool_t               compress_workspace[BCH_COMPRESSION_NR];
+       mempool_t               compress_workspace[BCH_COMPRESSION_TYPE_NR];
        mempool_t               decompress_workspace;
        ZSTD_parameters         zstd_params;
 
index 9b8fc265a5c0c5aaf5d8f0df6e019393717b1519..535ba27883159c08710e10d326e279ab8409009d 100644 (file)
@@ -436,47 +436,6 @@ struct bch_csum {
        __le64                  hi;
 } __attribute__((packed, aligned(8)));
 
-enum bch_csum_type {
-       BCH_CSUM_NONE                   = 0,
-       BCH_CSUM_CRC32C_NONZERO         = 1,
-       BCH_CSUM_CRC64_NONZERO          = 2,
-       BCH_CSUM_CHACHA20_POLY1305_80   = 3,
-       BCH_CSUM_CHACHA20_POLY1305_128  = 4,
-       BCH_CSUM_CRC32C                 = 5,
-       BCH_CSUM_CRC64                  = 6,
-       BCH_CSUM_NR                     = 7,
-};
-
-static const unsigned bch_crc_bytes[] = {
-       [BCH_CSUM_NONE]                         = 0,
-       [BCH_CSUM_CRC32C_NONZERO]               = 4,
-       [BCH_CSUM_CRC32C]                       = 4,
-       [BCH_CSUM_CRC64_NONZERO]                = 8,
-       [BCH_CSUM_CRC64]                        = 8,
-       [BCH_CSUM_CHACHA20_POLY1305_80]         = 10,
-       [BCH_CSUM_CHACHA20_POLY1305_128]        = 16,
-};
-
-static inline _Bool bch2_csum_type_is_encryption(enum bch_csum_type type)
-{
-       switch (type) {
-       case BCH_CSUM_CHACHA20_POLY1305_80:
-       case BCH_CSUM_CHACHA20_POLY1305_128:
-               return true;
-       default:
-               return false;
-       }
-}
-
-enum bch_compression_type {
-       BCH_COMPRESSION_NONE            = 0,
-       BCH_COMPRESSION_LZ4_OLD         = 1,
-       BCH_COMPRESSION_GZIP            = 2,
-       BCH_COMPRESSION_LZ4             = 3,
-       BCH_COMPRESSION_ZSTD            = 4,
-       BCH_COMPRESSION_NR              = 5,
-};
-
 #define BCH_EXTENT_ENTRY_TYPES()               \
        x(ptr,                  0)              \
        x(crc32,                1)              \
@@ -1320,17 +1279,29 @@ LE64_BITMASK(BCH_SB_GC_RESERVE_BYTES,   struct bch_sb, flags[2],  4, 64);
 
 LE64_BITMASK(BCH_SB_ERASURE_CODE,      struct bch_sb, flags[3],  0, 16);
 
-/* Features: */
-enum bch_sb_features {
-       BCH_FEATURE_LZ4                 = 0,
-       BCH_FEATURE_GZIP                = 1,
-       BCH_FEATURE_ZSTD                = 2,
-       BCH_FEATURE_ATOMIC_NLINK        = 3, /* should have gone under compat */
-       BCH_FEATURE_EC                  = 4,
-       BCH_FEATURE_JOURNAL_SEQ_BLACKLIST_V3 = 5,
-       BCH_FEATURE_REFLINK             = 6,
-       BCH_FEATURE_NEW_SIPHASH         = 7,
-       BCH_FEATURE_INLINE_DATA         = 8,
+/*
+ * Features:
+ *
+ * journal_seq_blacklist_v3:   gates BCH_SB_FIELD_journal_seq_blacklist
+ * reflink:                    gates KEY_TYPE_reflink
+ * inline_data:                        gates KEY_TYPE_inline_data
+ * new_siphash:                        gates BCH_STR_HASH_SIPHASH
+ */
+#define BCH_SB_FEATURES()                      \
+       x(lz4,                          0)      \
+       x(gzip,                         1)      \
+       x(zstd,                         2)      \
+       x(atomic_nlink,                 3)      \
+       x(ec,                           4)      \
+       x(journal_seq_blacklist_v3,     5)      \
+       x(reflink,                      6)      \
+       x(new_siphash,                  7)      \
+       x(inline_data,                  8)
+
+enum bch_sb_feature {
+#define x(f, n) BCH_FEATURE_##f,
+       BCH_SB_FEATURES()
+#undef x
        BCH_FEATURE_NR,
 };
 
@@ -1350,13 +1321,6 @@ enum bch_error_actions {
        BCH_NR_ERROR_ACTIONS            = 3,
 };
 
-enum bch_csum_opts {
-       BCH_CSUM_OPT_NONE               = 0,
-       BCH_CSUM_OPT_CRC32C             = 1,
-       BCH_CSUM_OPT_CRC64              = 2,
-       BCH_CSUM_OPT_NR                 = 3,
-};
-
 enum bch_str_hash_type {
        BCH_STR_HASH_CRC32C             = 0,
        BCH_STR_HASH_CRC64              = 1,
@@ -1372,15 +1336,68 @@ enum bch_str_hash_opts {
        BCH_STR_HASH_OPT_NR             = 3,
 };
 
+enum bch_csum_type {
+       BCH_CSUM_NONE                   = 0,
+       BCH_CSUM_CRC32C_NONZERO         = 1,
+       BCH_CSUM_CRC64_NONZERO          = 2,
+       BCH_CSUM_CHACHA20_POLY1305_80   = 3,
+       BCH_CSUM_CHACHA20_POLY1305_128  = 4,
+       BCH_CSUM_CRC32C                 = 5,
+       BCH_CSUM_CRC64                  = 6,
+       BCH_CSUM_NR                     = 7,
+};
+
+static const unsigned bch_crc_bytes[] = {
+       [BCH_CSUM_NONE]                         = 0,
+       [BCH_CSUM_CRC32C_NONZERO]               = 4,
+       [BCH_CSUM_CRC32C]                       = 4,
+       [BCH_CSUM_CRC64_NONZERO]                = 8,
+       [BCH_CSUM_CRC64]                        = 8,
+       [BCH_CSUM_CHACHA20_POLY1305_80]         = 10,
+       [BCH_CSUM_CHACHA20_POLY1305_128]        = 16,
+};
+
+static inline _Bool bch2_csum_type_is_encryption(enum bch_csum_type type)
+{
+       switch (type) {
+       case BCH_CSUM_CHACHA20_POLY1305_80:
+       case BCH_CSUM_CHACHA20_POLY1305_128:
+               return true;
+       default:
+               return false;
+       }
+}
+
+enum bch_csum_opts {
+       BCH_CSUM_OPT_NONE               = 0,
+       BCH_CSUM_OPT_CRC32C             = 1,
+       BCH_CSUM_OPT_CRC64              = 2,
+       BCH_CSUM_OPT_NR                 = 3,
+};
+
 #define BCH_COMPRESSION_TYPES()                \
-       x(NONE)                         \
-       x(LZ4)                          \
-       x(GZIP)                         \
-       x(ZSTD)
+       x(none,         0)              \
+       x(lz4_old,      1)              \
+       x(gzip,         2)              \
+       x(lz4,          3)              \
+       x(zstd,         4)
 
-enum bch_compression_opts {
-#define x(t) BCH_COMPRESSION_OPT_##t,
+enum bch_compression_type {
+#define x(t, n) BCH_COMPRESSION_TYPE_##t,
        BCH_COMPRESSION_TYPES()
+#undef x
+       BCH_COMPRESSION_TYPE_NR
+};
+
+#define BCH_COMPRESSION_OPTS()         \
+       x(none,         0)              \
+       x(lz4,          1)              \
+       x(gzip,         2)              \
+       x(zstd,         3)
+
+enum bch_compression_opts {
+#define x(t, n) BCH_COMPRESSION_OPT_##t,
+       BCH_COMPRESSION_OPTS()
 #undef x
        BCH_COMPRESSION_OPT_NR
 };
index b84e81bac8ff7b663b8f3238f2dceadc84bf5c9d..ca9e45906dc8813f707076670caabfdabcab4bd9 100644 (file)
@@ -108,8 +108,8 @@ static inline enum bch_csum_type bch2_meta_checksum_type(struct bch_fs *c)
 }
 
 static const unsigned bch2_compression_opt_to_type[] = {
-#define x(t) [BCH_COMPRESSION_OPT_##t] = BCH_COMPRESSION_##t,
-       BCH_COMPRESSION_TYPES()
+#define x(t, n) [BCH_COMPRESSION_OPT_##t] = BCH_COMPRESSION_TYPE_##t,
+       BCH_COMPRESSION_OPTS()
 #undef x
 };
 
index d350d917a8d479fe9efda56a7cc2cff09d974f9b..091958d1ea0436320a072a81cbcb5682a11df59a 100644 (file)
@@ -158,14 +158,14 @@ static int __bio_uncompress(struct bch_fs *c, struct bio *src,
        src_data = bio_map_or_bounce(c, src, READ);
 
        switch (crc.compression_type) {
-       case BCH_COMPRESSION_LZ4_OLD:
-       case BCH_COMPRESSION_LZ4:
+       case BCH_COMPRESSION_TYPE_lz4_old:
+       case BCH_COMPRESSION_TYPE_lz4:
                ret = LZ4_decompress_safe_partial(src_data.b, dst_data,
                                                  src_len, dst_len, dst_len);
                if (ret != dst_len)
                        goto err;
                break;
-       case BCH_COMPRESSION_GZIP: {
+       case BCH_COMPRESSION_TYPE_gzip: {
                z_stream strm = {
                        .next_in        = src_data.b,
                        .avail_in       = src_len,
@@ -185,7 +185,7 @@ static int __bio_uncompress(struct bch_fs *c, struct bio *src,
                        goto err;
                break;
        }
-       case BCH_COMPRESSION_ZSTD: {
+       case BCH_COMPRESSION_TYPE_zstd: {
                ZSTD_DCtx *ctx;
                size_t len;
 
@@ -290,10 +290,10 @@ static int attempt_compress(struct bch_fs *c,
                            void *workspace,
                            void *dst, size_t dst_len,
                            void *src, size_t src_len,
-                           unsigned compression_type)
+                           enum bch_compression_type compression_type)
 {
        switch (compression_type) {
-       case BCH_COMPRESSION_LZ4: {
+       case BCH_COMPRESSION_TYPE_lz4: {
                int len = src_len;
                int ret = LZ4_compress_destSize(
                                src,            dst,
@@ -305,7 +305,7 @@ static int attempt_compress(struct bch_fs *c,
 
                return ret;
        }
-       case BCH_COMPRESSION_GZIP: {
+       case BCH_COMPRESSION_TYPE_gzip: {
                z_stream strm = {
                        .next_in        = src,
                        .avail_in       = src_len,
@@ -326,7 +326,7 @@ static int attempt_compress(struct bch_fs *c,
 
                return strm.total_out;
        }
-       case BCH_COMPRESSION_ZSTD: {
+       case BCH_COMPRESSION_TYPE_zstd: {
                ZSTD_CCtx *ctx = zstd_init_cctx(workspace,
                        zstd_cctx_workspace_bound(&c->zstd_params.cParams));
 
@@ -348,14 +348,14 @@ static int attempt_compress(struct bch_fs *c,
 static unsigned __bio_compress(struct bch_fs *c,
                               struct bio *dst, size_t *dst_len,
                               struct bio *src, size_t *src_len,
-                              unsigned compression_type)
+                              enum bch_compression_type compression_type)
 {
        struct bbuf src_data = { NULL }, dst_data = { NULL };
        void *workspace;
        unsigned pad;
        int ret = 0;
 
-       BUG_ON(compression_type >= BCH_COMPRESSION_NR);
+       BUG_ON(compression_type >= BCH_COMPRESSION_TYPE_NR);
        BUG_ON(!mempool_initialized(&c->compress_workspace[compression_type]));
 
        /* If it's only one block, don't bother trying to compress: */
@@ -452,8 +452,8 @@ unsigned bch2_bio_compress(struct bch_fs *c,
        /* Don't generate a bigger output than input: */
        dst->bi_iter.bi_size = min(dst->bi_iter.bi_size, src->bi_iter.bi_size);
 
-       if (compression_type == BCH_COMPRESSION_LZ4_OLD)
-               compression_type = BCH_COMPRESSION_LZ4;
+       if (compression_type == BCH_COMPRESSION_TYPE_lz4_old)
+               compression_type = BCH_COMPRESSION_TYPE_lz4;
 
        compression_type =
                __bio_compress(c, dst, dst_len, src, src_len, compression_type);
@@ -465,15 +465,15 @@ unsigned bch2_bio_compress(struct bch_fs *c,
 
 static int __bch2_fs_compress_init(struct bch_fs *, u64);
 
-#define BCH_FEATURE_NONE       0
+#define BCH_FEATURE_none       0
 
 static const unsigned bch2_compression_opt_to_feature[] = {
-#define x(t) [BCH_COMPRESSION_OPT_##t] = BCH_FEATURE_##t,
-       BCH_COMPRESSION_TYPES()
+#define x(t, n) [BCH_COMPRESSION_OPT_##t] = BCH_FEATURE_##t,
+       BCH_COMPRESSION_OPTS()
 #undef x
 };
 
-#undef BCH_FEATURE_NONE
+#undef BCH_FEATURE_none
 
 static int __bch2_check_set_has_compressed_data(struct bch_fs *c, u64 f)
 {
@@ -537,11 +537,11 @@ static int __bch2_fs_compress_init(struct bch_fs *c, u64 features)
                size_t          compress_workspace;
                size_t          decompress_workspace;
        } compression_types[] = {
-               { BCH_FEATURE_LZ4, BCH_COMPRESSION_LZ4, LZ4_MEM_COMPRESS, 0 },
-               { BCH_FEATURE_GZIP, BCH_COMPRESSION_GZIP,
+               { BCH_FEATURE_lz4, BCH_COMPRESSION_TYPE_lz4, LZ4_MEM_COMPRESS, 0 },
+               { BCH_FEATURE_gzip, BCH_COMPRESSION_TYPE_gzip,
                        zlib_deflate_workspacesize(MAX_WBITS, DEF_MEM_LEVEL),
                        zlib_inflate_workspacesize(), },
-               { BCH_FEATURE_ZSTD, BCH_COMPRESSION_ZSTD,
+               { BCH_FEATURE_zstd, BCH_COMPRESSION_TYPE_zstd,
                        zstd_cctx_workspace_bound(&params.cParams),
                        zstd_dctx_workspace_bound() },
        }, *i;
index b85056440ac3b4e1f02fae4bf13a9cb8a82b5fcd..8322b043bdffd4519d6ef41f2077ca171b27c0e0 100644 (file)
@@ -613,7 +613,7 @@ unsigned bch2_bkey_nr_ptrs_fully_allocated(struct bkey_s_c k)
 
                bkey_for_each_ptr_decode(k.k, ptrs, p, entry)
                        ret += !p.ptr.cached &&
-                               p.crc.compression_type == BCH_COMPRESSION_NONE;
+                               p.crc.compression_type == BCH_COMPRESSION_TYPE_none;
        }
 
        return ret;
@@ -628,7 +628,7 @@ unsigned bch2_bkey_sectors_compressed(struct bkey_s_c k)
 
        bkey_for_each_ptr_decode(k.k, ptrs, p, entry)
                if (!p.ptr.cached &&
-                   p.crc.compression_type != BCH_COMPRESSION_NONE)
+                   p.crc.compression_type != BCH_COMPRESSION_TYPE_none)
                        ret += p.crc.compressed_size;
 
        return ret;
@@ -1053,7 +1053,7 @@ const char *bch2_bkey_ptrs_invalid(const struct bch_fs *c, struct bkey_s_c k)
                        if (!bch2_checksum_type_valid(c, crc.csum_type))
                                return "invalid checksum type";
 
-                       if (crc.compression_type >= BCH_COMPRESSION_NR)
+                       if (crc.compression_type >= BCH_COMPRESSION_TYPE_NR)
                                return "invalid compression type";
 
                        if (bch2_csum_type_is_encryption(crc.csum_type)) {
index cd230dc109841d7a435e21df317151c4626bc0d0..e25f064706ad431084772ef336a240c0d2945026 100644 (file)
@@ -1124,7 +1124,7 @@ static int check_inode_nlink(struct bch_fs *c,
 
        if (!link->count &&
            !(u->bi_flags & BCH_INODE_UNLINKED) &&
-           (c->sb.features & (1 << BCH_FEATURE_ATOMIC_NLINK))) {
+           (c->sb.features & (1 << BCH_FEATURE_atomic_nlink))) {
                if (fsck_err(c, "unreachable inode %llu not marked as unlinked (type %u)",
                             u->bi_inum, mode_to_type(u->bi_mode)) ==
                    FSCK_ERR_IGNORE)
@@ -1159,7 +1159,7 @@ static int check_inode_nlink(struct bch_fs *c,
        }
 
        if (i_nlink != real_i_nlink &&
-           (c->sb.features & (1 << BCH_FEATURE_ATOMIC_NLINK))) {
+           (c->sb.features & (1 << BCH_FEATURE_atomic_nlink))) {
                if (fsck_err(c, "inode %llu has wrong i_nlink "
                             "(type %u i_nlink %u, should be %u)",
                             u->bi_inum, mode_to_type(u->bi_mode),
index dd8f356f3ef0375c267316965f2e3d704ed79770..ba79b35a130f032969c62593300bde9125630b05 100644 (file)
@@ -1141,7 +1141,7 @@ static void bch2_write_data_inline(struct bch_write_op *op, unsigned data_len)
        unsigned sectors;
        int ret;
 
-       bch2_check_set_feature(op->c, BCH_FEATURE_INLINE_DATA);
+       bch2_check_set_feature(op->c, BCH_FEATURE_inline_data);
 
        ret = bch2_keylist_realloc(&op->insert_keys, op->inline_keys,
                                   ARRAY_SIZE(op->inline_keys),
@@ -1788,7 +1788,7 @@ static void __bch2_read_endio(struct work_struct *work)
        crc.offset     += rbio->offset_into_extent;
        crc.live_size   = bvec_iter_sectors(rbio->bvec_iter);
 
-       if (crc.compression_type != BCH_COMPRESSION_NONE) {
+       if (crc.compression_type != BCH_COMPRESSION_TYPE_none) {
                bch2_encrypt_bio(c, crc.csum_type, nonce, src);
                if (bch2_bio_uncompress(c, src, dst, dst_iter, crc))
                        goto decompression_err;
@@ -1996,7 +1996,7 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig,
 
        EBUG_ON(offset_into_extent + bvec_iter_sectors(iter) > k.k->size);
 
-       if (pick.crc.compression_type != BCH_COMPRESSION_NONE ||
+       if (pick.crc.compression_type != BCH_COMPRESSION_TYPE_none ||
            (pick.crc.csum_type != BCH_CSUM_NONE &&
             (bvec_iter_sectors(iter) != pick.crc.uncompressed_size ||
              (bch2_csum_type_is_encryption(pick.crc.csum_type) &&
index 787d9f7638d05f82b6a73f3d034f053f21752563..a21de00887535723b2f7ff06265b42bf35142463 100644 (file)
@@ -121,7 +121,7 @@ int bch2_journal_seq_blacklist_add(struct bch_fs *c, u64 start, u64 end)
        bl->start[nr].end       = cpu_to_le64(end);
 out_write_sb:
        c->disk_sb.sb->features[0] |=
-               1ULL << BCH_FEATURE_JOURNAL_SEQ_BLACKLIST_V3;
+               1ULL << BCH_FEATURE_journal_seq_blacklist_v3;
 
        ret = bch2_write_super(c);
 out:
@@ -309,7 +309,7 @@ void bch2_blacklist_entries_gc(struct work_struct *work)
 
                if (!new_nr)
                        c->disk_sb.sb->features[0] &=
-                               ~(1ULL << BCH_FEATURE_JOURNAL_SEQ_BLACKLIST_V3);
+                               ~(1ULL << BCH_FEATURE_journal_seq_blacklist_v3);
 
                bch2_write_super(c);
        }
index 261e465341cdb92ccd96a643f5bbfbc2724facb7..cb7bb751b7b5aa9c3a6ad7909857cb2ac0899f24 100644 (file)
@@ -271,7 +271,7 @@ int bch2_migrate_write_init(struct bch_fs *c, struct migrate_write *m,
 
                bkey_for_each_ptr_decode(k.k, ptrs, p, entry)
                        if (!p.ptr.cached &&
-                           p.crc.compression_type != BCH_COMPRESSION_NONE &&
+                           p.crc.compression_type != BCH_COMPRESSION_TYPE_none &&
                            bch2_dev_in_target(c, p.ptr.dev, data_opts.target))
                                compressed_sectors += p.crc.compressed_size;
 
index cbacd2f36799bdf265181d381b6858540bfd7b15..94d6c044a27daa935ed9dec7c01c2456fcdc20fa 100644 (file)
@@ -16,18 +16,24 @@ const char * const bch2_error_actions[] = {
        NULL
 };
 
-const char * const bch2_csum_types[] = {
+const char * const bch2_sb_features[] = {
+#define x(f, n) #f,
+       BCH_SB_FEATURES()
+#undef x
+       NULL
+};
+
+const char * const bch2_csum_opts[] = {
        "none",
        "crc32c",
        "crc64",
        NULL
 };
 
-const char * const bch2_compression_types[] = {
-       "none",
-       "lz4",
-       "gzip",
-       "zstd",
+const char * const bch2_compression_opts[] = {
+#define x(t, n) #t,
+       BCH_COMPRESSION_OPTS()
+#undef x
        NULL
 };
 
@@ -300,7 +306,7 @@ int bch2_opt_check_may_set(struct bch_fs *c, int id, u64 v)
                break;
        case Opt_erasure_code:
                if (v)
-                       bch2_check_set_feature(c, BCH_FEATURE_EC);
+                       bch2_check_set_feature(c, BCH_FEATURE_ec);
                break;
        }
 
index 92a9b7e0f47fcbbd819a10454ac22cc18a8f8507..59c7b36857455ebdc45a0d41c142e84dad90f3fa 100644 (file)
@@ -9,8 +9,9 @@
 #include "bcachefs_format.h"
 
 extern const char * const bch2_error_actions[];
-extern const char * const bch2_csum_types[];
-extern const char * const bch2_compression_types[];
+extern const char * const bch2_sb_features[];
+extern const char * const bch2_csum_opts[];
+extern const char * const bch2_compression_opts[];
 extern const char * const bch2_str_hash_types[];
 extern const char * const bch2_data_types[];
 extern const char * const bch2_cache_replacement_policies[];
@@ -112,23 +113,23 @@ enum opt_type {
          "#",          NULL)                                           \
        x(metadata_checksum,            u8,                             \
          OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                             \
-         OPT_STR(bch2_csum_types),                                     \
+         OPT_STR(bch2_csum_opts),                                      \
          BCH_SB_META_CSUM_TYPE,        BCH_CSUM_OPT_CRC32C,            \
          NULL,         NULL)                                           \
        x(data_checksum,                u8,                             \
          OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE,                   \
-         OPT_STR(bch2_csum_types),                                     \
+         OPT_STR(bch2_csum_opts),                                      \
          BCH_SB_DATA_CSUM_TYPE,        BCH_CSUM_OPT_CRC32C,            \
          NULL,         NULL)                                           \
        x(compression,                  u8,                             \
          OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE,                   \
-         OPT_STR(bch2_compression_types),                              \
-         BCH_SB_COMPRESSION_TYPE,      BCH_COMPRESSION_OPT_NONE,       \
+         OPT_STR(bch2_compression_opts),                               \
+         BCH_SB_COMPRESSION_TYPE,      BCH_COMPRESSION_OPT_none,       \
          NULL,         NULL)                                           \
        x(background_compression,       u8,                             \
          OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE,                   \
-         OPT_STR(bch2_compression_types),                              \
-         BCH_SB_BACKGROUND_COMPRESSION_TYPE,BCH_COMPRESSION_OPT_NONE,  \
+         OPT_STR(bch2_compression_opts),                               \
+         BCH_SB_BACKGROUND_COMPRESSION_TYPE,BCH_COMPRESSION_OPT_none,  \
          NULL,         NULL)                                           \
        x(str_hash,                     u8,                             \
          OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME,                             \
index 9c90d2bbb7cc4a42993e004e4561e61ef6fca5f7..97b367252e821ca2dbcce0529c8728c9abc40027 100644 (file)
@@ -866,7 +866,7 @@ int bch2_fs_recovery(struct bch_fs *c)
        }
 
        if (!c->sb.clean) {
-               if (!(c->sb.features & (1 << BCH_FEATURE_ATOMIC_NLINK))) {
+               if (!(c->sb.features & (1 << BCH_FEATURE_atomic_nlink))) {
                        bch_info(c, "checking inode link counts");
                        err = "error in recovery";
                        ret = bch2_fsck_inode_nlink(c);
@@ -907,6 +907,7 @@ int bch2_fs_recovery(struct bch_fs *c)
                        c->disk_sb.sb->version_min =
                                le16_to_cpu(bcachefs_metadata_version_min);
                c->disk_sb.sb->version = le16_to_cpu(bcachefs_metadata_version_current);
+               c->disk_sb.sb->features[0] |= 1ULL << BCH_FEATURE_new_siphash;
                write_sb = true;
        }
 
@@ -917,7 +918,7 @@ int bch2_fs_recovery(struct bch_fs *c)
 
        if (c->opts.fsck &&
            !test_bit(BCH_FS_ERROR, &c->flags)) {
-               c->disk_sb.sb->features[0] |= 1ULL << BCH_FEATURE_ATOMIC_NLINK;
+               c->disk_sb.sb->features[0] |= 1ULL << BCH_FEATURE_atomic_nlink;
                SET_BCH_SB_HAS_ERRORS(c->disk_sb.sb, 0);
                write_sb = true;
        }
@@ -1024,7 +1025,8 @@ int bch2_fs_initialize(struct bch_fs *c)
        mutex_lock(&c->sb_lock);
        c->disk_sb.sb->version = c->disk_sb.sb->version_min =
                le16_to_cpu(bcachefs_metadata_version_current);
-       c->disk_sb.sb->features[0] |= 1ULL << BCH_FEATURE_ATOMIC_NLINK;
+       c->disk_sb.sb->features[0] |= 1ULL << BCH_FEATURE_atomic_nlink;
+       c->disk_sb.sb->features[0] |= 1ULL << BCH_FEATURE_new_siphash;
 
        SET_BCH_SB_INITIALIZED(c->disk_sb.sb, true);
        SET_BCH_SB_CLEAN(c->disk_sb.sb, false);
index 5cad39fe031f6d9e3d1a62eaf1b27749f21b78f5..2bf003ba3bd8b7cb9ae50e537cb9d9b590afb90d 100644 (file)
@@ -171,7 +171,7 @@ s64 bch2_remap_range(struct bch_fs *c,
        if (!percpu_ref_tryget(&c->writes))
                return -EROFS;
 
-       bch2_check_set_feature(c, BCH_FEATURE_REFLINK);
+       bch2_check_set_feature(c, BCH_FEATURE_reflink);
 
        dst_end.offset += remap_sectors;
        src_end.offset += remap_sectors;
index 7be4a8e50eaaac513f62697f46db12889b7d7767..3870df2d58ce68041ec40f1bd0e5f792b1a603d5 100644 (file)
@@ -23,7 +23,7 @@ bch2_str_hash_opt_to_type(struct bch_fs *c, enum bch_str_hash_opts opt)
        case BCH_STR_HASH_OPT_CRC64:
                return BCH_STR_HASH_CRC64;
        case BCH_STR_HASH_OPT_SIPHASH:
-               return c->sb.features & (1ULL << BCH_FEATURE_NEW_SIPHASH)
+               return c->sb.features & (1ULL << BCH_FEATURE_new_siphash)
                        ? BCH_STR_HASH_SIPHASH
                        : BCH_STR_HASH_SIPHASH_OLD;
        default:
index 767fd7bed2d0fbfaa414ef8232d25b082c529ba1..d3713db317cef86ba775f0e0391e9561f8361072 100644 (file)
@@ -276,7 +276,7 @@ static ssize_t bch2_compression_stats(struct bch_fs *c, char *buf)
                        struct extent_ptr_decoded p;
 
                        extent_for_each_ptr_decode(e, p, entry) {
-                               if (p.crc.compression_type == BCH_COMPRESSION_NONE) {
+                               if (p.crc.compression_type == BCH_COMPRESSION_TYPE_none) {
                                        nr_uncompressed_extents++;
                                        uncompressed_sectors += e.k->size;
                                } else {