diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-12-20 02:59:22 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:19 +0300 |
commit | 62d5bd955fd81320d1e03fdebb4342ee14df1d1f (patch) | |
tree | 894f7f7d7acb4ba58b5773763ecd186dc0fa183a /fs | |
parent | b84d42c31f34094c74d6306e11e3a0bc224c7575 (diff) | |
download | linux-62d5bd955fd81320d1e03fdebb4342ee14df1d1f.tar.xz |
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/bkey_sort.c | 58 | ||||
-rw-r--r-- | fs/bcachefs/bkey_sort.h | 5 | ||||
-rw-r--r-- | fs/bcachefs/btree_io.c | 14 |
3 files changed, 4 insertions, 73 deletions
diff --git a/fs/bcachefs/bkey_sort.c b/fs/bcachefs/bkey_sort.c index 537ab7919e88..da0b7a63b146 100644 --- a/fs/bcachefs/bkey_sort.c +++ b/fs/bcachefs/bkey_sort.c @@ -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) diff --git a/fs/bcachefs/bkey_sort.h b/fs/bcachefs/bkey_sort.h index 1059996dac78..79cf11d1b4e7 100644 --- a/fs/bcachefs/bkey_sort.h +++ b/fs/bcachefs/bkey_sort.h @@ -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); diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index 5a678e6e993a..45f7ec41a8f1 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -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); |