bcachefs: Fix bch2_btree_path_traverse_all()
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 8 Jan 2023 05:04:30 +0000 (00:04 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:49 +0000 (17:09 -0400)
We need to take a ref on a path while we're traversing it: this fixes a
bug with paths getting reused while being traversed, in the key cache
fill code.

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

index 398db0faa8169dc5922856990d676ebba1b77a8d..31733c239746f91a4036451578d242bc88488319 100644 (file)
@@ -999,7 +999,10 @@ retry_all:
                 * the same position:
                 */
                if (path->uptodate) {
+                       __btree_path_get(path, false);
                        ret = btree_path_traverse_one(trans, path, 0, _THIS_IP_);
+                       __btree_path_put(path, false);
+
                        if (bch2_err_matches(ret, BCH_ERR_transaction_restart) ||
                            ret == -ENOMEM)
                                goto retry_all;