bcachefs: Fix extents iteration + snapshots interaction
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 29 Dec 2023 18:39:07 +0000 (13:39 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 1 Jan 2024 16:42:39 +0000 (11:42 -0500)
commitfa014953f9409edd32b04cb5c0f4167b8a537e65
tree39d24c456a3a19ad0ef102b8b2b309d57ad1b576
parent453f5db0619e2ad64076aab16ff5a00e0f7c53a2
bcachefs: Fix extents iteration + snapshots interaction

peek_upto() checks against the end position and bails out before
FILTER_SNAPSHOTS checks; this is because if we end up at a different
inode number than the original search key none of the keys we see might
be visibile in the current snapshot - we might be looking at inode in a
completely different subvolume.

But this is broken, because when we're iterating over extents we're
checking against the extent start position to decide when to bail out,
and the extent start position isn't monotonically increasing until after
we've run FILTER_SNAPSHOTS.

Fix this by adding a simple inode number check where the old bailout
check was, and moving the main check to the correct position.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Reported-by: "Carl E. Thompson" <list-bcachefs@carlthompson.net>
fs/bcachefs/btree_iter.c