summaryrefslogtreecommitdiff
path: root/drivers/md/bcache/btree.h
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-12-17 21:46:35 -0800
committerKent Overstreet <kmo@daterainc.com>2014-01-08 13:05:10 -0800
commit88b9f8c426f35e04738220c1bc05dd1ea1b513a3 (patch)
treeb0391209b767145e53d4c0f52d3cb56376e4dc53 /drivers/md/bcache/btree.h
parent5c41c8a713da7874bd79196696a275beeb11821e (diff)
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.h20
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);