diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-07-02 06:29:05 +0400 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2013-11-11 09:56:36 +0400 |
commit | 0eacac22034ca21c73fe49e800d0b938b2047250 (patch) | |
tree | 5ff18b8b3296de48a5fa7e60aeedf2e2d2789a0a /drivers/md/bcache/bset.h | |
parent | d5cc66e95744065f96024add4bf7d7e019be54ac (diff) | |
download | linux-0eacac22034ca21c73fe49e800d0b938b2047250.tar.xz |
bcache: PRECEDING_KEY()
btree_insert_key() was open coding this, this is just refactoring.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/bset.h')
-rw-r--r-- | drivers/md/bcache/bset.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h index e67386001814..bc9975526aa1 100644 --- a/drivers/md/bcache/bset.h +++ b/drivers/md/bcache/bset.h @@ -353,12 +353,30 @@ void bch_bset_fix_lookup_table(struct btree *, struct bkey *); struct bkey *__bch_bset_search(struct btree *, 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, const struct bkey *search) { return search ? __bch_bset_search(b, t, search) : t->data->start; } +#define PRECEDING_KEY(_k) \ +({ \ + struct bkey *_ret = NULL; \ + \ + if (KEY_INODE(_k) || KEY_OFFSET(_k)) { \ + _ret = &KEY(KEY_INODE(_k), KEY_OFFSET(_k), 0); \ + \ + if (!_ret->low) \ + _ret->high--; \ + _ret->low--; \ + } \ + \ + _ret; \ +}) + bool bch_bkey_try_merge(struct btree *, struct bkey *, struct bkey *); void bch_btree_sort_lazy(struct btree *); void bch_btree_sort_into(struct btree *, struct btree *); |