bcachefs: More enum strings
This patch converts more enums in the on disk format to our standard x-macro-with-strings deal - to enable better pretty-printing. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
e3f2db39b3
commit
6404dcc9c2
@ -1447,7 +1447,7 @@ LE64_BITMASK(BCH_SB_INODES_USE_KEY_CACHE,struct bch_sb, flags[3], 29, 30);
|
|||||||
* journal_seq_blacklist_v3: gates BCH_SB_FIELD_journal_seq_blacklist
|
* journal_seq_blacklist_v3: gates BCH_SB_FIELD_journal_seq_blacklist
|
||||||
* reflink: gates KEY_TYPE_reflink
|
* reflink: gates KEY_TYPE_reflink
|
||||||
* inline_data: gates KEY_TYPE_inline_data
|
* inline_data: gates KEY_TYPE_inline_data
|
||||||
* new_siphash: gates BCH_STR_HASH_SIPHASH
|
* new_siphash: gates BCH_STR_HASH_siphash
|
||||||
* new_extent_overwrite: gates BTREE_NODE_NEW_EXTENT_OVERWRITE
|
* new_extent_overwrite: gates BTREE_NODE_NEW_EXTENT_OVERWRITE
|
||||||
*/
|
*/
|
||||||
#define BCH_SB_FEATURES() \
|
#define BCH_SB_FEATURES() \
|
||||||
@ -1523,12 +1523,17 @@ enum bch_error_actions {
|
|||||||
BCH_ON_ERROR_NR
|
BCH_ON_ERROR_NR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define BCH_STR_HASH_TYPES() \
|
||||||
|
x(crc32c, 0) \
|
||||||
|
x(crc64, 1) \
|
||||||
|
x(siphash_old, 2) \
|
||||||
|
x(siphash, 3)
|
||||||
|
|
||||||
enum bch_str_hash_type {
|
enum bch_str_hash_type {
|
||||||
BCH_STR_HASH_CRC32C = 0,
|
#define x(t, n) BCH_STR_HASH_##t = n,
|
||||||
BCH_STR_HASH_CRC64 = 1,
|
BCH_STR_HASH_TYPES()
|
||||||
BCH_STR_HASH_SIPHASH_OLD = 2,
|
#undef x
|
||||||
BCH_STR_HASH_SIPHASH = 3,
|
BCH_STR_HASH_NR
|
||||||
BCH_STR_HASH_NR = 4,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BCH_STR_HASH_OPTS() \
|
#define BCH_STR_HASH_OPTS() \
|
||||||
@ -1543,34 +1548,39 @@ enum bch_str_hash_opts {
|
|||||||
BCH_STR_HASH_OPT_NR
|
BCH_STR_HASH_OPT_NR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define BCH_CSUM_TYPES() \
|
||||||
|
x(none, 0) \
|
||||||
|
x(crc32c_nonzero, 1) \
|
||||||
|
x(crc64_nonzero, 2) \
|
||||||
|
x(chacha20_poly1305_80, 3) \
|
||||||
|
x(chacha20_poly1305_128, 4) \
|
||||||
|
x(crc32c, 5) \
|
||||||
|
x(crc64, 6) \
|
||||||
|
x(xxhash, 7)
|
||||||
|
|
||||||
enum bch_csum_type {
|
enum bch_csum_type {
|
||||||
BCH_CSUM_NONE = 0,
|
#define x(t, n) BCH_CSUM_##t = n,
|
||||||
BCH_CSUM_CRC32C_NONZERO = 1,
|
BCH_CSUM_TYPES()
|
||||||
BCH_CSUM_CRC64_NONZERO = 2,
|
#undef x
|
||||||
BCH_CSUM_CHACHA20_POLY1305_80 = 3,
|
BCH_CSUM_NR
|
||||||
BCH_CSUM_CHACHA20_POLY1305_128 = 4,
|
|
||||||
BCH_CSUM_CRC32C = 5,
|
|
||||||
BCH_CSUM_CRC64 = 6,
|
|
||||||
BCH_CSUM_XXHASH = 7,
|
|
||||||
BCH_CSUM_NR = 8,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned bch_crc_bytes[] = {
|
static const unsigned bch_crc_bytes[] = {
|
||||||
[BCH_CSUM_NONE] = 0,
|
[BCH_CSUM_none] = 0,
|
||||||
[BCH_CSUM_CRC32C_NONZERO] = 4,
|
[BCH_CSUM_crc32c_nonzero] = 4,
|
||||||
[BCH_CSUM_CRC32C] = 4,
|
[BCH_CSUM_crc32c] = 4,
|
||||||
[BCH_CSUM_CRC64_NONZERO] = 8,
|
[BCH_CSUM_crc64_nonzero] = 8,
|
||||||
[BCH_CSUM_CRC64] = 8,
|
[BCH_CSUM_crc64] = 8,
|
||||||
[BCH_CSUM_XXHASH] = 8,
|
[BCH_CSUM_xxhash] = 8,
|
||||||
[BCH_CSUM_CHACHA20_POLY1305_80] = 10,
|
[BCH_CSUM_chacha20_poly1305_80] = 10,
|
||||||
[BCH_CSUM_CHACHA20_POLY1305_128] = 16,
|
[BCH_CSUM_chacha20_poly1305_128] = 16,
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline _Bool bch2_csum_type_is_encryption(enum bch_csum_type type)
|
static inline _Bool bch2_csum_type_is_encryption(enum bch_csum_type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BCH_CSUM_CHACHA20_POLY1305_80:
|
case BCH_CSUM_chacha20_poly1305_80:
|
||||||
case BCH_CSUM_CHACHA20_POLY1305_128:
|
case BCH_CSUM_chacha20_poly1305_128:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -35,18 +35,18 @@ struct bch2_checksum_state {
|
|||||||
static void bch2_checksum_init(struct bch2_checksum_state *state)
|
static void bch2_checksum_init(struct bch2_checksum_state *state)
|
||||||
{
|
{
|
||||||
switch (state->type) {
|
switch (state->type) {
|
||||||
case BCH_CSUM_NONE:
|
case BCH_CSUM_none:
|
||||||
case BCH_CSUM_CRC32C:
|
case BCH_CSUM_crc32c:
|
||||||
case BCH_CSUM_CRC64:
|
case BCH_CSUM_crc64:
|
||||||
state->seed = 0;
|
state->seed = 0;
|
||||||
break;
|
break;
|
||||||
case BCH_CSUM_CRC32C_NONZERO:
|
case BCH_CSUM_crc32c_nonzero:
|
||||||
state->seed = U32_MAX;
|
state->seed = U32_MAX;
|
||||||
break;
|
break;
|
||||||
case BCH_CSUM_CRC64_NONZERO:
|
case BCH_CSUM_crc64_nonzero:
|
||||||
state->seed = U64_MAX;
|
state->seed = U64_MAX;
|
||||||
break;
|
break;
|
||||||
case BCH_CSUM_XXHASH:
|
case BCH_CSUM_xxhash:
|
||||||
xxh64_reset(&state->h64state, 0);
|
xxh64_reset(&state->h64state, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -57,15 +57,15 @@ static void bch2_checksum_init(struct bch2_checksum_state *state)
|
|||||||
static u64 bch2_checksum_final(const struct bch2_checksum_state *state)
|
static u64 bch2_checksum_final(const struct bch2_checksum_state *state)
|
||||||
{
|
{
|
||||||
switch (state->type) {
|
switch (state->type) {
|
||||||
case BCH_CSUM_NONE:
|
case BCH_CSUM_none:
|
||||||
case BCH_CSUM_CRC32C:
|
case BCH_CSUM_crc32c:
|
||||||
case BCH_CSUM_CRC64:
|
case BCH_CSUM_crc64:
|
||||||
return state->seed;
|
return state->seed;
|
||||||
case BCH_CSUM_CRC32C_NONZERO:
|
case BCH_CSUM_crc32c_nonzero:
|
||||||
return state->seed ^ U32_MAX;
|
return state->seed ^ U32_MAX;
|
||||||
case BCH_CSUM_CRC64_NONZERO:
|
case BCH_CSUM_crc64_nonzero:
|
||||||
return state->seed ^ U64_MAX;
|
return state->seed ^ U64_MAX;
|
||||||
case BCH_CSUM_XXHASH:
|
case BCH_CSUM_xxhash:
|
||||||
return xxh64_digest(&state->h64state);
|
return xxh64_digest(&state->h64state);
|
||||||
default:
|
default:
|
||||||
BUG();
|
BUG();
|
||||||
@ -75,17 +75,17 @@ static u64 bch2_checksum_final(const struct bch2_checksum_state *state)
|
|||||||
static void bch2_checksum_update(struct bch2_checksum_state *state, const void *data, size_t len)
|
static void bch2_checksum_update(struct bch2_checksum_state *state, const void *data, size_t len)
|
||||||
{
|
{
|
||||||
switch (state->type) {
|
switch (state->type) {
|
||||||
case BCH_CSUM_NONE:
|
case BCH_CSUM_none:
|
||||||
return;
|
return;
|
||||||
case BCH_CSUM_CRC32C_NONZERO:
|
case BCH_CSUM_crc32c_nonzero:
|
||||||
case BCH_CSUM_CRC32C:
|
case BCH_CSUM_crc32c:
|
||||||
state->seed = crc32c(state->seed, data, len);
|
state->seed = crc32c(state->seed, data, len);
|
||||||
break;
|
break;
|
||||||
case BCH_CSUM_CRC64_NONZERO:
|
case BCH_CSUM_crc64_nonzero:
|
||||||
case BCH_CSUM_CRC64:
|
case BCH_CSUM_crc64:
|
||||||
state->seed = crc64_be(state->seed, data, len);
|
state->seed = crc64_be(state->seed, data, len);
|
||||||
break;
|
break;
|
||||||
case BCH_CSUM_XXHASH:
|
case BCH_CSUM_xxhash:
|
||||||
xxh64_update(&state->h64state, data, len);
|
xxh64_update(&state->h64state, data, len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -161,12 +161,12 @@ struct bch_csum bch2_checksum(struct bch_fs *c, unsigned type,
|
|||||||
struct nonce nonce, const void *data, size_t len)
|
struct nonce nonce, const void *data, size_t len)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BCH_CSUM_NONE:
|
case BCH_CSUM_none:
|
||||||
case BCH_CSUM_CRC32C_NONZERO:
|
case BCH_CSUM_crc32c_nonzero:
|
||||||
case BCH_CSUM_CRC64_NONZERO:
|
case BCH_CSUM_crc64_nonzero:
|
||||||
case BCH_CSUM_CRC32C:
|
case BCH_CSUM_crc32c:
|
||||||
case BCH_CSUM_XXHASH:
|
case BCH_CSUM_xxhash:
|
||||||
case BCH_CSUM_CRC64: {
|
case BCH_CSUM_crc64: {
|
||||||
struct bch2_checksum_state state;
|
struct bch2_checksum_state state;
|
||||||
|
|
||||||
state.type = type;
|
state.type = type;
|
||||||
@ -177,8 +177,8 @@ struct bch_csum bch2_checksum(struct bch_fs *c, unsigned type,
|
|||||||
return (struct bch_csum) { .lo = cpu_to_le64(bch2_checksum_final(&state)) };
|
return (struct bch_csum) { .lo = cpu_to_le64(bch2_checksum_final(&state)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
case BCH_CSUM_CHACHA20_POLY1305_80:
|
case BCH_CSUM_chacha20_poly1305_80:
|
||||||
case BCH_CSUM_CHACHA20_POLY1305_128: {
|
case BCH_CSUM_chacha20_poly1305_128: {
|
||||||
SHASH_DESC_ON_STACK(desc, c->poly1305);
|
SHASH_DESC_ON_STACK(desc, c->poly1305);
|
||||||
u8 digest[POLY1305_DIGEST_SIZE];
|
u8 digest[POLY1305_DIGEST_SIZE];
|
||||||
struct bch_csum ret = { 0 };
|
struct bch_csum ret = { 0 };
|
||||||
@ -212,13 +212,13 @@ static struct bch_csum __bch2_checksum_bio(struct bch_fs *c, unsigned type,
|
|||||||
struct bio_vec bv;
|
struct bio_vec bv;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BCH_CSUM_NONE:
|
case BCH_CSUM_none:
|
||||||
return (struct bch_csum) { 0 };
|
return (struct bch_csum) { 0 };
|
||||||
case BCH_CSUM_CRC32C_NONZERO:
|
case BCH_CSUM_crc32c_nonzero:
|
||||||
case BCH_CSUM_CRC64_NONZERO:
|
case BCH_CSUM_crc64_nonzero:
|
||||||
case BCH_CSUM_CRC32C:
|
case BCH_CSUM_crc32c:
|
||||||
case BCH_CSUM_XXHASH:
|
case BCH_CSUM_xxhash:
|
||||||
case BCH_CSUM_CRC64: {
|
case BCH_CSUM_crc64: {
|
||||||
struct bch2_checksum_state state;
|
struct bch2_checksum_state state;
|
||||||
|
|
||||||
state.type = type;
|
state.type = type;
|
||||||
@ -238,8 +238,8 @@ static struct bch_csum __bch2_checksum_bio(struct bch_fs *c, unsigned type,
|
|||||||
return (struct bch_csum) { .lo = cpu_to_le64(bch2_checksum_final(&state)) };
|
return (struct bch_csum) { .lo = cpu_to_le64(bch2_checksum_final(&state)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
case BCH_CSUM_CHACHA20_POLY1305_80:
|
case BCH_CSUM_chacha20_poly1305_80:
|
||||||
case BCH_CSUM_CHACHA20_POLY1305_128: {
|
case BCH_CSUM_chacha20_poly1305_128: {
|
||||||
SHASH_DESC_ON_STACK(desc, c->poly1305);
|
SHASH_DESC_ON_STACK(desc, c->poly1305);
|
||||||
u8 digest[POLY1305_DIGEST_SIZE];
|
u8 digest[POLY1305_DIGEST_SIZE];
|
||||||
struct bch_csum ret = { 0 };
|
struct bch_csum ret = { 0 };
|
||||||
|
@ -13,9 +13,9 @@ static inline bool bch2_checksum_mergeable(unsigned type)
|
|||||||
{
|
{
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BCH_CSUM_NONE:
|
case BCH_CSUM_none:
|
||||||
case BCH_CSUM_CRC32C:
|
case BCH_CSUM_crc32c:
|
||||||
case BCH_CSUM_CRC64:
|
case BCH_CSUM_crc64:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@ -78,13 +78,13 @@ static inline enum bch_csum_type bch2_csum_opt_to_type(enum bch_csum_opts type,
|
|||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BCH_CSUM_OPT_none:
|
case BCH_CSUM_OPT_none:
|
||||||
return BCH_CSUM_NONE;
|
return BCH_CSUM_none;
|
||||||
case BCH_CSUM_OPT_crc32c:
|
case BCH_CSUM_OPT_crc32c:
|
||||||
return data ? BCH_CSUM_CRC32C : BCH_CSUM_CRC32C_NONZERO;
|
return data ? BCH_CSUM_crc32c : BCH_CSUM_crc32c_nonzero;
|
||||||
case BCH_CSUM_OPT_crc64:
|
case BCH_CSUM_OPT_crc64:
|
||||||
return data ? BCH_CSUM_CRC64 : BCH_CSUM_CRC64_NONZERO;
|
return data ? BCH_CSUM_crc64 : BCH_CSUM_crc64_nonzero;
|
||||||
case BCH_CSUM_OPT_xxhash:
|
case BCH_CSUM_OPT_xxhash:
|
||||||
return BCH_CSUM_XXHASH;
|
return BCH_CSUM_xxhash;
|
||||||
default:
|
default:
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
@ -95,8 +95,8 @@ static inline enum bch_csum_type bch2_data_checksum_type(struct bch_fs *c,
|
|||||||
{
|
{
|
||||||
if (c->sb.encryption_type)
|
if (c->sb.encryption_type)
|
||||||
return c->opts.wide_macs
|
return c->opts.wide_macs
|
||||||
? BCH_CSUM_CHACHA20_POLY1305_128
|
? BCH_CSUM_chacha20_poly1305_128
|
||||||
: BCH_CSUM_CHACHA20_POLY1305_80;
|
: BCH_CSUM_chacha20_poly1305_80;
|
||||||
|
|
||||||
return bch2_csum_opt_to_type(opt, true);
|
return bch2_csum_opt_to_type(opt, true);
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ static inline enum bch_csum_type bch2_data_checksum_type(struct bch_fs *c,
|
|||||||
static inline enum bch_csum_type bch2_meta_checksum_type(struct bch_fs *c)
|
static inline enum bch_csum_type bch2_meta_checksum_type(struct bch_fs *c)
|
||||||
{
|
{
|
||||||
if (c->sb.encryption_type)
|
if (c->sb.encryption_type)
|
||||||
return BCH_CSUM_CHACHA20_POLY1305_128;
|
return BCH_CSUM_chacha20_poly1305_128;
|
||||||
|
|
||||||
return bch2_csum_opt_to_type(c->opts.metadata_checksum, false);
|
return bch2_csum_opt_to_type(c->opts.metadata_checksum, false);
|
||||||
}
|
}
|
||||||
|
@ -1154,7 +1154,7 @@ static void ec_stripe_key_init(struct bch_fs *c,
|
|||||||
s->v.nr_blocks = nr_data + nr_parity;
|
s->v.nr_blocks = nr_data + nr_parity;
|
||||||
s->v.nr_redundant = nr_parity;
|
s->v.nr_redundant = nr_parity;
|
||||||
s->v.csum_granularity_bits = ilog2(c->sb.encoded_extent_max);
|
s->v.csum_granularity_bits = ilog2(c->sb.encoded_extent_max);
|
||||||
s->v.csum_type = BCH_CSUM_CRC32C;
|
s->v.csum_type = BCH_CSUM_crc32c;
|
||||||
s->v.pad = 0;
|
s->v.pad = 0;
|
||||||
|
|
||||||
while ((u64s = stripe_val_u64s(&s->v)) > BKEY_VAL_U64s_MAX) {
|
while ((u64s = stripe_val_u64s(&s->v)) > BKEY_VAL_U64s_MAX) {
|
||||||
|
@ -968,12 +968,12 @@ void bch2_bkey_ptrs_to_text(struct printbuf *out, struct bch_fs *c,
|
|||||||
case BCH_EXTENT_ENTRY_crc128:
|
case BCH_EXTENT_ENTRY_crc128:
|
||||||
crc = bch2_extent_crc_unpack(k.k, entry_to_crc(entry));
|
crc = bch2_extent_crc_unpack(k.k, entry_to_crc(entry));
|
||||||
|
|
||||||
pr_buf(out, "crc: c_size %u size %u offset %u nonce %u csum %u compress %u",
|
pr_buf(out, "crc: c_size %u size %u offset %u nonce %u csum %s compress %s",
|
||||||
crc.compressed_size,
|
crc.compressed_size,
|
||||||
crc.uncompressed_size,
|
crc.uncompressed_size,
|
||||||
crc.offset, crc.nonce,
|
crc.offset, crc.nonce,
|
||||||
crc.csum_type,
|
bch2_csum_types[crc.csum_type],
|
||||||
crc.compression_type);
|
bch2_compression_types[crc.compression_type]);
|
||||||
break;
|
break;
|
||||||
case BCH_EXTENT_ENTRY_stripe_ptr:
|
case BCH_EXTENT_ENTRY_stripe_ptr:
|
||||||
ec = &entry->stripe_ptr;
|
ec = &entry->stripe_ptr;
|
||||||
|
@ -2104,7 +2104,7 @@ int __bch2_read_extent(struct btree_trans *trans, 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 (crc_is_compressed(pick.crc) ||
|
if (crc_is_compressed(pick.crc) ||
|
||||||
(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) &&
|
||||||
(flags & BCH_READ_USER_MAPPED)) ||
|
(flags & BCH_READ_USER_MAPPED)) ||
|
||||||
|
@ -31,17 +31,32 @@ const char * const bch2_btree_ids[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char * const bch2_csum_types[] = {
|
||||||
|
BCH_CSUM_TYPES()
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
const char * const bch2_csum_opts[] = {
|
const char * const bch2_csum_opts[] = {
|
||||||
BCH_CSUM_OPTS()
|
BCH_CSUM_OPTS()
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char * const bch2_compression_types[] = {
|
||||||
|
BCH_COMPRESSION_TYPES()
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
const char * const bch2_compression_opts[] = {
|
const char * const bch2_compression_opts[] = {
|
||||||
BCH_COMPRESSION_OPTS()
|
BCH_COMPRESSION_OPTS()
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
const char * const bch2_str_hash_types[] = {
|
const char * const bch2_str_hash_types[] = {
|
||||||
|
BCH_STR_HASH_TYPES()
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
const char * const bch2_str_hash_opts[] = {
|
||||||
BCH_STR_HASH_OPTS()
|
BCH_STR_HASH_OPTS()
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
@ -12,9 +12,12 @@ extern const char * const bch2_error_actions[];
|
|||||||
extern const char * const bch2_sb_features[];
|
extern const char * const bch2_sb_features[];
|
||||||
extern const char * const bch2_sb_compat[];
|
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_csum_opts[];
|
||||||
|
extern const char * const bch2_compression_types[];
|
||||||
extern const char * const bch2_compression_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_str_hash_opts[];
|
||||||
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[];
|
||||||
extern const char * const bch2_member_states[];
|
extern const char * const bch2_member_states[];
|
||||||
@ -140,7 +143,7 @@ enum opt_type {
|
|||||||
NULL, NULL) \
|
NULL, NULL) \
|
||||||
x(str_hash, u8, \
|
x(str_hash, u8, \
|
||||||
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
OPT_FORMAT|OPT_MOUNT|OPT_RUNTIME, \
|
||||||
OPT_STR(bch2_str_hash_types), \
|
OPT_STR(bch2_str_hash_opts), \
|
||||||
BCH_SB_STR_HASH_TYPE, BCH_STR_HASH_OPT_siphash, \
|
BCH_SB_STR_HASH_TYPE, BCH_STR_HASH_OPT_siphash, \
|
||||||
NULL, "Hash function for directory entries and xattrs")\
|
NULL, "Hash function for directory entries and xattrs")\
|
||||||
x(metadata_target, u16, \
|
x(metadata_target, u16, \
|
||||||
|
@ -20,13 +20,13 @@ bch2_str_hash_opt_to_type(struct bch_fs *c, enum bch_str_hash_opts opt)
|
|||||||
{
|
{
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case BCH_STR_HASH_OPT_crc32c:
|
case BCH_STR_HASH_OPT_crc32c:
|
||||||
return BCH_STR_HASH_CRC32C;
|
return BCH_STR_HASH_crc32c;
|
||||||
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:
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ bch2_hash_info_init(struct bch_fs *c, const struct bch_inode_unpacked *bi)
|
|||||||
.siphash_key = { .k0 = bi->bi_hash_seed }
|
.siphash_key = { .k0 = bi->bi_hash_seed }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (unlikely(info.type == BCH_STR_HASH_SIPHASH_OLD)) {
|
if (unlikely(info.type == BCH_STR_HASH_siphash_old)) {
|
||||||
SHASH_DESC_ON_STACK(desc, c->sha256);
|
SHASH_DESC_ON_STACK(desc, c->sha256);
|
||||||
u8 digest[SHA256_DIGEST_SIZE];
|
u8 digest[SHA256_DIGEST_SIZE];
|
||||||
|
|
||||||
@ -77,16 +77,16 @@ static inline void bch2_str_hash_init(struct bch_str_hash_ctx *ctx,
|
|||||||
const struct bch_hash_info *info)
|
const struct bch_hash_info *info)
|
||||||
{
|
{
|
||||||
switch (info->type) {
|
switch (info->type) {
|
||||||
case BCH_STR_HASH_CRC32C:
|
case BCH_STR_HASH_crc32c:
|
||||||
ctx->crc32c = crc32c(~0, &info->siphash_key.k0,
|
ctx->crc32c = crc32c(~0, &info->siphash_key.k0,
|
||||||
sizeof(info->siphash_key.k0));
|
sizeof(info->siphash_key.k0));
|
||||||
break;
|
break;
|
||||||
case BCH_STR_HASH_CRC64:
|
case BCH_STR_HASH_crc64:
|
||||||
ctx->crc64 = crc64_be(~0, &info->siphash_key.k0,
|
ctx->crc64 = crc64_be(~0, &info->siphash_key.k0,
|
||||||
sizeof(info->siphash_key.k0));
|
sizeof(info->siphash_key.k0));
|
||||||
break;
|
break;
|
||||||
case BCH_STR_HASH_SIPHASH_OLD:
|
case BCH_STR_HASH_siphash_old:
|
||||||
case BCH_STR_HASH_SIPHASH:
|
case BCH_STR_HASH_siphash:
|
||||||
SipHash24_Init(&ctx->siphash, &info->siphash_key);
|
SipHash24_Init(&ctx->siphash, &info->siphash_key);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -99,14 +99,14 @@ static inline void bch2_str_hash_update(struct bch_str_hash_ctx *ctx,
|
|||||||
const void *data, size_t len)
|
const void *data, size_t len)
|
||||||
{
|
{
|
||||||
switch (info->type) {
|
switch (info->type) {
|
||||||
case BCH_STR_HASH_CRC32C:
|
case BCH_STR_HASH_crc32c:
|
||||||
ctx->crc32c = crc32c(ctx->crc32c, data, len);
|
ctx->crc32c = crc32c(ctx->crc32c, data, len);
|
||||||
break;
|
break;
|
||||||
case BCH_STR_HASH_CRC64:
|
case BCH_STR_HASH_crc64:
|
||||||
ctx->crc64 = crc64_be(ctx->crc64, data, len);
|
ctx->crc64 = crc64_be(ctx->crc64, data, len);
|
||||||
break;
|
break;
|
||||||
case BCH_STR_HASH_SIPHASH_OLD:
|
case BCH_STR_HASH_siphash_old:
|
||||||
case BCH_STR_HASH_SIPHASH:
|
case BCH_STR_HASH_siphash:
|
||||||
SipHash24_Update(&ctx->siphash, data, len);
|
SipHash24_Update(&ctx->siphash, data, len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -118,12 +118,12 @@ static inline u64 bch2_str_hash_end(struct bch_str_hash_ctx *ctx,
|
|||||||
const struct bch_hash_info *info)
|
const struct bch_hash_info *info)
|
||||||
{
|
{
|
||||||
switch (info->type) {
|
switch (info->type) {
|
||||||
case BCH_STR_HASH_CRC32C:
|
case BCH_STR_HASH_crc32c:
|
||||||
return ctx->crc32c;
|
return ctx->crc32c;
|
||||||
case BCH_STR_HASH_CRC64:
|
case BCH_STR_HASH_crc64:
|
||||||
return ctx->crc64 >> 1;
|
return ctx->crc64 >> 1;
|
||||||
case BCH_STR_HASH_SIPHASH_OLD:
|
case BCH_STR_HASH_siphash_old:
|
||||||
case BCH_STR_HASH_SIPHASH:
|
case BCH_STR_HASH_siphash:
|
||||||
return SipHash24_End(&ctx->siphash) >> 1;
|
return SipHash24_End(&ctx->siphash) >> 1;
|
||||||
default:
|
default:
|
||||||
BUG();
|
BUG();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user