Skip to content

Commit 78cf0ae

Browse files
author
Kent Overstreet
committed
bcachefs: INODE_STR_HASH() for bch_inode_unpacked
Trivial cleanup - add a normal BITMASK() helper for bch_inode_unpacked. Signed-off-by: Kent Overstreet <[email protected]>
1 parent b96f8cd commit 78cf0ae

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

fs/bcachefs/inode.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ static noinline int bch2_inode_unpack_v1(struct bkey_s_c_inode inode,
163163
unsigned fieldnr = 0, field_bits;
164164
int ret;
165165

166-
#define x(_name, _bits) \
167-
if (fieldnr++ == INODE_NR_FIELDS(inode.v)) { \
166+
#define x(_name, _bits) \
167+
if (fieldnr++ == INODEv1_NR_FIELDS(inode.v)) { \
168168
unsigned offset = offsetof(struct bch_inode_unpacked, _name);\
169169
memset((void *) unpacked + offset, 0, \
170170
sizeof(*unpacked) - offset); \
@@ -293,10 +293,10 @@ static noinline int bch2_inode_unpack_slowpath(struct bkey_s_c k,
293293
unpacked->bi_flags = le32_to_cpu(inode.v->bi_flags);
294294
unpacked->bi_mode = le16_to_cpu(inode.v->bi_mode);
295295

296-
if (INODE_NEW_VARINT(inode.v)) {
296+
if (INODEv1_NEW_VARINT(inode.v)) {
297297
return bch2_inode_unpack_v2(unpacked, inode.v->fields,
298298
bkey_val_end(inode),
299-
INODE_NR_FIELDS(inode.v));
299+
INODEv1_NR_FIELDS(inode.v));
300300
} else {
301301
return bch2_inode_unpack_v1(inode, unpacked);
302302
}
@@ -471,10 +471,10 @@ int bch2_inode_validate(struct bch_fs *c, struct bkey_s_c k,
471471
struct bkey_s_c_inode inode = bkey_s_c_to_inode(k);
472472
int ret = 0;
473473

474-
bkey_fsck_err_on(INODE_STR_HASH(inode.v) >= BCH_STR_HASH_NR,
474+
bkey_fsck_err_on(INODEv1_STR_HASH(inode.v) >= BCH_STR_HASH_NR,
475475
c, inode_str_hash_invalid,
476476
"invalid str hash type (%llu >= %u)",
477-
INODE_STR_HASH(inode.v), BCH_STR_HASH_NR);
477+
INODEv1_STR_HASH(inode.v), BCH_STR_HASH_NR);
478478

479479
ret = __bch2_inode_validate(c, k, flags);
480480
fsck_err:
@@ -800,10 +800,8 @@ void bch2_inode_init_early(struct bch_fs *c,
800800

801801
memset(inode_u, 0, sizeof(*inode_u));
802802

803-
/* ick */
804-
inode_u->bi_flags |= str_hash << INODE_STR_HASH_OFFSET;
805-
get_random_bytes(&inode_u->bi_hash_seed,
806-
sizeof(inode_u->bi_hash_seed));
803+
SET_INODE_STR_HASH(inode_u, str_hash);
804+
get_random_bytes(&inode_u->bi_hash_seed, sizeof(inode_u->bi_hash_seed));
807805
}
808806

809807
void bch2_inode_init_late(struct bch_inode_unpacked *inode_u, u64 now,

fs/bcachefs/inode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ struct bch_inode_unpacked {
9292
BCH_INODE_FIELDS_v3()
9393
#undef x
9494
};
95+
BITMASK(INODE_STR_HASH, struct bch_inode_unpacked, bi_flags, 20, 24);
9596

9697
struct bkey_inode_buf {
9798
struct bkey_i_inode_v3 inode;

fs/bcachefs/inode_format.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ enum __bch_inode_flags {
150150
#undef x
151151
};
152152

153-
LE32_BITMASK(INODE_STR_HASH, struct bch_inode, bi_flags, 20, 24);
154-
LE32_BITMASK(INODE_NR_FIELDS, struct bch_inode, bi_flags, 24, 31);
155-
LE32_BITMASK(INODE_NEW_VARINT, struct bch_inode, bi_flags, 31, 32);
153+
LE32_BITMASK(INODEv1_STR_HASH, struct bch_inode, bi_flags, 20, 24);
154+
LE32_BITMASK(INODEv1_NR_FIELDS, struct bch_inode, bi_flags, 24, 31);
155+
LE32_BITMASK(INODEv1_NEW_VARINT,struct bch_inode, bi_flags, 31, 32);
156156

157157
LE64_BITMASK(INODEv2_STR_HASH, struct bch_inode_v2, bi_flags, 20, 24);
158158
LE64_BITMASK(INODEv2_NR_FIELDS, struct bch_inode_v2, bi_flags, 24, 31);

fs/bcachefs/str_hash.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ bch2_hash_info_init(struct bch_fs *c, const struct bch_inode_unpacked *bi)
4646
{
4747
/* XXX ick */
4848
struct bch_hash_info info = {
49-
.type = (bi->bi_flags >> INODE_STR_HASH_OFFSET) &
50-
~(~0U << INODE_STR_HASH_BITS),
49+
.type = INODE_STR_HASH(bi),
5150
.siphash_key = { .k0 = bi->bi_hash_seed }
5251
};
5352

0 commit comments

Comments
 (0)