From: Kent Overstreet Date: Thu, 12 Dec 2024 07:26:15 +0000 (-0500) Subject: bcachefs: Fix btree_trans_peek_key_cache() BTREE_ITER_all_snapshots X-Git-Tag: io_uring-6.14-20240131~27^2~68 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=7e320a4063a81508e171012e0f75ec4a111850d4;p=linux-block.git bcachefs: Fix btree_trans_peek_key_cache() BTREE_ITER_all_snapshots In BTREE_ITER_all_snapshots mode, we're required to only return keys where the snapshot field matches the iterator position - BTREE_ITER_filter_snapshots requires pulling keys into the key cache from ancestor snapshots, so we have to check for that. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 51ebce9d5b5c..e370fa327769 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2230,6 +2230,10 @@ struct bkey_s_c btree_trans_peek_key_cache(struct btree_iter *iter, struct bpos k = bch2_btree_path_peek_slot(trans->paths + iter->key_cache_path, &u); if (k.k && !bkey_err(k)) { + if ((iter->flags & BTREE_ITER_all_snapshots) && + !bpos_eq(pos, k.k->p)) + return bkey_s_c_null; + iter->k = u; k.k = &iter->k; }