diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-12-18 06:46:35 +0100 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2014-01-08 22:05:10 +0100 |
commit | 88b9f8c426f35e04738220c1bc05dd1ea1b513a3 (patch) | |
tree | b0391209b767145e53d4c0f52d3cb56376e4dc53 /drivers/md/bcache/btree.h | |
parent | bcache: Trivial error handling fix (diff) | |
download | linux-88b9f8c426f35e04738220c1bc05dd1ea1b513a3.tar.xz linux-88b9f8c426f35e04738220c1bc05dd1ea1b513a3.zip |
bcache: kill index()
That was a terrible name for a macro, add some better helpers to replace it.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/btree.h')
-rw-r--r-- | drivers/md/bcache/btree.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/md/bcache/btree.h b/drivers/md/bcache/btree.h index 4f0378ac1f7b..12c99b1a764d 100644 --- a/drivers/md/bcache/btree.h +++ b/drivers/md/bcache/btree.h @@ -185,6 +185,26 @@ static inline unsigned bset_offset(struct btree *b, struct bset *i) return (((size_t) i) - ((size_t) b->sets->data)) >> 9; } +static inline struct bset *btree_bset_first(struct btree *b) +{ + return b->sets->data; +} + +static inline unsigned bset_byte_offset(struct btree *b, struct bset *i) +{ + return ((size_t) i) - ((size_t) b->sets->data); +} + +static inline unsigned bset_sector_offset(struct btree *b, struct bset *i) +{ + return (((void *) i) - ((void *) btree_bset_first(b))) >> 9; +} + +static inline unsigned bset_block_offset(struct btree *b, struct bset *i) +{ + return bset_sector_offset(b, i) >> b->c->block_bits; +} + static inline struct bset *write_block(struct btree *b) { return ((void *) b->sets[0].data) + b->written * block_bytes(b->c); |