From: Kent Overstreet Date: Sun, 8 Jan 2023 05:04:30 +0000 (-0500) Subject: bcachefs: Fix bch2_btree_path_traverse_all() X-Git-Tag: io_uring-6.7-2023-11-10~119^2~603 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=c82ed3047b8875b07b19e6e287c48f27a37b756f;p=linux-block.git bcachefs: Fix bch2_btree_path_traverse_all() 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 --- diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 398db0faa816..31733c239746 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -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;