Skip to content

Commit f6f91d2

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: punch delalloc extents from the COW fork for COW writes
When ->iomap_end is called on a short write to the COW fork it needs to punch stale delalloc data from the COW fork and not the data fork. Ensure that IOMAP_F_NEW is set for new COW fork allocations in xfs_buffered_write_iomap_begin, and then use the IOMAP_F_SHARED flag in xfs_buffered_write_delalloc_punch to decide which fork to punch. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent 7d6fe5c commit f6f91d2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

fs/xfs/xfs_iomap.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ xfs_buffered_write_iomap_begin(
11961196
imap.br_startoff - offset_fsb);
11971197
}
11981198

1199-
iomap_flags = IOMAP_F_SHARED;
1199+
iomap_flags |= IOMAP_F_SHARED;
12001200
seq = xfs_iomap_inode_sequence(ip, iomap_flags);
12011201
xfs_iunlock(ip, lockmode);
12021202
return xfs_bmbt_to_iomap(ip, iomap, &cmap, flags, iomap_flags, seq);
@@ -1213,8 +1213,10 @@ xfs_buffered_write_delalloc_punch(
12131213
loff_t length,
12141214
struct iomap *iomap)
12151215
{
1216-
xfs_bmap_punch_delalloc_range(XFS_I(inode), XFS_DATA_FORK, offset,
1217-
offset + length);
1216+
xfs_bmap_punch_delalloc_range(XFS_I(inode),
1217+
(iomap->flags & IOMAP_F_SHARED) ?
1218+
XFS_COW_FORK : XFS_DATA_FORK,
1219+
offset, offset + length);
12181220
}
12191221

12201222
static int

0 commit comments

Comments
 (0)