]> www.infradead.org Git - users/jedix/linux-maple.git/commit
iomap: improve shared block detection in iomap_unshare_iter
authorChristoph Hellwig <hch@lst.de>
Tue, 10 Sep 2024 04:39:04 +0000 (07:39 +0300)
committerChristian Brauner <brauner@kernel.org>
Tue, 10 Sep 2024 09:13:43 +0000 (11:13 +0200)
commitb53fdb215d13f8e9c29541434bf2d14dac8bcbdc
tree44ff5357a01a5237bab6f2c871edfa4181d7ad4f
parent7a9d43eace888a0ee6095035997bb138425844d3
iomap: improve shared block detection in iomap_unshare_iter

Currently iomap_unshare_iter relies on the IOMAP_F_SHARED flag to detect
blocks to unshare.  This is reasonable, but IOMAP_F_SHARED is also useful
for the file system to do internal book keeping for out of place writes.
XFS used to that, until it got removed in commit 72a048c1056a
("xfs: only set IOMAP_F_SHARED when providing a srcmap to a write")
because unshare for incorrectly unshare such blocks.

Add an extra safeguard by checking the explicitly provided srcmap instead
of the fallback to the iomap for valid data, as that catches the case
where we'd just copy from the same place we'd write to easily, allowing
to reinstate setting IOMAP_F_SHARED for all XFS writes that go to the
COW fork.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240910043949.3481298-3-hch@lst.de
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/iomap/buffered-io.c