[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251223223018.3295372-1-sashal@kernel.org>
Date: Tue, 23 Dec 2025 17:30:16 -0500
From: Sasha Levin <sashal@...nel.org>
To: joannelkoong@...il.com
Cc: willy@...radead.org,
linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
Sasha Levin <sashal@...nel.org>
Subject: [RFC PATCH 0/1] iomap: fix race between iomap_set_range_uptodate and folio_end_read
Hi Joanne,
While testing with your FUSE iomap patchset that recently landed upstream,
I ran into a warning in ifs_free() where the folio's uptodate flag didn't
match the ifs per-block uptodate bitmap. The warning was triggered during
FUSE-based filesystem unmount when running the LTP writev03 test.
After some investigation, I believe the root cause is a race condition
that has existed since commit 7a4847e54cc1 ("iomap: use folio_end_read()")
but was difficult to trigger until now. The issue is that folio_end_read()
uses XOR semantics to set the uptodate bit, so if iomap_set_range_uptodate()
calls folio_mark_uptodate() while a read is in progress, the subsequent
folio_end_read() will XOR and clear the uptodate bit.
The FUSE iomap enablement seems to have created the right conditions to
expose this race - likely due to different file extent patterns in
FUSE-based filesystems (like NTFS-3G) compared to native filesystems
like XFS/ext4.
The fix checks read_bytes_pending under the state_lock in
iomap_set_range_uptodate() and skips calling folio_mark_uptodate() if a
read is in progress, letting the read completion path handle it.
I'm not very familiar with the iomap internals, so I'd really appreciate
your review and feedback on whether this approach is correct.
Thanks,
Sasha
Sasha Levin (1):
iomap: fix race between iomap_set_range_uptodate and folio_end_read
fs/fuse/dev.c | 3 +-
fs/fuse/file.c | 6 ++--
fs/iomap/buffered-io.c | 65 +++++++++++++++++++++++++++++++++++++++---
include/linux/iomap.h | 2 ++
4 files changed, 68 insertions(+), 8 deletions(-)
--
2.51.0
Powered by blists - more mailing lists