bcachefs: INODE_STR_HASH() for bch_inode_unpacked
Trivial cleanup - add a normal BITMASK() helper for bch_inode_unpacked. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
b96f8cd387
commit
78cf0ae636
@ -163,8 +163,8 @@ static noinline int bch2_inode_unpack_v1(struct bkey_s_c_inode inode,
|
|||||||
unsigned fieldnr = 0, field_bits;
|
unsigned fieldnr = 0, field_bits;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#define x(_name, _bits) \
|
#define x(_name, _bits) \
|
||||||
if (fieldnr++ == INODE_NR_FIELDS(inode.v)) { \
|
if (fieldnr++ == INODEv1_NR_FIELDS(inode.v)) { \
|
||||||
unsigned offset = offsetof(struct bch_inode_unpacked, _name);\
|
unsigned offset = offsetof(struct bch_inode_unpacked, _name);\
|
||||||
memset((void *) unpacked + offset, 0, \
|
memset((void *) unpacked + offset, 0, \
|
||||||
sizeof(*unpacked) - offset); \
|
sizeof(*unpacked) - offset); \
|
||||||
@ -293,10 +293,10 @@ static noinline int bch2_inode_unpack_slowpath(struct bkey_s_c k,
|
|||||||
unpacked->bi_flags = le32_to_cpu(inode.v->bi_flags);
|
unpacked->bi_flags = le32_to_cpu(inode.v->bi_flags);
|
||||||
unpacked->bi_mode = le16_to_cpu(inode.v->bi_mode);
|
unpacked->bi_mode = le16_to_cpu(inode.v->bi_mode);
|
||||||
|
|
||||||
if (INODE_NEW_VARINT(inode.v)) {
|
if (INODEv1_NEW_VARINT(inode.v)) {
|
||||||
return bch2_inode_unpack_v2(unpacked, inode.v->fields,
|
return bch2_inode_unpack_v2(unpacked, inode.v->fields,
|
||||||
bkey_val_end(inode),
|
bkey_val_end(inode),
|
||||||
INODE_NR_FIELDS(inode.v));
|
INODEv1_NR_FIELDS(inode.v));
|
||||||
} else {
|
} else {
|
||||||
return bch2_inode_unpack_v1(inode, unpacked);
|
return bch2_inode_unpack_v1(inode, unpacked);
|
||||||
}
|
}
|
||||||
@ -471,10 +471,10 @@ int bch2_inode_validate(struct bch_fs *c, struct bkey_s_c k,
|
|||||||
struct bkey_s_c_inode inode = bkey_s_c_to_inode(k);
|
struct bkey_s_c_inode inode = bkey_s_c_to_inode(k);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
bkey_fsck_err_on(INODE_STR_HASH(inode.v) >= BCH_STR_HASH_NR,
|
bkey_fsck_err_on(INODEv1_STR_HASH(inode.v) >= BCH_STR_HASH_NR,
|
||||||
c, inode_str_hash_invalid,
|
c, inode_str_hash_invalid,
|
||||||
"invalid str hash type (%llu >= %u)",
|
"invalid str hash type (%llu >= %u)",
|
||||||
INODE_STR_HASH(inode.v), BCH_STR_HASH_NR);
|
INODEv1_STR_HASH(inode.v), BCH_STR_HASH_NR);
|
||||||
|
|
||||||
ret = __bch2_inode_validate(c, k, flags);
|
ret = __bch2_inode_validate(c, k, flags);
|
||||||
fsck_err:
|
fsck_err:
|
||||||
@ -800,10 +800,8 @@ void bch2_inode_init_early(struct bch_fs *c,
|
|||||||
|
|
||||||
memset(inode_u, 0, sizeof(*inode_u));
|
memset(inode_u, 0, sizeof(*inode_u));
|
||||||
|
|
||||||
/* ick */
|
SET_INODE_STR_HASH(inode_u, str_hash);
|
||||||
inode_u->bi_flags |= str_hash << INODE_STR_HASH_OFFSET;
|
get_random_bytes(&inode_u->bi_hash_seed, sizeof(inode_u->bi_hash_seed));
|
||||||
get_random_bytes(&inode_u->bi_hash_seed,
|
|
||||||
sizeof(inode_u->bi_hash_seed));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bch2_inode_init_late(struct bch_inode_unpacked *inode_u, u64 now,
|
void bch2_inode_init_late(struct bch_inode_unpacked *inode_u, u64 now,
|
||||||
|
@ -92,6 +92,7 @@ struct bch_inode_unpacked {
|
|||||||
BCH_INODE_FIELDS_v3()
|
BCH_INODE_FIELDS_v3()
|
||||||
#undef x
|
#undef x
|
||||||
};
|
};
|
||||||
|
BITMASK(INODE_STR_HASH, struct bch_inode_unpacked, bi_flags, 20, 24);
|
||||||
|
|
||||||
struct bkey_inode_buf {
|
struct bkey_inode_buf {
|
||||||
struct bkey_i_inode_v3 inode;
|
struct bkey_i_inode_v3 inode;
|
||||||
|
@ -150,9 +150,9 @@ enum __bch_inode_flags {
|
|||||||
#undef x
|
#undef x
|
||||||
};
|
};
|
||||||
|
|
||||||
LE32_BITMASK(INODE_STR_HASH, struct bch_inode, bi_flags, 20, 24);
|
LE32_BITMASK(INODEv1_STR_HASH, struct bch_inode, bi_flags, 20, 24);
|
||||||
LE32_BITMASK(INODE_NR_FIELDS, struct bch_inode, bi_flags, 24, 31);
|
LE32_BITMASK(INODEv1_NR_FIELDS, struct bch_inode, bi_flags, 24, 31);
|
||||||
LE32_BITMASK(INODE_NEW_VARINT, struct bch_inode, bi_flags, 31, 32);
|
LE32_BITMASK(INODEv1_NEW_VARINT,struct bch_inode, bi_flags, 31, 32);
|
||||||
|
|
||||||
LE64_BITMASK(INODEv2_STR_HASH, struct bch_inode_v2, bi_flags, 20, 24);
|
LE64_BITMASK(INODEv2_STR_HASH, struct bch_inode_v2, bi_flags, 20, 24);
|
||||||
LE64_BITMASK(INODEv2_NR_FIELDS, struct bch_inode_v2, bi_flags, 24, 31);
|
LE64_BITMASK(INODEv2_NR_FIELDS, struct bch_inode_v2, bi_flags, 24, 31);
|
||||||
|
@ -46,8 +46,7 @@ bch2_hash_info_init(struct bch_fs *c, const struct bch_inode_unpacked *bi)
|
|||||||
{
|
{
|
||||||
/* XXX ick */
|
/* XXX ick */
|
||||||
struct bch_hash_info info = {
|
struct bch_hash_info info = {
|
||||||
.type = (bi->bi_flags >> INODE_STR_HASH_OFFSET) &
|
.type = INODE_STR_HASH(bi),
|
||||||
~(~0U << INODE_STR_HASH_BITS),
|
|
||||||
.siphash_key = { .k0 = bi->bi_hash_seed }
|
.siphash_key = { .k0 = bi->bi_hash_seed }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user