bcachefs: Kill bch2_sort_repack_merge()

The main function of bch2_sort_repack_merge() was to call .key_normalize
on every key, which drops stale (cached) pointers - it hasn't actually
merged extents in quite some time.

But bch2_gc_gens() now works on individual keys - we used to gc old gens
by rewriting entire btree nodes. With that gone, there's no need for
internal btree code to be calling .key_normalize anymore.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2021-12-19 18:59:22 -05:00 committed by Kent Overstreet
parent b84d42c31f
commit 62d5bd955f
3 changed files with 4 additions and 73 deletions

View File

@ -117,23 +117,6 @@ bch2_key_sort_fix_overlapping(struct bch_fs *c, struct bset *dst,
return nr;
}
static void extent_sort_append(struct bch_fs *c,
struct bkey_format *f,
struct btree_nr_keys *nr,
struct bkey_packed **out,
struct bkey_s k)
{
if (!bkey_deleted(k.k)) {
if (!bch2_bkey_pack_key(*out, k.k, f))
memcpy_u64s_small(*out, k.k, BKEY_U64s);
memcpy_u64s_small(bkeyp_val(f, *out), k.v, bkey_val_u64s(k.k));
btree_keys_account_key_add(nr, 0, *out);
*out = bkey_next(*out);
}
}
/* Sort + repack in a new format: */
struct btree_nr_keys
bch2_sort_repack(struct bset *dst, struct btree *src,
@ -165,47 +148,6 @@ bch2_sort_repack(struct bset *dst, struct btree *src,
return nr;
}
/* Sort, repack, and call bch2_bkey_normalize() to drop stale pointers: */
struct btree_nr_keys
bch2_sort_repack_merge(struct bch_fs *c,
struct bset *dst, struct btree *src,
struct btree_node_iter *iter,
struct bkey_format *out_f,
bool filter_whiteouts)
{
struct bkey_packed *out = vstruct_last(dst), *k_packed;
struct bkey_buf k;
struct btree_nr_keys nr;
memset(&nr, 0, sizeof(nr));
bch2_bkey_buf_init(&k);
while ((k_packed = bch2_btree_node_iter_next_all(iter, src))) {
if (filter_whiteouts && bkey_deleted(k_packed))
continue;
/*
* NOTE:
* bch2_bkey_normalize may modify the key we pass it (dropping
* stale pointers) and we don't have a write lock on the src
* node; we have to make a copy of the entire key before calling
* normalize
*/
bch2_bkey_buf_realloc(&k, c, k_packed->u64s + BKEY_U64s);
bch2_bkey_unpack(src, k.k, k_packed);
if (filter_whiteouts &&
bch2_bkey_normalize(c, bkey_i_to_s(k.k)))
continue;
extent_sort_append(c, out_f, &nr, &out, bkey_i_to_s(k.k));
}
dst->u64s = cpu_to_le16((u64 *) out - dst->_data);
bch2_bkey_buf_exit(&k, c);
return nr;
}
static inline int sort_keys_cmp(struct btree *b,
struct bkey_packed *l,
struct bkey_packed *r)

View File

@ -37,11 +37,6 @@ struct btree_nr_keys
bch2_sort_repack(struct bset *, struct btree *,
struct btree_node_iter *,
struct bkey_format *, bool);
struct btree_nr_keys
bch2_sort_repack_merge(struct bch_fs *,
struct bset *, struct btree *,
struct btree_node_iter *,
struct bkey_format *, bool);
unsigned bch2_sort_keys(struct bkey_packed *,
struct sort_iter *, bool);

View File

@ -385,16 +385,10 @@ void bch2_btree_sort_into(struct bch_fs *c,
bch2_btree_node_iter_init_from_start(&src_iter, src);
if (btree_node_is_extents(src))
nr = bch2_sort_repack_merge(c, btree_bset_first(dst),
src, &src_iter,
&dst->format,
true);
else
nr = bch2_sort_repack(btree_bset_first(dst),
src, &src_iter,
&dst->format,
true);
nr = bch2_sort_repack(btree_bset_first(dst),
src, &src_iter,
&dst->format,
true);
bch2_time_stats_update(&c->times[BCH_TIME_btree_node_sort],
start_time);