Commit 1c3ff72c authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Convert some enums to x-macros

Helps for preventing things from getting out of sync.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 27b3e523
...@@ -718,7 +718,7 @@ struct bch_fs { ...@@ -718,7 +718,7 @@ struct bch_fs {
struct rhashtable promote_table; struct rhashtable promote_table;
mempool_t compression_bounce[2]; mempool_t compression_bounce[2];
mempool_t compress_workspace[BCH_COMPRESSION_NR]; mempool_t compress_workspace[BCH_COMPRESSION_TYPE_NR];
mempool_t decompress_workspace; mempool_t decompress_workspace;
ZSTD_parameters zstd_params; ZSTD_parameters zstd_params;
......
...@@ -436,47 +436,6 @@ struct bch_csum { ...@@ -436,47 +436,6 @@ struct bch_csum {
__le64 hi; __le64 hi;
} __attribute__((packed, aligned(8))); } __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() \ #define BCH_EXTENT_ENTRY_TYPES() \
x(ptr, 0) \ x(ptr, 0) \
x(crc32, 1) \ x(crc32, 1) \
...@@ -1320,17 +1279,29 @@ LE64_BITMASK(BCH_SB_GC_RESERVE_BYTES, struct bch_sb, flags[2], 4, 64); ...@@ -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); LE64_BITMASK(BCH_SB_ERASURE_CODE, struct bch_sb, flags[3], 0, 16);
/* Features: */ /*
enum bch_sb_features { * Features:
BCH_FEATURE_LZ4 = 0, *
BCH_FEATURE_GZIP = 1, * journal_seq_blacklist_v3: gates BCH_SB_FIELD_journal_seq_blacklist
BCH_FEATURE_ZSTD = 2, * reflink: gates KEY_TYPE_reflink
BCH_FEATURE_ATOMIC_NLINK = 3, /* should have gone under compat */ * inline_data: gates KEY_TYPE_inline_data
BCH_FEATURE_EC = 4, * new_siphash: gates BCH_STR_HASH_SIPHASH
BCH_FEATURE_JOURNAL_SEQ_BLACKLIST_V3 = 5, */
BCH_FEATURE_REFLINK = 6, #define BCH_SB_FEATURES() \
BCH_FEATURE_NEW_SIPHASH = 7, x(lz4, 0) \
BCH_FEATURE_INLINE_DATA = 8, 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, BCH_FEATURE_NR,
}; };
...@@ -1350,13 +1321,6 @@ enum bch_error_actions { ...@@ -1350,13 +1321,6 @@ enum bch_error_actions {
BCH_NR_ERROR_ACTIONS = 3, 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 { enum bch_str_hash_type {
BCH_STR_HASH_CRC32C = 0, BCH_STR_HASH_CRC32C = 0,
BCH_STR_HASH_CRC64 = 1, BCH_STR_HASH_CRC64 = 1,
...@@ -1372,15 +1336,68 @@ enum bch_str_hash_opts { ...@@ -1372,15 +1336,68 @@ enum bch_str_hash_opts {
BCH_STR_HASH_OPT_NR = 3, 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() \ #define BCH_COMPRESSION_TYPES() \
x(NONE) \ x(none, 0) \
x(LZ4) \ x(lz4_old, 1) \
x(GZIP) \ x(gzip, 2) \
x(ZSTD) x(lz4, 3) \
x(zstd, 4)
enum bch_compression_opts { enum bch_compression_type {
#define x(t) BCH_COMPRESSION_OPT_##t, #define x(t, n) BCH_COMPRESSION_TYPE_##t,
BCH_COMPRESSION_TYPES() 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 #undef x
BCH_COMPRESSION_OPT_NR BCH_COMPRESSION_OPT_NR
}; };
......
...@@ -108,8 +108,8 @@ static inline enum bch_csum_type bch2_meta_checksum_type(struct bch_fs *c) ...@@ -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[] = { static const unsigned bch2_compression_opt_to_type[] = {
#define x(t) [BCH_COMPRESSION_OPT_##t] = BCH_COMPRESSION_##t, #define x(t, n) [BCH_COMPRESSION_OPT_##t] = BCH_COMPRESSION_TYPE_##t,
BCH_COMPRESSION_TYPES() BCH_COMPRESSION_OPTS()
#undef x #undef x
}; };
......
...@@ -158,14 +158,14 @@ static int __bio_uncompress(struct bch_fs *c, struct bio *src, ...@@ -158,14 +158,14 @@ static int __bio_uncompress(struct bch_fs *c, struct bio *src,
src_data = bio_map_or_bounce(c, src, READ); src_data = bio_map_or_bounce(c, src, READ);
switch (crc.compression_type) { switch (crc.compression_type) {
case BCH_COMPRESSION_LZ4_OLD: case BCH_COMPRESSION_TYPE_lz4_old:
case BCH_COMPRESSION_LZ4: case BCH_COMPRESSION_TYPE_lz4:
ret = LZ4_decompress_safe_partial(src_data.b, dst_data, ret = LZ4_decompress_safe_partial(src_data.b, dst_data,
src_len, dst_len, dst_len); src_len, dst_len, dst_len);
if (ret != dst_len) if (ret != dst_len)
goto err; goto err;
break; break;
case BCH_COMPRESSION_GZIP: { case BCH_COMPRESSION_TYPE_gzip: {
z_stream strm = { z_stream strm = {
.next_in = src_data.b, .next_in = src_data.b,
.avail_in = src_len, .avail_in = src_len,
...@@ -185,7 +185,7 @@ static int __bio_uncompress(struct bch_fs *c, struct bio *src, ...@@ -185,7 +185,7 @@ static int __bio_uncompress(struct bch_fs *c, struct bio *src,
goto err; goto err;
break; break;
} }
case BCH_COMPRESSION_ZSTD: { case BCH_COMPRESSION_TYPE_zstd: {
ZSTD_DCtx *ctx; ZSTD_DCtx *ctx;
size_t len; size_t len;
...@@ -290,10 +290,10 @@ static int attempt_compress(struct bch_fs *c, ...@@ -290,10 +290,10 @@ static int attempt_compress(struct bch_fs *c,
void *workspace, void *workspace,
void *dst, size_t dst_len, void *dst, size_t dst_len,
void *src, size_t src_len, void *src, size_t src_len,
unsigned compression_type) enum bch_compression_type compression_type)
{ {
switch (compression_type) { switch (compression_type) {
case BCH_COMPRESSION_LZ4: { case BCH_COMPRESSION_TYPE_lz4: {
int len = src_len; int len = src_len;
int ret = LZ4_compress_destSize( int ret = LZ4_compress_destSize(
src, dst, src, dst,
...@@ -305,7 +305,7 @@ static int attempt_compress(struct bch_fs *c, ...@@ -305,7 +305,7 @@ static int attempt_compress(struct bch_fs *c,
return ret; return ret;
} }
case BCH_COMPRESSION_GZIP: { case BCH_COMPRESSION_TYPE_gzip: {
z_stream strm = { z_stream strm = {
.next_in = src, .next_in = src,
.avail_in = src_len, .avail_in = src_len,
...@@ -326,7 +326,7 @@ static int attempt_compress(struct bch_fs *c, ...@@ -326,7 +326,7 @@ static int attempt_compress(struct bch_fs *c,
return strm.total_out; return strm.total_out;
} }
case BCH_COMPRESSION_ZSTD: { case BCH_COMPRESSION_TYPE_zstd: {
ZSTD_CCtx *ctx = zstd_init_cctx(workspace, ZSTD_CCtx *ctx = zstd_init_cctx(workspace,
zstd_cctx_workspace_bound(&c->zstd_params.cParams)); zstd_cctx_workspace_bound(&c->zstd_params.cParams));
...@@ -348,14 +348,14 @@ static int attempt_compress(struct bch_fs *c, ...@@ -348,14 +348,14 @@ static int attempt_compress(struct bch_fs *c,
static unsigned __bio_compress(struct bch_fs *c, static unsigned __bio_compress(struct bch_fs *c,
struct bio *dst, size_t *dst_len, struct bio *dst, size_t *dst_len,
struct bio *src, size_t *src_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 }; struct bbuf src_data = { NULL }, dst_data = { NULL };
void *workspace; void *workspace;
unsigned pad; unsigned pad;
int ret = 0; 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])); BUG_ON(!mempool_initialized(&c->compress_workspace[compression_type]));
/* If it's only one block, don't bother trying to compress: */ /* If it's only one block, don't bother trying to compress: */
...@@ -452,8 +452,8 @@ unsigned bch2_bio_compress(struct bch_fs *c, ...@@ -452,8 +452,8 @@ unsigned bch2_bio_compress(struct bch_fs *c,
/* Don't generate a bigger output than input: */ /* Don't generate a bigger output than input: */
dst->bi_iter.bi_size = min(dst->bi_iter.bi_size, src->bi_iter.bi_size); dst->bi_iter.bi_size = min(dst->bi_iter.bi_size, src->bi_iter.bi_size);
if (compression_type == BCH_COMPRESSION_LZ4_OLD) if (compression_type == BCH_COMPRESSION_TYPE_lz4_old)
compression_type = BCH_COMPRESSION_LZ4; compression_type = BCH_COMPRESSION_TYPE_lz4;
compression_type = compression_type =
__bio_compress(c, dst, dst_len, src, src_len, 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, ...@@ -465,15 +465,15 @@ unsigned bch2_bio_compress(struct bch_fs *c,
static int __bch2_fs_compress_init(struct bch_fs *, u64); 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[] = { static const unsigned bch2_compression_opt_to_feature[] = {
#define x(t) [BCH_COMPRESSION_OPT_##t] = BCH_FEATURE_##t, #define x(t, n) [BCH_COMPRESSION_OPT_##t] = BCH_FEATURE_##t,
BCH_COMPRESSION_TYPES() BCH_COMPRESSION_OPTS()
#undef x #undef x
}; };
#undef BCH_FEATURE_NONE #undef BCH_FEATURE_none
static int __bch2_check_set_has_compressed_data(struct bch_fs *c, u64 f) 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) ...@@ -537,11 +537,11 @@ static int __bch2_fs_compress_init(struct bch_fs *c, u64 features)
size_t compress_workspace; size_t compress_workspace;
size_t decompress_workspace; size_t decompress_workspace;
} compression_types[] = { } compression_types[] = {
{ BCH_FEATURE_LZ4, BCH_COMPRESSION_LZ4, LZ4_MEM_COMPRESS, 0 }, { BCH_FEATURE_lz4, BCH_COMPRESSION_TYPE_lz4, LZ4_MEM_COMPRESS, 0 },
{ BCH_FEATURE_GZIP, BCH_COMPRESSION_GZIP, { BCH_FEATURE_gzip, BCH_COMPRESSION_TYPE_gzip,
zlib_deflate_workspacesize(MAX_WBITS, DEF_MEM_LEVEL), zlib_deflate_workspacesize(MAX_WBITS, DEF_MEM_LEVEL),
zlib_inflate_workspacesize(), }, zlib_inflate_workspacesize(), },
{ BCH_FEATURE_ZSTD, BCH_COMPRESSION_ZSTD, { BCH_FEATURE_zstd, BCH_COMPRESSION_TYPE_zstd,
zstd_cctx_workspace_bound(&params.cParams), zstd_cctx_workspace_bound(&params.cParams),
zstd_dctx_workspace_bound() }, zstd_dctx_workspace_bound() },
}, *i; }, *i;
......
...@@ -613,7 +613,7 @@ unsigned bch2_bkey_nr_ptrs_fully_allocated(struct bkey_s_c k) ...@@ -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) bkey_for_each_ptr_decode(k.k, ptrs, p, entry)
ret += !p.ptr.cached && ret += !p.ptr.cached &&
p.crc.compression_type == BCH_COMPRESSION_NONE; p.crc.compression_type == BCH_COMPRESSION_TYPE_none;
} }
return ret; return ret;
...@@ -628,7 +628,7 @@ unsigned bch2_bkey_sectors_compressed(struct bkey_s_c k) ...@@ -628,7 +628,7 @@ unsigned bch2_bkey_sectors_compressed(struct bkey_s_c k)
bkey_for_each_ptr_decode(k.k, ptrs, p, entry) bkey_for_each_ptr_decode(k.k, ptrs, p, entry)
if (!p.ptr.cached && if (!p.ptr.cached &&
p.crc.compression_type != BCH_COMPRESSION_NONE) p.crc.compression_type != BCH_COMPRESSION_TYPE_none)
ret += p.crc.compressed_size; ret += p.crc.compressed_size;
return ret; return ret;
...@@ -1053,7 +1053,7 @@ const char *bch2_bkey_ptrs_invalid(const struct bch_fs *c, struct bkey_s_c k) ...@@ -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)) if (!bch2_checksum_type_valid(c, crc.csum_type))
return "invalid checksum type"; return "invalid checksum type";
if (crc.compression_type >= BCH_COMPRESSION_NR) if (crc.compression_type >= BCH_COMPRESSION_TYPE_NR)
return "invalid compression type"; return "invalid compression type";
if (bch2_csum_type_is_encryption(crc.csum_type)) { if (bch2_csum_type_is_encryption(crc.csum_type)) {
......
...@@ -1124,7 +1124,7 @@ static int check_inode_nlink(struct bch_fs *c, ...@@ -1124,7 +1124,7 @@ static int check_inode_nlink(struct bch_fs *c,
if (!link->count && if (!link->count &&
!(u->bi_flags & BCH_INODE_UNLINKED) && !(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)", if (fsck_err(c, "unreachable inode %llu not marked as unlinked (type %u)",
u->bi_inum, mode_to_type(u->bi_mode)) == u->bi_inum, mode_to_type(u->bi_mode)) ==
FSCK_ERR_IGNORE) FSCK_ERR_IGNORE)
...@@ -1159,7 +1159,7 @@ static int check_inode_nlink(struct bch_fs *c, ...@@ -1159,7 +1159,7 @@ static int check_inode_nlink(struct bch_fs *c,
} }
if (i_nlink != real_i_nlink && 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 " if (fsck_err(c, "inode %llu has wrong i_nlink "
"(type %u i_nlink %u, should be %u)", "(type %u i_nlink %u, should be %u)",
u->bi_inum, mode_to_type(u->bi_mode), u->bi_inum, mode_to_type(u->bi_mode),
......
...@@ -1141,7 +1141,7 @@ static void bch2_write_data_inline(struct bch_write_op *op, unsigned data_len) ...@@ -1141,7 +1141,7 @@ static void bch2_write_data_inline(struct bch_write_op *op, unsigned data_len)
unsigned sectors; unsigned sectors;
int ret; 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, ret = bch2_keylist_realloc(&op->insert_keys, op->inline_keys,
ARRAY_SIZE(op->inline_keys), ARRAY_SIZE(op->inline_keys),
...@@ -1788,7 +1788,7 @@ static void __bch2_read_endio(struct work_struct *work) ...@@ -1788,7 +1788,7 @@ static void __bch2_read_endio(struct work_struct *work)
crc.offset += rbio->offset_into_extent; crc.offset += rbio->offset_into_extent;
crc.live_size = bvec_iter_sectors(rbio->bvec_iter); 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); bch2_encrypt_bio(c, crc.csum_type, nonce, src);
if (bch2_bio_uncompress(c, src, dst, dst_iter, crc)) if (bch2_bio_uncompress(c, src, dst, dst_iter, crc))
goto decompression_err; goto decompression_err;
...@@ -1996,7 +1996,7 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig, ...@@ -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); 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 && (pick.crc.csum_type != BCH_CSUM_NONE &&
(bvec_iter_sectors(iter) != pick.crc.uncompressed_size || (bvec_iter_sectors(iter) != pick.crc.uncompressed_size ||
(bch2_csum_type_is_encryption(pick.crc.csum_type) && (bch2_csum_type_is_encryption(pick.crc.csum_type) &&
......
...@@ -121,7 +121,7 @@ int bch2_journal_seq_blacklist_add(struct bch_fs *c, u64 start, u64 end) ...@@ -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); bl->start[nr].end = cpu_to_le64(end);
out_write_sb: out_write_sb:
c->disk_sb.sb->features[0] |= 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); ret = bch2_write_super(c);
out: out:
...@@ -309,7 +309,7 @@ void bch2_blacklist_entries_gc(struct work_struct *work) ...@@ -309,7 +309,7 @@ void bch2_blacklist_entries_gc(struct work_struct *work)
if (!new_nr) if (!new_nr)
c->disk_sb.sb->features[0] &= c->disk_sb.sb->features[0] &=
~(1ULL << BCH_FEATURE_JOURNAL_SEQ_BLACKLIST_V3); ~(1ULL << BCH_FEATURE_journal_seq_blacklist_v3);
bch2_write_super(c); bch2_write_super(c);
} }
......
...@@ -271,7 +271,7 @@ int bch2_migrate_write_init(struct bch_fs *c, struct migrate_write *m, ...@@ -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) bkey_for_each_ptr_decode(k.k, ptrs, p, entry)
if (!p.ptr.cached && 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)) bch2_dev_in_target(c, p.ptr.dev, data_opts.target))
compressed_sectors += p.crc.compressed_size; compressed_sectors += p.crc.compressed_size;
......
...@@ -16,18 +16,24 @@ const char * const bch2_error_actions[] = { ...@@ -16,18 +16,24 @@ const char * const bch2_error_actions[] = {
NULL 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", "none",
"crc32c", "crc32c",
"crc64", "crc64",
NULL NULL
}; };
const char * const bch2_compression_types[] = { const char * const bch2_compression_opts[] = {
"none", #define x(t, n) #t,
"lz4", BCH_COMPRESSION_OPTS()
"gzip", #undef x
"zstd",
NULL NULL
}; };
...@@ -300,7 +306,7 @@ int bch2_opt_check_may_set(struct bch_fs *c, int id, u64 v) ...@@ -300,7 +306,7 @@ int bch2_opt_check_may_set(struct bch_fs *c, int id, u64 v)
break; break;
case Opt_erasure_code: case Opt_erasure_code:
if (v) if (v)
bch2_check_set_feature(c, BCH_FEATURE_EC); bch2_check_set_feature(c, BCH_FEATURE_ec);
break; break;
} }
......
...@@ -9,8 +9,9 @@ ...@@ -9,8 +9,9 @@
#include "bcachefs_format.h" #include "bcachefs_format.h"
extern const char * const bch2_error_actions[]; extern const char * const bch2_error_actions[];
extern const char * const bch2_csum_types[]; extern const char * const bch2_sb_features[];
extern const char * const bch2_compression_types[]; 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_str_hash_types[];
extern const char * const bch2_data_types[]; extern const char * const bch2_data_types[];
extern const char * const bch2_cache_replacement_policies[]; extern const char * const bch2_cache_replacement_policies[];
...@@ -112,23 +113,23 @@ enum opt_type { ...@@ -112,23 +113,23 @@ enum opt_type {
"#", NULL) \ "#", NULL) \
x(metadata_checksum, u8, \ x(metadata_checksum, u8, \
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \ 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, \ BCH_SB_META_CSUM_TYPE, BCH_CSUM_OPT_CRC32C, \
NULL, NULL) \ NULL, NULL) \
x(data_checksum, u8, \ x(data_checksum, u8, \
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \ 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, \ BCH_SB_DATA_CSUM_TYPE, BCH_CSUM_OPT_CRC32C, \
NULL, NULL) \ NULL, NULL) \
x(compression, u8, \ x(compression, u8, \
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \ OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
OPT_STR(bch2_compression_types), \ OPT_STR(bch2_compression_opts), \
BCH_SB_COMPRESSION_TYPE, BCH_COMPRESSION_OPT_NONE, \ BCH_SB_COMPRESSION_TYPE, BCH_COMPRESSION_OPT_none, \
NULL, NULL) \ NULL, NULL) \
x(background_compression, u8, \ x(background_compression, u8, \
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \ OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME|OPT_INODE, \
OPT_STR(bch2_compression_types), \ OPT_STR(bch2_compression_opts), \
BCH_SB_BACKGROUND_COMPRESSION_TYPE,BCH_COMPRESSION_OPT_NONE, \ BCH_SB_BACKGROUND_COMPRESSION_TYPE,BCH_COMPRESSION_OPT_none, \
NULL, NULL) \ NULL, NULL) \
x(str_hash, u8, \ x(str_hash, u8, \
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \ OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
......
...@@ -866,7 +866,7 @@ int bch2_fs_recovery(struct bch_fs *c) ...@@ -866,7 +866,7 @@ int bch2_fs_recovery(struct bch_fs *c)
} }
if (!c->sb.clean) { 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"); bch_info(c, "checking inode link counts");
err = "error in recovery"; err = "error in recovery";
ret = bch2_fsck_inode_nlink(c); ret = bch2_fsck_inode_nlink(c);
...@@ -907,6 +907,7 @@ int bch2_fs_recovery(struct bch_fs *c) ...@@ -907,6 +907,7 @@ int bch2_fs_recovery(struct bch_fs *c)
c->disk_sb.sb->version_min = c->disk_sb.sb->version_min =
le16_to_cpu(bcachefs_metadata_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->version = le16_to_cpu(bcachefs_metadata_version_current);
c->disk_sb.sb->features[0] |= 1ULL << BCH_FEATURE_new_siphash;
write_sb = true; write_sb = true;
} }
...@@ -917,7 +918,7 @@ int bch2_fs_recovery(struct bch_fs *c) ...@@ -917,7 +918,7 @@ int bch2_fs_recovery(struct bch_fs *c)
if (c->opts.fsck && if (c->opts.fsck &&
!test_bit(BCH_FS_ERROR, &c->flags)) { !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); SET_BCH_SB_HAS_ERRORS(c->disk_sb.sb, 0);
write_sb = true; write_sb = true;
} }
...@@ -1024,7 +1025,8 @@ int bch2_fs_initialize(struct bch_fs *c) ...@@ -1024,7 +1025,8 @@ int bch2_fs_initialize(struct bch_fs *c)
mutex_lock(&c->sb_lock); mutex_lock(&c->sb_lock);
c->disk_sb.sb->version = c->disk_sb.sb->version_min = c->disk_sb.sb->version = c->disk_sb.sb->version_min =
le16_to_cpu(bcachefs_metadata_version_current); 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_INITIALIZED(c->disk_sb.sb, true);
SET_BCH_SB_CLEAN(c->disk_sb.sb, false); SET_BCH_SB_CLEAN(c->disk_sb.sb, false);
......
...@@ -171,7 +171,7 @@ s64 bch2_remap_range(struct bch_fs *c, ...@@ -171,7 +171,7 @@ s64 bch2_remap_range(struct bch_fs *c,
if (!percpu_ref_tryget(&c->writes)) if (!percpu_ref_tryget(&c->writes))
return -EROFS; return -EROFS;
bch2_check_set_feature(c, BCH_FEATURE_REFLINK); bch2_check_set_feature(c, BCH_FEATURE_reflink);
dst_end.offset += remap_sectors; dst_end.offset += remap_sectors;
src_end.offset += remap_sectors; src_end.offset += remap_sectors;
......
...@@ -23,7 +23,7 @@ bch2_str_hash_opt_to_type(struct bch_fs *c, enum bch_str_hash_opts opt) ...@@ -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: case BCH_STR_HASH_OPT_CRC64:
return BCH_STR_HASH_CRC64; return BCH_STR_HASH_CRC64;
case BCH_STR_HASH_OPT_SIPHASH: 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
: BCH_STR_HASH_SIPHASH_OLD; : BCH_STR_HASH_SIPHASH_OLD;
default: default:
......
...@@ -276,7 +276,7 @@ static ssize_t bch2_compression_stats(struct bch_fs *c, char *buf) ...@@ -276,7 +276,7 @@ static ssize_t bch2_compression_stats(struct bch_fs *c, char *buf)
struct extent_ptr_decoded p; struct extent_ptr_decoded p;
extent_for_each_ptr_decode(e, p, entry) { 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++; nr_uncompressed_extents++;
uncompressed_sectors += e.k->size; uncompressed_sectors += e.k->size;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment