]> git.ipfire.org Git - thirdparty/linux.git/commit
iomap: don't mark folio uptodate if read IO has bytes pending
authorJoanne Koong <joannelkoong@gmail.com>
Tue, 3 Mar 2026 23:34:20 +0000 (15:34 -0800)
committerChristian Brauner <brauner@kernel.org>
Wed, 4 Mar 2026 13:18:54 +0000 (14:18 +0100)
commitdebc1a492b2695d05973994fb0f796dbd9ceaae6
tree1ff9744bb6f965c2c1cecabbd224732de0c52c21
parent10047142d6ce3b8562546c61f3cf57f852b9b950
iomap: don't mark folio uptodate if read IO has bytes pending

If a folio has ifs metadata attached to it and the folio is partially
read in through an async IO helper with the rest of it then being read
in through post-EOF zeroing or as inline data, and the helper
successfully finishes the read first, then post-EOF zeroing / reading
inline will mark the folio as uptodate in iomap_set_range_uptodate().

This is a problem because when the read completion path later calls
iomap_read_end(), it will call folio_end_read(), which sets the uptodate
bit using XOR semantics. Calling folio_end_read() on a folio that was
already marked uptodate clears the uptodate bit.

Fix this by not marking the folio as uptodate if the read IO has bytes
pending. The folio uptodate state will be set in the read completion
path through iomap_end_read() -> folio_end_read().

Reported-by: Wei Gao <wegao@suse.com>
Suggested-by: Sasha Levin <sashal@kernel.org>
Tested-by: Wei Gao <wegao@suse.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Cc: stable@vger.kernel.org # v6.19
Link: https://lore.kernel.org/linux-fsdevel/aYbmy8JdgXwsGaPP@autotest-wegao.qe.prg2.suse.org/
Fixes: b2f35ac4146d ("iomap: add caller-provided callbacks for read and readahead")
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Link: https://patch.msgid.link/20260303233420.874231-2-joannelkoong@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/iomap/buffered-io.c