diff mbox series

[12/14] xfs: validate COW fork sequence counters during buffered writes

Message ID 166801781202.3992140.14867094485108244588.stgit@magnolia (mailing list archive)
State New, archived
Headers show
Series xfs, iomap: fix data corruption due to stale cached iomaps | expand

Commit Message

Darrick J. Wong Nov. 9, 2022, 6:16 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

In the previous patch, we transformed the iomap revalidation code to use
an explicit context object where data and cow fork sequence counters are
tracked explicitly.  The existing validation function only validated the
data fork sequence counter, so now let's make it validate both.

I /think/ this isn't actually necessary here because we're writing to
the page cache, and the page state does not track or care about cow
status.  However, this question came up when Dave and I were chatting
about this patchset on IRC, so here it is for formal consideration.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/xfs_iomap.c |    3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index c3c23524a3d2..5e746df2c63f 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -1370,6 +1370,9 @@  xfs_buffered_write_iomap_valid(
 
 	if (ibc->data_seq != READ_ONCE(ip->i_df.if_seq))
 		return false;
+	if (ibc->has_cow_seq &&
+	    ibc->cow_seq != READ_ONCE(ip->i_cowfp->if_seq))
+		return false;
 	return true;
 }