Commit 3130303b authored by Alan Huang's avatar Alan Huang Committed by Kent Overstreet

bcachefs: Remove the prev array stuff

After reducing the search range when building the aux tree, the prev array
stuff is no longer useful, so remove it.
Signed-off-by: default avatarAlan Huang <mmpgouride@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 5d011012
...@@ -304,11 +304,6 @@ struct bkey_float { ...@@ -304,11 +304,6 @@ struct bkey_float {
}; };
#define BKEY_MANTISSA_BITS 16 #define BKEY_MANTISSA_BITS 16
static unsigned bkey_float_byte_offset(unsigned idx)
{
return idx * sizeof(struct bkey_float);
}
struct ro_aux_tree { struct ro_aux_tree {
u8 nothing[0]; u8 nothing[0];
struct bkey_float f[]; struct bkey_float f[];
...@@ -328,8 +323,7 @@ static unsigned bset_aux_tree_buf_end(const struct bset_tree *t) ...@@ -328,8 +323,7 @@ static unsigned bset_aux_tree_buf_end(const struct bset_tree *t)
return t->aux_data_offset; return t->aux_data_offset;
case BSET_RO_AUX_TREE: case BSET_RO_AUX_TREE:
return t->aux_data_offset + return t->aux_data_offset +
DIV_ROUND_UP(t->size * sizeof(struct bkey_float) + DIV_ROUND_UP(t->size * sizeof(struct bkey_float), 8);
t->size * sizeof(u8), 8);
case BSET_RW_AUX_TREE: case BSET_RW_AUX_TREE:
return t->aux_data_offset + return t->aux_data_offset +
DIV_ROUND_UP(sizeof(struct rw_aux_tree) * t->size, 8); DIV_ROUND_UP(sizeof(struct rw_aux_tree) * t->size, 8);
...@@ -360,14 +354,6 @@ static struct ro_aux_tree *ro_aux_tree_base(const struct btree *b, ...@@ -360,14 +354,6 @@ static struct ro_aux_tree *ro_aux_tree_base(const struct btree *b,
return __aux_tree_base(b, t); return __aux_tree_base(b, t);
} }
static u8 *ro_aux_tree_prev(const struct btree *b,
const struct bset_tree *t)
{
EBUG_ON(bset_aux_tree_type(t) != BSET_RO_AUX_TREE);
return __aux_tree_base(b, t) + bkey_float_byte_offset(t->size);
}
static struct bkey_float *bkey_float(const struct btree *b, static struct bkey_float *bkey_float(const struct btree *b,
const struct bset_tree *t, const struct bset_tree *t,
unsigned idx) unsigned idx)
...@@ -479,15 +465,6 @@ static inline struct bkey_packed *tree_to_bkey(const struct btree *b, ...@@ -479,15 +465,6 @@ static inline struct bkey_packed *tree_to_bkey(const struct btree *b,
bkey_float(b, t, j)->key_offset); bkey_float(b, t, j)->key_offset);
} }
static struct bkey_packed *tree_to_prev_bkey(const struct btree *b,
const struct bset_tree *t,
unsigned j)
{
unsigned prev_u64s = ro_aux_tree_prev(b, t)[j];
return (void *) ((u64 *) tree_to_bkey(b, t, j)->_data - prev_u64s);
}
static struct rw_aux_tree *rw_aux_tree(const struct btree *b, static struct rw_aux_tree *rw_aux_tree(const struct btree *b,
const struct bset_tree *t) const struct bset_tree *t)
{ {
...@@ -689,8 +666,7 @@ static unsigned __bset_tree_capacity(struct btree *b, const struct bset_tree *t) ...@@ -689,8 +666,7 @@ static unsigned __bset_tree_capacity(struct btree *b, const struct bset_tree *t)
static unsigned bset_ro_tree_capacity(struct btree *b, const struct bset_tree *t) static unsigned bset_ro_tree_capacity(struct btree *b, const struct bset_tree *t)
{ {
return __bset_tree_capacity(b, t) / return __bset_tree_capacity(b, t) / sizeof(struct bkey_float);
(sizeof(struct bkey_float) + sizeof(u8));
} }
static unsigned bset_rw_tree_capacity(struct btree *b, const struct bset_tree *t) static unsigned bset_rw_tree_capacity(struct btree *b, const struct bset_tree *t)
...@@ -719,7 +695,7 @@ static noinline void __build_rw_aux_tree(struct btree *b, struct bset_tree *t) ...@@ -719,7 +695,7 @@ static noinline void __build_rw_aux_tree(struct btree *b, struct bset_tree *t)
static noinline void __build_ro_aux_tree(struct btree *b, struct bset_tree *t) static noinline void __build_ro_aux_tree(struct btree *b, struct bset_tree *t)
{ {
struct bkey_packed *prev = NULL, *k = btree_bkey_first(b, t); struct bkey_packed *k = btree_bkey_first(b, t);
struct bkey_i min_key, max_key; struct bkey_i min_key, max_key;
unsigned cacheline = 1; unsigned cacheline = 1;
...@@ -737,7 +713,7 @@ static noinline void __build_ro_aux_tree(struct btree *b, struct bset_tree *t) ...@@ -737,7 +713,7 @@ static noinline void __build_ro_aux_tree(struct btree *b, struct bset_tree *t)
/* First we figure out where the first key in each cacheline is */ /* First we figure out where the first key in each cacheline is */
eytzinger1_for_each(j, t->size - 1) { eytzinger1_for_each(j, t->size - 1) {
while (bkey_to_cacheline(b, t, k) < cacheline) while (bkey_to_cacheline(b, t, k) < cacheline)
prev = k, k = bkey_p_next(k); k = bkey_p_next(k);
if (k >= btree_bkey_last(b, t)) { if (k >= btree_bkey_last(b, t)) {
/* XXX: this path sucks */ /* XXX: this path sucks */
...@@ -745,11 +721,9 @@ static noinline void __build_ro_aux_tree(struct btree *b, struct bset_tree *t) ...@@ -745,11 +721,9 @@ static noinline void __build_ro_aux_tree(struct btree *b, struct bset_tree *t)
goto retry; goto retry;
} }
ro_aux_tree_prev(b, t)[j] = prev->u64s;
bkey_float(b, t, j)->key_offset = bkey_float(b, t, j)->key_offset =
bkey_to_cacheline_offset(b, t, cacheline++, k); bkey_to_cacheline_offset(b, t, cacheline++, k);
EBUG_ON(tree_to_prev_bkey(b, t, j) != prev);
EBUG_ON(tree_to_bkey(b, t, j) != k); EBUG_ON(tree_to_bkey(b, t, j) != k);
} }
......
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