bcachefs: Add a missing btree_path_make_mut() call

Also add another small helper, btree_path_clone().

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2021-09-07 13:55:33 -04:00 committed by Kent Overstreet
parent 8ffa63cd7e
commit c404f20386

View File

@ -1491,16 +1491,22 @@ static void btree_path_copy(struct btree_trans *trans, struct btree_path *dst,
trans->paths_sorted = false;
}
static struct btree_path *btree_path_clone(struct btree_trans *trans, struct btree_path *src,
bool intent)
{
struct btree_path *new = btree_path_alloc(trans, src);
btree_path_copy(trans, new, src);
__btree_path_get(new, intent);
return new;
}
struct btree_path * __must_check
__bch2_btree_path_make_mut(struct btree_trans *trans,
struct btree_path *path, bool intent)
struct btree_path *path, bool intent)
{
struct btree_path *new = btree_path_alloc(trans, path);
btree_path_copy(trans, new, path);
__btree_path_get(new, intent);
__btree_path_put(path, intent);
path = new;
path = btree_path_clone(trans, path, intent);
path->preserve = false;
#ifdef CONFIG_BCACHEFS_DEBUG
path->ip_allocated = _RET_IP_;
@ -2030,6 +2036,8 @@ struct bkey_s_c bch2_btree_iter_peek(struct btree_iter *iter)
cmp = bpos_cmp(k.k->p, iter->path->pos);
if (cmp) {
iter->path = bch2_btree_path_make_mut(trans, iter->path,
iter->flags & BTREE_ITER_INTENT);
iter->path->pos = k.k->p;
trans->paths_sorted = false;
}