Commit ae2f17d5 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Kill btree_node_iter_large

Long overdue cleanup - this converts btree_node_iter_large uses to
sort_iter.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 8f82280e
This diff is collapsed.
......@@ -2,20 +2,10 @@
#ifndef _BCACHEFS_BKEY_SORT_H
#define _BCACHEFS_BKEY_SORT_H
struct btree_node_iter_large {
u16 used;
struct btree_node_iter_set data[MAX_BSETS];
};
void bch2_btree_node_iter_large_push(struct btree_node_iter_large *,
struct btree *,
const struct bkey_packed *,
const struct bkey_packed *);
struct sort_iter {
struct btree *b;
struct btree *b;
unsigned used;
unsigned size;
struct sort_iter_set {
struct bkey_packed *k, *end;
......@@ -24,27 +14,27 @@ struct sort_iter {
static inline void sort_iter_init(struct sort_iter *iter, struct btree *b)
{
memset(iter, 0, sizeof(*iter));
iter->b = b;
iter->used = 0;
iter->size = ARRAY_SIZE(iter->data);
}
static inline void sort_iter_add(struct sort_iter *iter,
struct bkey_packed *k,
struct bkey_packed *end)
{
BUG_ON(iter->used >= ARRAY_SIZE(iter->data));
BUG_ON(iter->used >= iter->size);
if (k != end)
iter->data[iter->used++] = (struct sort_iter_set) { k, end };
}
struct btree_nr_keys
bch2_key_sort_fix_overlapping(struct bset *, struct btree *,
struct btree_node_iter_large *);
bch2_key_sort_fix_overlapping(struct bch_fs *, struct bset *,
struct sort_iter *);
struct btree_nr_keys
bch2_extent_sort_fix_overlapping(struct bch_fs *, struct bset *,
struct btree *,
struct btree_node_iter_large *);
struct sort_iter *);
struct btree_nr_keys
bch2_sort_repack(struct bset *, struct btree *,
......
......@@ -862,7 +862,7 @@ static int validate_bset(struct bch_fs *c, struct btree *b,
int bch2_btree_node_read_done(struct bch_fs *c, struct btree *b, bool have_retry)
{
struct btree_node_entry *bne;
struct btree_node_iter_large *iter;
struct sort_iter *iter;
struct btree_node *sorted;
struct bkey_packed *k;
struct bset *i;
......@@ -871,7 +871,8 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct btree *b, bool have_retry
int ret, retry_read = 0, write = READ;
iter = mempool_alloc(&c->fill_iter, GFP_NOIO);
iter->used = 0;
sort_iter_init(iter, b);
iter->size = (btree_blocks(c) + 1) * 2;
if (bch2_meta_read_fault("btree"))
btree_err(BTREE_ERR_MUST_RETRY, c, b, NULL,
......@@ -950,13 +951,12 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct btree *b, bool have_retry
if (blacklisted && !first)
continue;
bch2_btree_node_iter_large_push(iter, b,
i->start,
vstruct_idx(i, whiteout_u64s));
sort_iter_add(iter, i->start,
vstruct_idx(i, whiteout_u64s));
bch2_btree_node_iter_large_push(iter, b,
vstruct_idx(i, whiteout_u64s),
vstruct_last(i));
sort_iter_add(iter,
vstruct_idx(i, whiteout_u64s),
vstruct_last(i));
}
for (bne = write_block(b);
......@@ -971,9 +971,9 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct btree *b, bool have_retry
set_btree_bset(b, b->set, &b->data->keys);
b->nr = btree_node_is_extents(b)
? bch2_extent_sort_fix_overlapping(c, &sorted->keys, b, iter)
: bch2_key_sort_fix_overlapping(&sorted->keys, b, iter);
b->nr = (btree_node_is_extents(b)
? bch2_extent_sort_fix_overlapping
: bch2_key_sort_fix_overlapping)(c, &sorted->keys, iter);
u64s = le16_to_cpu(sorted->keys.u64s);
*sorted = *b->data;
......
......@@ -705,9 +705,9 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
if (bch2_fs_init_fault("fs_alloc"))
goto err;
iter_size = sizeof(struct btree_node_iter_large) +
iter_size = sizeof(struct sort_iter) +
(btree_blocks(c) + 1) * 2 *
sizeof(struct btree_node_iter_set);
sizeof(struct sort_iter_set);
if (!(c->wq = alloc_workqueue("bcachefs",
WQ_FREEZABLE|WQ_MEM_RECLAIM|WQ_HIGHPRI, 1)) ||
......
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