Lines Matching refs:iter

13 static inline bool sort_iter_end(struct sort_iter *iter)  in sort_iter_end()  argument
15 return !iter->used; in sort_iter_end()
18 static inline void sort_iter_sift(struct sort_iter *iter, unsigned from, in sort_iter_sift() argument
24 i + 1 < iter->used && in sort_iter_sift()
25 cmp(iter->b, iter->data[i].k, iter->data[i + 1].k) > 0; in sort_iter_sift()
27 swap(iter->data[i], iter->data[i + 1]); in sort_iter_sift()
30 static inline void sort_iter_sort(struct sort_iter *iter, sort_cmp_fn cmp) in sort_iter_sort() argument
32 unsigned i = iter->used; in sort_iter_sort()
35 sort_iter_sift(iter, i, cmp); in sort_iter_sort()
38 static inline struct bkey_packed *sort_iter_peek(struct sort_iter *iter) in sort_iter_peek() argument
40 return !sort_iter_end(iter) ? iter->data->k : NULL; in sort_iter_peek()
43 static inline void sort_iter_advance(struct sort_iter *iter, sort_cmp_fn cmp) in sort_iter_advance() argument
45 struct sort_iter_set *i = iter->data; in sort_iter_advance()
47 BUG_ON(!iter->used); in sort_iter_advance()
54 array_remove_item(iter->data, iter->used, 0); in sort_iter_advance()
56 sort_iter_sift(iter, 0, cmp); in sort_iter_advance()
59 static inline struct bkey_packed *sort_iter_next(struct sort_iter *iter, in sort_iter_next() argument
62 struct bkey_packed *ret = sort_iter_peek(iter); in sort_iter_next()
65 sort_iter_advance(iter, cmp); in sort_iter_next()
81 static inline bool should_drop_next_key(struct sort_iter *iter) in should_drop_next_key() argument
88 return iter->used >= 2 && in should_drop_next_key()
89 !bch2_bkey_cmp_packed(iter->b, in should_drop_next_key()
90 iter->data[0].k, in should_drop_next_key()
91 iter->data[1].k); in should_drop_next_key()
96 struct sort_iter *iter) in bch2_key_sort_fix_overlapping() argument
104 sort_iter_sort(iter, key_sort_fix_overlapping_cmp); in bch2_key_sort_fix_overlapping()
106 while ((k = sort_iter_peek(iter))) { in bch2_key_sort_fix_overlapping()
108 !should_drop_next_key(iter)) { in bch2_key_sort_fix_overlapping()
114 sort_iter_advance(iter, key_sort_fix_overlapping_cmp); in bch2_key_sort_fix_overlapping()
173 unsigned bch2_sort_keys_keep_unwritten_whiteouts(struct bkey_packed *dst, struct sort_iter *iter) in bch2_sort_keys_keep_unwritten_whiteouts() argument
177 sort_iter_sort(iter, keep_unwritten_whiteouts_cmp); in bch2_sort_keys_keep_unwritten_whiteouts()
179 while ((in = sort_iter_next(iter, keep_unwritten_whiteouts_cmp))) { in bch2_sort_keys_keep_unwritten_whiteouts()
180 if (bkey_deleted(in) && in < unwritten_whiteouts_start(iter->b)) in bch2_sort_keys_keep_unwritten_whiteouts()
183 if ((next = sort_iter_peek(iter)) && in bch2_sort_keys_keep_unwritten_whiteouts()
184 !bch2_bkey_cmp_packed_inlined(iter->b, in, next)) in bch2_sort_keys_keep_unwritten_whiteouts()
199 unsigned bch2_sort_keys(struct bkey_packed *dst, struct sort_iter *iter) in bch2_sort_keys() argument
203 sort_iter_sort(iter, bch2_bkey_cmp_packed_inlined); in bch2_sort_keys()
205 while ((in = sort_iter_next(iter, bch2_bkey_cmp_packed_inlined))) { in bch2_sort_keys()