bcachefs: Add a missing btree_path_make_mut() call
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 7 Sep 2021 17:55:33 +0000 (13:55 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:12 +0000 (17:09 -0400)
Also add another small helper, btree_path_clone().

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/btree_iter.c

index 81351673ede3398d2144e77e73ee39ef197ba7d6..3aa2777e40a5bd2cb3ac4ced661e9c49b1f4b43d 100644 (file)
@@ -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;
        }