mbox series

[PATCHSET,0/2] iomap: fix unshare data corruption bug

Message ID 169507871947.772278.5767091361086740046.stgit@frogsfrogsfrogs (mailing list archive)
Headers show
Series iomap: fix unshare data corruption bug | expand

Message

Darrick J. Wong Sept. 18, 2023, 11:11 p.m. UTC
Hi all,

I rebased djwong-dev atop 6.6-rc1, and discovered that the iomap unshare
code writes garbage into the unshared file if the unshared range covers
at least one base page's worth of file range and there weren't any
folios in the pagecache for that region.

The root cause is an optimization applied to __iomap_write_begin for 6.6
that caused it to ignore !uptodate folios.  This is fine for the
write/zeroing cases since they're going to write to the folio anyway,
but unshare merely marks the folio dirty and lets writeback handle the
unsharing.

While I was rooting around in there, I also noticed that the unshare
operation wasn't ported to use large folios.  This leads to suboptimal
performance if userspace funshares a file and continues using the page
cache, since the cache is now using base pages.

If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.

This has been lightly tested with fstests.  Enjoy!
Comments and questions are, as always, welcome.

--D

kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=iomap-fix-unshare-6.6
---
 fs/iomap/buffered-io.c |   28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)