summaryrefslogtreecommitdiff
path: root/drivers/md/bcache/bset.h
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-11-12 05:35:24 +0400
committerKent Overstreet <kmo@daterainc.com>2014-01-09 01:05:13 +0400
commitc052dd9a26f60bcf70c0c3fcc08e07abb60295cd (patch)
tree9b6f0f270c546ef974bd0b091679a81e1ea295fc /drivers/md/bcache/bset.h
parentf67342dd342d5917d94a7c0ffbde5f78e0d7a57a (diff)
downloadlinux-c052dd9a26f60bcf70c0c3fcc08e07abb60295cd.tar.xz
bcache: Convert btree_iter to struct btree_keys
More work to disentangle bset.c from struct btree Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/bset.h')
-rw-r--r--drivers/md/bcache/bset.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h
index 49135695342e..563130c28142 100644
--- a/drivers/md/bcache/bset.h
+++ b/drivers/md/bcache/bset.h
@@ -309,7 +309,7 @@ static inline bool bch_bkey_try_merge(struct btree_keys *b,
struct btree_iter {
size_t size, used;
#ifdef CONFIG_BCACHE_DEBUG
- struct btree *b;
+ struct btree_keys *b;
#endif
struct btree_iter_set {
struct bkey *k, *end;
@@ -323,21 +323,30 @@ struct bkey *bch_btree_iter_next_filter(struct btree_iter *,
struct btree_keys *, ptr_filter_fn);
void bch_btree_iter_push(struct btree_iter *, struct bkey *, struct bkey *);
-struct bkey *bch_btree_iter_init(struct btree *, struct btree_iter *,
+struct bkey *bch_btree_iter_init(struct btree_keys *, struct btree_iter *,
struct bkey *);
-struct bkey *__bch_bset_search(struct btree *, struct bset_tree *,
- const struct bkey *);
+struct bkey *__bch_bset_search(struct btree_keys *, struct bset_tree *,
+ const struct bkey *);
/*
* Returns the first key that is strictly greater than search
*/
-static inline struct bkey *bch_bset_search(struct btree *b, struct bset_tree *t,
+static inline struct bkey *bch_bset_search(struct btree_keys *b,
+ struct bset_tree *t,
const struct bkey *search)
{
return search ? __bch_bset_search(b, t, search) : t->data->start;
}
+#define for_each_key_filter(b, k, iter, filter) \
+ for (bch_btree_iter_init((b), (iter), NULL); \
+ ((k) = bch_btree_iter_next_filter((iter), (b), filter));)
+
+#define for_each_key(b, k, iter) \
+ for (bch_btree_iter_init((b), (iter), NULL); \
+ ((k) = bch_btree_iter_next(iter));)
+
/* Sorting */
struct bset_sort_state {