linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET v3 0/1] fstests: fix unshare data corruption bug
@ 2023-10-09 18:18 Darrick J. Wong
  2023-10-09 18:19 ` [PATCH 1/1] generic: test FALLOC_FL_UNSHARE when pagecache is not loaded Darrick J. Wong
  0 siblings, 1 reply; 6+ messages in thread
From: Darrick J. Wong @ 2023-10-09 18:18 UTC (permalink / raw)
  To: djwong, zlang
  Cc: Ritesh Harjani (IBM), linux-xfs, fstests, guan, ritesh.list,
	willy

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.

v2: reduce redundant variable access
v3: add rvb tags

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

fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=iomap-fix-unshare
---
 tests/xfs/1936     |   87 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/1936.out |    4 ++
 2 files changed, 91 insertions(+)
 create mode 100755 tests/xfs/1936
 create mode 100644 tests/xfs/1936.out


^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCHSET v2 0/1] fstests: fix unshare data corruption bug
@ 2023-09-25 21:43 Darrick J. Wong
  2023-09-25 21:43 ` [PATCH 1/1] generic: test FALLOC_FL_UNSHARE when pagecache is not loaded Darrick J. Wong
  0 siblings, 1 reply; 6+ messages in thread
From: Darrick J. Wong @ 2023-09-25 21:43 UTC (permalink / raw)
  To: djwong, zlang; +Cc: linux-xfs, fstests, guan, ritesh.list, willy

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.

v2: reduce redundant variable access

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

fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=iomap-fix-unshare
---
 tests/xfs/1936     |   88 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/1936.out |    4 ++
 2 files changed, 92 insertions(+)
 create mode 100755 tests/xfs/1936
 create mode 100644 tests/xfs/1936.out


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-10-10  7:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-09 18:18 [PATCHSET v3 0/1] fstests: fix unshare data corruption bug Darrick J. Wong
2023-10-09 18:19 ` [PATCH 1/1] generic: test FALLOC_FL_UNSHARE when pagecache is not loaded Darrick J. Wong
2023-10-10  7:05   ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2023-09-25 21:43 [PATCHSET v2 0/1] fstests: fix unshare data corruption bug Darrick J. Wong
2023-09-25 21:43 ` [PATCH 1/1] generic: test FALLOC_FL_UNSHARE when pagecache is not loaded Darrick J. Wong
2023-09-26  5:21   ` Ritesh Harjani
2023-09-26 14:47     ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).