Commit a0c9cc17 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Better iterator picking

Avoid cloning iterators if we don't have to.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent d44a6e35
......@@ -2017,10 +2017,14 @@ struct btree_iter *__bch2_trans_get_iter(struct btree_trans *trans,
if (iter->btree_id != btree_id)
continue;
if (best &&
bkey_cmp(bpos_diff(best->real_pos, pos),
bpos_diff(iter->real_pos, pos)) < 0)
continue;
if (best) {
int cmp = bkey_cmp(bpos_diff(best->real_pos, pos),
bpos_diff(iter->real_pos, pos));
if (cmp < 0 ||
((cmp == 0 && btree_iter_keep(trans, iter))))
continue;
}
best = iter;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment