Skip to content

Commit 204f451

Browse files
author
Kent Overstreet
committed
bcachefs: Fix BTREE_ITER_FILTER_SNAPSHOTS on inodes btree
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 <[email protected]>
1 parent 04fee68 commit 204f451

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/bcachefs/btree_iter.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,9 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e
21562156
* isn't monotonically increasing before FILTER_SNAPSHOTS, and
21572157
* that's what we check against in extents mode:
21582158
*/
2159-
if (k.k->p.inode > end.inode)
2159+
if (unlikely(!(iter->flags & BTREE_ITER_IS_EXTENTS)
2160+
? bkey_gt(k.k->p, end)
2161+
: k.k->p.inode > end.inode))
21602162
goto end;
21612163

21622164
if (iter->update_path &&

0 commit comments

Comments
 (0)