diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-03-26 20:10:59 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2021-03-26 20:10:59 -0400 |
commit | 90f7b75fef473e7bfcc63ee1f1fda819bd265aee (patch) | |
tree | 6e129bb6395be71fb0e310f84be008ce2adbe2f9 | |
parent | db6fb2f0c33e39842c0c6f16062727d6b297a71f (diff) |
bcachefs: Fix building of aux search trees
We weren't packing the min/max keys, which was a major oversight and
completely disabled generating bkey_floats for adjacent nodes.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r-- | fs/bcachefs/bset.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index 2a01a5b326dd..f48b8798a4ca 100644 --- a/fs/bcachefs/bset.c +++ b/fs/bcachefs/bset.c @@ -686,16 +686,20 @@ static void make_bfloat(struct btree *b, struct bset_tree *t, if (is_power_of_2(j) && !min_key->u64s) { - k = (void *) min_key; - bkey_init(&k->k); - k->k.p = b->data->min_key; + if (!bkey_pack_pos(min_key, b->data->min_key, b)) { + k = (void *) min_key; + bkey_init(&k->k); + k->k.p = b->data->min_key; + } } if (is_power_of_2(j + 1) && !max_key->u64s) { - k = (void *) max_key; - bkey_init(&k->k); - k->k.p = t->max_key; + if (!bkey_pack_pos(max_key, b->data->max_key, b)) { + k = (void *) max_key; + bkey_init(&k->k); + k->k.p = t->max_key; + } } __make_bfloat(b, t, j, min_key, max_key); @@ -780,10 +784,15 @@ retry: t->max_key = bkey_unpack_pos(b, prev); - bkey_init(&min_key.k); - min_key.k.p = b->data->min_key; - bkey_init(&max_key.k); - max_key.k.p = t->max_key; + if (!bkey_pack_pos(bkey_to_packed(&min_key), b->data->min_key, b)) { + bkey_init(&min_key.k); + min_key.k.p = b->data->min_key; + } + + if (!bkey_pack_pos(bkey_to_packed(&max_key), b->data->max_key, b)) { + bkey_init(&max_key.k); + max_key.k.p = t->max_key; + } /* Then we build the tree */ eytzinger1_for_each(j, t->size) |