diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-02-24 19:14:36 -0500 |
---|---|---|
committer | Sasha Levin <sashal@kernel.org> | 2024-03-26 18:18:50 -0400 |
commit | 2da31af6e876b90301227005a1775c10813923ee (patch) | |
tree | fc91a0b3308b9adefd769510734278ed35d2b87e /fs | |
parent | 0b7d401d0b001036ccf93d4d688fdc626a05e53b (diff) | |
download | linux-stable-2da31af6e876b90301227005a1775c10813923ee.tar.gz linux-stable-2da31af6e876b90301227005a1775c10813923ee.tar.bz2 linux-stable-2da31af6e876b90301227005a1775c10813923ee.zip |
bcachefs: Fix BTREE_ITER_FILTER_SNAPSHOTS on inodes btree
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@linux.dev>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/btree_iter.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index da594e006769..816ecc337519 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2094,7 +2094,9 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e * 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 && |