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

bcachefs: No need to clone iterators for update

Since btree_path is now internally refcounted, we don't need to clone an
iterator before calling bch2_trans_update() if we'll be mutating it.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 22b383ad
......@@ -875,12 +875,7 @@ static noinline int extent_front_merge(struct btree_trans *trans,
bkey_reassemble(update, k);
if (bch2_bkey_merge(c, bkey_i_to_s(update), bkey_i_to_s_c(*insert))) {
struct btree_iter update_iter;
bch2_trans_copy_iter(&update_iter, iter);
ret = bch2_btree_delete_at(trans, &update_iter, flags);
bch2_trans_iter_exit(trans, &update_iter);
ret = bch2_btree_delete_at(trans, iter, flags);
if (ret)
return ret;
......@@ -959,10 +954,7 @@ static int bch2_trans_update_extent(struct btree_trans *trans,
}
if (bkey_cmp(k.k->p, insert->k.p) <= 0) {
bch2_trans_copy_iter(&update_iter, &iter);
ret = bch2_btree_delete_at(trans, &update_iter, flags);
bch2_trans_iter_exit(trans, &update_iter);
ret = bch2_btree_delete_at(trans, &iter, flags);
if (ret)
goto err;
}
......@@ -975,9 +967,10 @@ static int bch2_trans_update_extent(struct btree_trans *trans,
bkey_reassemble(update, k);
bch2_cut_front(insert->k.p, update);
bch2_trans_copy_iter(&update_iter, &iter);
bch2_trans_update(trans, &update_iter, update, flags);
bch2_trans_iter_exit(trans, &update_iter);
ret = bch2_trans_update(trans, &iter, update, flags);
if (ret)
goto err;
goto out;
}
next:
......@@ -1081,8 +1074,7 @@ int __bch2_btree_insert(struct btree_trans *trans,
int ret;
bch2_trans_iter_init(trans, &iter, id, bkey_start_pos(&k->k),
BTREE_ITER_INTENT);
BTREE_ITER_INTENT);
ret = bch2_btree_iter_traverse(&iter) ?:
bch2_trans_update(trans, &iter, k, 0);
bch2_trans_iter_exit(trans, &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