Skip to content

Commit 7d6fe5c

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: set IOMAP_F_SHARED for all COW fork allocations
Change to always set xfs_buffered_write_iomap_begin for COW fork allocations even if they don't overlap existing data fork extents, which will allow the iomap_end callback to detect if it has to punch stale delalloc blocks from the COW fork instead of the data fork. It also means we sample the sequence counter for both the data and the COW fork when writing to the COW fork, which ensures we properly revalidate when only COW fork changes happens. This is essentially a revert of commit 72a048c ("xfs: only set IOMAP_F_SHARED when providing a srcmap to a write"). This is fine because the problem that the commit fixed has now been dealt with in iomap by only looking at the actual srcmap and not the fallback to the write iomap. Note that the direct I/O path was never changed and has always set IOMAP_F_SHARED for all COW fork allocations. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent c29440f commit 7d6fe5c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

fs/xfs/xfs_iomap.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,20 +1186,20 @@ xfs_buffered_write_iomap_begin(
11861186
return 0;
11871187

11881188
found_cow:
1189-
seq = xfs_iomap_inode_sequence(ip, 0);
11901189
if (imap.br_startoff <= offset_fsb) {
1191-
error = xfs_bmbt_to_iomap(ip, srcmap, &imap, flags, 0, seq);
1190+
error = xfs_bmbt_to_iomap(ip, srcmap, &imap, flags, 0,
1191+
xfs_iomap_inode_sequence(ip, 0));
11921192
if (error)
11931193
goto out_unlock;
1194-
seq = xfs_iomap_inode_sequence(ip, IOMAP_F_SHARED);
1195-
xfs_iunlock(ip, lockmode);
1196-
return xfs_bmbt_to_iomap(ip, iomap, &cmap, flags,
1197-
IOMAP_F_SHARED, seq);
1194+
} else {
1195+
xfs_trim_extent(&cmap, offset_fsb,
1196+
imap.br_startoff - offset_fsb);
11981197
}
11991198

1200-
xfs_trim_extent(&cmap, offset_fsb, imap.br_startoff - offset_fsb);
1199+
iomap_flags = IOMAP_F_SHARED;
1200+
seq = xfs_iomap_inode_sequence(ip, iomap_flags);
12011201
xfs_iunlock(ip, lockmode);
1202-
return xfs_bmbt_to_iomap(ip, iomap, &cmap, flags, 0, seq);
1202+
return xfs_bmbt_to_iomap(ip, iomap, &cmap, flags, iomap_flags, seq);
12031203

12041204
out_unlock:
12051205
xfs_iunlock(ip, lockmode);

0 commit comments

Comments
 (0)