trans->paths_sorted = false;
}
-struct btree_path * __must_check
-__bch2_btree_path_make_mut(struct btree_trans *trans,
- struct btree_path *path, bool intent)
+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, path);
+ struct btree_path *new = btree_path_alloc(trans, src);
- btree_path_copy(trans, new, path);
+ 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)
+{
__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_;
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;
}