This is a note to let you know that I've just added the patch titled bcachefs: Fix BTREE_ITER_FILTER_SNAPSHOTS on inodes btree to the 6.7-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: bcachefs-fix-btree_iter_filter_snapshots-on-inodes-btree.patch and it can be found in the queue-6.7 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 560ceb6a4d9e3bea57c29f5f3a7a1d671dfc7983 Mon Sep 17 00:00:00 2001 From: Kent Overstreet <kent.overstreet@xxxxxxxxx> Date: Sat, 24 Feb 2024 19:14:36 -0500 Subject: bcachefs: Fix BTREE_ITER_FILTER_SNAPSHOTS on inodes btree From: Kent Overstreet <kent.overstreet@xxxxxxxxx> commit 204f45140faa0772d2ca1b3de96d1c0fb3db8e77 upstream. If we're in FILTER_SNAPSHOTS mode and we start scanning a range of the keyspace where no keys are visible in the current snapshot, we have a problem - we'll scan for a very long time before scanning terminates. Awhile back, this was fixed for most cases with peek_upto() (and assertions that enforce that it's being used). But the fix missed the fact that the inodes btree is different - every key offset is in a different snapshot tree, not just the inode field. Fixes: Signed-off-by: Kent Overstreet <kent.overstreet@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/bcachefs/btree_iter.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2094,7 +2094,9 @@ struct bkey_s_c bch2_btree_iter_peek_upt * isn't monotonically increasing before FILTER_SNAPSHOTS, and * that's what we check against in extents mode: */ - if (k.k->p.inode > end.inode) + if (unlikely(!(iter->flags & BTREE_ITER_IS_EXTENTS) + ? bkey_gt(k.k->p, end) + : k.k->p.inode > end.inode)) goto end; if (iter->update_path && Patches currently in stable-queue which might be from kent.overstreet@xxxxxxxxx are queue-6.7/bcachefs-check-for-failure-to-downgrade.patch queue-6.7/bcachefs-install-fd-later-to-avoid-race-with-close.patch queue-6.7/bcachefs-fix-simulateously-upgrading-downgrading.patch queue-6.7/bcachefs-fix-btree_iter_filter_snapshots-on-inodes-btree.patch queue-6.7/bcachefs-fix-build-on-parisc-by-avoiding-__multi3.patch