summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-06-01 13:48:38 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2016-07-30 01:13:53 -0800
commit75f7ef0f069f175b70b09e074b2da19f140c20e9 (patch)
treee6539af06b54d077eefcab864c13926f01a097d2
parentea331bf0715c6c9d4d91e0e83127bd30aa5e5969 (diff)
bcache: lift restrictions on 0 size extents
-rw-r--r--drivers/md/bcache/extents.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c
index 951850c0eb27..1adbcc05cf69 100644
--- a/drivers/md/bcache/extents.c
+++ b/drivers/md/bcache/extents.c
@@ -1025,16 +1025,17 @@ static enum btree_insert_ret extent_insert_should_stop(struct btree_insert_trans
return BTREE_INSERT_OK;
}
-static void extent_do_insert(struct btree_iter *iter, struct bkey_i *insert,
+static void extent_do_insert(struct btree_iter *iter,
+ struct btree_node_iter *insert_iter,
+ struct bkey_i *insert,
struct journal_res *res, unsigned flags,
struct bucket_stats_cache_set *stats)
{
struct btree_keys *b = &iter->nodes[0]->keys;
- struct btree_node_iter *node_iter = &iter->node_iters[0];
struct bset_tree *t = bset_tree_last(b);
struct bset *i = t->data;
struct bkey_packed *prev, *where =
- bch_btree_node_iter_bset_pos(node_iter, b, i) ?:
+ bch_btree_node_iter_bset_pos(insert_iter, b, i) ?:
bset_bkey_last(i);
if (!(flags & BTREE_INSERT_NO_MARK_KEY))
@@ -1052,11 +1053,12 @@ static void extent_do_insert(struct btree_iter *iter, struct bkey_i *insert,
bch_extent_merge_inline(iter, bkey_to_packed(insert), where, false))
return;
- bch_btree_bset_insert(iter, iter->nodes[0], node_iter, insert);
+ bch_btree_bset_insert(iter, iter->nodes[0], insert_iter, insert);
}
static void extent_insert_committed(struct btree_insert_trans *trans,
struct btree_trans_entry *insert,
+ struct btree_node_iter *insert_iter,
struct bpos committed_pos,
struct journal_res *res, unsigned flags,
struct bucket_stats_cache_set *stats)
@@ -1072,7 +1074,8 @@ static void extent_insert_committed(struct btree_insert_trans *trans,
EBUG_ON(bkey_deleted(&insert->k->k) || !insert->k->k.size);
split = bch_key_split(committed_pos, insert->k);
- extent_do_insert(insert->iter, split, res, flags, stats);
+ extent_do_insert(insert->iter, insert_iter,
+ split, res, flags, stats);
bch_btree_iter_set_pos_same_leaf(insert->iter, committed_pos);
@@ -1083,6 +1086,7 @@ static void extent_insert_committed(struct btree_insert_trans *trans,
static enum extent_insert_hook_ret
__extent_insert_advance_pos(struct btree_insert_trans *trans,
struct btree_trans_entry *insert,
+ struct btree_node_iter *insert_iter,
struct extent_insert_hook *hook,
struct bpos *committed_pos,
struct bpos next_pos,
@@ -1128,6 +1132,7 @@ __extent_insert_advance_pos(struct btree_insert_trans *trans,
static enum extent_insert_hook_ret
extent_insert_advance_pos(struct btree_insert_trans *trans,
struct btree_trans_entry *insert,
+ struct btree_node_iter *insert_iter,
struct extent_insert_hook *hook,
struct bpos *committed_pos,
struct bkey_s_c k,
@@ -1143,8 +1148,8 @@ extent_insert_advance_pos(struct btree_insert_trans *trans,
bool have_uncommitted = bkey_cmp(*committed_pos,
bkey_start_pos(&insert->k->k)) > 0;
- switch (__extent_insert_advance_pos(trans, insert, hook,
- committed_pos,
+ switch (__extent_insert_advance_pos(trans, insert, insert_iter,
+ hook, committed_pos,
bkey_start_pos(k.k),
bkey_s_c_null,
res, flags, stats)) {
@@ -1168,7 +1173,7 @@ extent_insert_advance_pos(struct btree_insert_trans *trans,
if (!bkey_cmp(*committed_pos, next_pos))
return BTREE_HOOK_DO_INSERT;
- return __extent_insert_advance_pos(trans, insert, hook,
+ return __extent_insert_advance_pos(trans, insert, insert_iter, hook,
committed_pos, next_pos,
k, res, flags, stats);
}
@@ -1224,6 +1229,7 @@ bch_insert_fixup_extent(struct btree_insert_trans *trans,
struct cache_set *c = iter->c;
struct btree *b = iter->nodes[0];
struct btree_node_iter *node_iter = &iter->node_iters[0];
+ struct btree_node_iter node_insert_iter = *node_iter;
const struct bkey_format *f = &b->keys.format;
struct bkey_packed *_k;
struct bkey unpacked;
@@ -1279,8 +1285,8 @@ bch_insert_fixup_extent(struct btree_insert_trans *trans,
}
}
- switch (extent_insert_advance_pos(trans, insert, hook,
- &committed_pos,
+ switch (extent_insert_advance_pos(trans, insert, &node_insert_iter,
+ hook, &committed_pos,
k.s_c, res, flags,
&stats)) {
case BTREE_HOOK_DO_INSERT:
@@ -1360,12 +1366,13 @@ bch_insert_fixup_extent(struct btree_insert_trans *trans,
if (bkey_cmp(committed_pos, insert->k->k.p) < 0 &&
ret == BTREE_INSERT_OK &&
- extent_insert_advance_pos(trans, insert, hook, &committed_pos,
- bkey_s_c_null, res, flags,
+ extent_insert_advance_pos(trans, insert, &node_insert_iter, hook,
+ &committed_pos, bkey_s_c_null, res, flags,
&stats) == BTREE_HOOK_RESTART_TRANS)
ret = BTREE_INSERT_NEED_TRAVERSE;
stop:
- extent_insert_committed(trans, insert, committed_pos, res, flags, &stats);
+ extent_insert_committed(trans, insert, &node_insert_iter,
+ committed_pos, res, flags, &stats);
bch_cache_set_stats_apply(c, &stats, disk_res, gc_pos_btree_node(b));