diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-12-18 00:56:21 -0500 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2014-01-08 16:05:12 -0500 |
commit | fafff81cead78157099df1ee10af16cc51893ddc (patch) | |
tree | a198145a2ac94431667e82e2eb09c1365fb94b84 /drivers/md/bcache/btree.c | |
parent | 085d2a3dd4d65b7bce1dead987c647dbbc014281 (diff) |
bcache: Bkey indexing renaming
More refactoring:
node() -> bset_bkey_idx()
end() -> bset_bkey_last()
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/btree.c')
-rw-r--r-- | drivers/md/bcache/btree.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index f0a6399fdd3c..8aaaf16637a0 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c | |||
@@ -197,7 +197,7 @@ void bkey_put(struct cache_set *c, struct bkey *k) | |||
197 | static uint64_t btree_csum_set(struct btree *b, struct bset *i) | 197 | static uint64_t btree_csum_set(struct btree *b, struct bset *i) |
198 | { | 198 | { |
199 | uint64_t crc = b->key.ptr[0]; | 199 | uint64_t crc = b->key.ptr[0]; |
200 | void *data = (void *) i + 8, *end = end(i); | 200 | void *data = (void *) i + 8, *end = bset_bkey_last(i); |
201 | 201 | ||
202 | crc = bch_crc64_update(crc, data, end - data); | 202 | crc = bch_crc64_update(crc, data, end - data); |
203 | return crc ^ 0xffffffffffffffffULL; | 203 | return crc ^ 0xffffffffffffffffULL; |
@@ -251,7 +251,7 @@ void bch_btree_node_read_done(struct btree *b) | |||
251 | if (i != b->sets[0].data && !i->keys) | 251 | if (i != b->sets[0].data && !i->keys) |
252 | goto err; | 252 | goto err; |
253 | 253 | ||
254 | bch_btree_iter_push(iter, i->start, end(i)); | 254 | bch_btree_iter_push(iter, i->start, bset_bkey_last(i)); |
255 | 255 | ||
256 | b->written += set_blocks(i, b->c); | 256 | b->written += set_blocks(i, b->c); |
257 | } | 257 | } |
@@ -1310,7 +1310,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, | |||
1310 | 1310 | ||
1311 | if (i > 1) { | 1311 | if (i > 1) { |
1312 | for (k = n2->start; | 1312 | for (k = n2->start; |
1313 | k < end(n2); | 1313 | k < bset_bkey_last(n2); |
1314 | k = bkey_next(k)) { | 1314 | k = bkey_next(k)) { |
1315 | if (__set_blocks(n1, n1->keys + keys + | 1315 | if (__set_blocks(n1, n1->keys + keys + |
1316 | bkey_u64s(k), b->c) > blocks) | 1316 | bkey_u64s(k), b->c) > blocks) |
@@ -1343,16 +1343,17 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, | |||
1343 | if (last) | 1343 | if (last) |
1344 | bkey_copy_key(&new_nodes[i]->key, last); | 1344 | bkey_copy_key(&new_nodes[i]->key, last); |
1345 | 1345 | ||
1346 | memcpy(end(n1), | 1346 | memcpy(bset_bkey_last(n1), |
1347 | n2->start, | 1347 | n2->start, |
1348 | (void *) node(n2, keys) - (void *) n2->start); | 1348 | (void *) bset_bkey_idx(n2, keys) - (void *) n2->start); |
1349 | 1349 | ||
1350 | n1->keys += keys; | 1350 | n1->keys += keys; |
1351 | r[i].keys = n1->keys; | 1351 | r[i].keys = n1->keys; |
1352 | 1352 | ||
1353 | memmove(n2->start, | 1353 | memmove(n2->start, |
1354 | node(n2, keys), | 1354 | bset_bkey_idx(n2, keys), |
1355 | (void *) end(n2) - (void *) node(n2, keys)); | 1355 | (void *) bset_bkey_last(n2) - |
1356 | (void *) bset_bkey_idx(n2, keys)); | ||
1356 | 1357 | ||
1357 | n2->keys -= keys; | 1358 | n2->keys -= keys; |
1358 | 1359 | ||
@@ -1830,7 +1831,7 @@ static void shift_keys(struct btree *b, struct bkey *where, struct bkey *insert) | |||
1830 | 1831 | ||
1831 | memmove((uint64_t *) where + bkey_u64s(insert), | 1832 | memmove((uint64_t *) where + bkey_u64s(insert), |
1832 | where, | 1833 | where, |
1833 | (void *) end(i) - (void *) where); | 1834 | (void *) bset_bkey_last(i) - (void *) where); |
1834 | 1835 | ||
1835 | i->keys += bkey_u64s(insert); | 1836 | i->keys += bkey_u64s(insert); |
1836 | bkey_copy(where, insert); | 1837 | bkey_copy(where, insert); |
@@ -2014,7 +2015,7 @@ static bool btree_insert_key(struct btree *b, struct btree_op *op, | |||
2014 | bcache_dev_sectors_dirty_add(b->c, KEY_INODE(k), | 2015 | bcache_dev_sectors_dirty_add(b->c, KEY_INODE(k), |
2015 | KEY_START(k), KEY_SIZE(k)); | 2016 | KEY_START(k), KEY_SIZE(k)); |
2016 | 2017 | ||
2017 | while (m != end(i) && | 2018 | while (m != bset_bkey_last(i) && |
2018 | bkey_cmp(k, &START_KEY(m)) > 0) | 2019 | bkey_cmp(k, &START_KEY(m)) > 0) |
2019 | prev = m, m = bkey_next(m); | 2020 | prev = m, m = bkey_next(m); |
2020 | 2021 | ||
@@ -2028,12 +2029,12 @@ static bool btree_insert_key(struct btree *b, struct btree_op *op, | |||
2028 | goto merged; | 2029 | goto merged; |
2029 | 2030 | ||
2030 | status = BTREE_INSERT_STATUS_OVERWROTE; | 2031 | status = BTREE_INSERT_STATUS_OVERWROTE; |
2031 | if (m != end(i) && | 2032 | if (m != bset_bkey_last(i) && |
2032 | KEY_PTRS(m) == KEY_PTRS(k) && !KEY_SIZE(m)) | 2033 | KEY_PTRS(m) == KEY_PTRS(k) && !KEY_SIZE(m)) |
2033 | goto copy; | 2034 | goto copy; |
2034 | 2035 | ||
2035 | status = BTREE_INSERT_STATUS_FRONT_MERGE; | 2036 | status = BTREE_INSERT_STATUS_FRONT_MERGE; |
2036 | if (m != end(i) && | 2037 | if (m != bset_bkey_last(i) && |
2037 | bch_bkey_try_merge(b, k, m)) | 2038 | bch_bkey_try_merge(b, k, m)) |
2038 | goto copy; | 2039 | goto copy; |
2039 | } else { | 2040 | } else { |
@@ -2142,16 +2143,18 @@ static int btree_split(struct btree *b, struct btree_op *op, | |||
2142 | */ | 2143 | */ |
2143 | 2144 | ||
2144 | while (keys < (n1->sets[0].data->keys * 3) / 5) | 2145 | while (keys < (n1->sets[0].data->keys * 3) / 5) |
2145 | keys += bkey_u64s(node(n1->sets[0].data, keys)); | 2146 | keys += bkey_u64s(bset_bkey_idx(n1->sets[0].data, |
2147 | keys)); | ||
2146 | 2148 | ||
2147 | bkey_copy_key(&n1->key, node(n1->sets[0].data, keys)); | 2149 | bkey_copy_key(&n1->key, |
2148 | keys += bkey_u64s(node(n1->sets[0].data, keys)); | 2150 | bset_bkey_idx(n1->sets[0].data, keys)); |
2151 | keys += bkey_u64s(bset_bkey_idx(n1->sets[0].data, keys)); | ||
2149 | 2152 | ||
2150 | n2->sets[0].data->keys = n1->sets[0].data->keys - keys; | 2153 | n2->sets[0].data->keys = n1->sets[0].data->keys - keys; |
2151 | n1->sets[0].data->keys = keys; | 2154 | n1->sets[0].data->keys = keys; |
2152 | 2155 | ||
2153 | memcpy(n2->sets[0].data->start, | 2156 | memcpy(n2->sets[0].data->start, |
2154 | end(n1->sets[0].data), | 2157 | bset_bkey_last(n1->sets[0].data), |
2155 | n2->sets[0].data->keys * sizeof(uint64_t)); | 2158 | n2->sets[0].data->keys * sizeof(uint64_t)); |
2156 | 2159 | ||
2157 | bkey_copy_key(&n2->key, &b->key); | 2160 | bkey_copy_key(&n2->key, &b->key); |