From c404f2038602580b6bdddeff5e9a4d42717da3b8 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Tue, 7 Sep 2021 13:55:33 -0400 Subject: [PATCH] bcachefs: Add a missing btree_path_make_mut() call Also add another small helper, btree_path_clone(). Signed-off-by: Kent Overstreet --- fs/bcachefs/btree_iter.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 81351673ede33..3aa2777e40a5b 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1491,16 +1491,22 @@ static void btree_path_copy(struct btree_trans *trans, struct btree_path *dst, 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_; @@ -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; } -- 2.30.2