2018-11-27 23:30:56 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _BCACHEFS_BKEY_SORT_H
|
|
|
|
#define _BCACHEFS_BKEY_SORT_H
|
|
|
|
|
|
|
|
struct sort_iter {
|
2019-12-14 21:20:33 +00:00
|
|
|
struct btree *b;
|
2018-11-27 23:30:56 +00:00
|
|
|
unsigned used;
|
2019-12-14 21:20:33 +00:00
|
|
|
unsigned size;
|
2018-11-27 23:30:56 +00:00
|
|
|
|
|
|
|
struct sort_iter_set {
|
|
|
|
struct bkey_packed *k, *end;
|
|
|
|
} data[MAX_BSETS + 1];
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void sort_iter_init(struct sort_iter *iter, struct btree *b)
|
|
|
|
{
|
|
|
|
iter->b = b;
|
2019-12-14 21:20:33 +00:00
|
|
|
iter->used = 0;
|
|
|
|
iter->size = ARRAY_SIZE(iter->data);
|
2018-11-27 23:30:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void sort_iter_add(struct sort_iter *iter,
|
|
|
|
struct bkey_packed *k,
|
|
|
|
struct bkey_packed *end)
|
|
|
|
{
|
2019-12-14 21:20:33 +00:00
|
|
|
BUG_ON(iter->used >= iter->size);
|
2018-11-27 23:30:56 +00:00
|
|
|
|
|
|
|
if (k != end)
|
|
|
|
iter->data[iter->used++] = (struct sort_iter_set) { k, end };
|
|
|
|
}
|
|
|
|
|
|
|
|
struct btree_nr_keys
|
2019-12-14 21:20:33 +00:00
|
|
|
bch2_key_sort_fix_overlapping(struct bch_fs *, struct bset *,
|
|
|
|
struct sort_iter *);
|
2018-11-27 23:30:56 +00:00
|
|
|
|
|
|
|
struct btree_nr_keys
|
2018-11-01 19:10:01 +00:00
|
|
|
bch2_sort_repack(struct bset *, struct btree *,
|
|
|
|
struct btree_node_iter *,
|
|
|
|
struct bkey_format *, bool);
|
2018-11-27 23:30:56 +00:00
|
|
|
|
|
|
|
unsigned bch2_sort_keys(struct bkey_packed *,
|
|
|
|
struct sort_iter *, bool);
|
|
|
|
|
|
|
|
#endif /* _BCACHEFS_BKEY_SORT_H */
|