Skip to content

Commit 8fe3b21

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: support the COW fork in xfs_bmap_punch_delalloc_range
xfs_buffered_write_iomap_begin can also create delallocate reservations that need cleaning up, prepare for that by adding support for the COW fork in xfs_bmap_punch_delalloc_range. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent abd7d65 commit 8fe3b21

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

fs/xfs/xfs_aops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ xfs_end_ioend(
116116
if (unlikely(error)) {
117117
if (ioend->io_flags & IOMAP_F_SHARED) {
118118
xfs_reflink_cancel_cow_range(ip, offset, size, true);
119-
xfs_bmap_punch_delalloc_range(ip, offset,
119+
xfs_bmap_punch_delalloc_range(ip, XFS_DATA_FORK, offset,
120120
offset + size);
121121
}
122122
goto done;
@@ -456,7 +456,7 @@ xfs_discard_folio(
456456
* byte of the next folio. Hence the end offset is only dependent on the
457457
* folio itself and not the start offset that is passed in.
458458
*/
459-
xfs_bmap_punch_delalloc_range(ip, pos,
459+
xfs_bmap_punch_delalloc_range(ip, XFS_DATA_FORK, pos,
460460
folio_pos(folio) + folio_size(folio));
461461
}
462462

fs/xfs/xfs_bmap_util.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,12 @@ xfs_getbmap(
442442
void
443443
xfs_bmap_punch_delalloc_range(
444444
struct xfs_inode *ip,
445+
int whichfork,
445446
xfs_off_t start_byte,
446447
xfs_off_t end_byte)
447448
{
448449
struct xfs_mount *mp = ip->i_mount;
449-
struct xfs_ifork *ifp = &ip->i_df;
450+
struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
450451
xfs_fileoff_t start_fsb = XFS_B_TO_FSBT(mp, start_byte);
451452
xfs_fileoff_t end_fsb = XFS_B_TO_FSB(mp, end_byte);
452453
struct xfs_bmbt_irec got, del;
@@ -474,11 +475,14 @@ xfs_bmap_punch_delalloc_range(
474475
continue;
475476
}
476477

477-
xfs_bmap_del_extent_delay(ip, XFS_DATA_FORK, &icur, &got, &del);
478+
xfs_bmap_del_extent_delay(ip, whichfork, &icur, &got, &del);
478479
if (!xfs_iext_get_extent(ifp, &icur, &got))
479480
break;
480481
}
481482

483+
if (whichfork == XFS_COW_FORK && !ifp->if_bytes)
484+
xfs_inode_clear_cowblocks_tag(ip);
485+
482486
out_unlock:
483487
xfs_iunlock(ip, XFS_ILOCK_EXCL);
484488
}
@@ -580,7 +584,7 @@ xfs_free_eofblocks(
580584
*/
581585
if (ip->i_diflags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) {
582586
if (ip->i_delayed_blks) {
583-
xfs_bmap_punch_delalloc_range(ip,
587+
xfs_bmap_punch_delalloc_range(ip, XFS_DATA_FORK,
584588
round_up(XFS_ISIZE(ip), mp->m_sb.sb_blocksize),
585589
LLONG_MAX);
586590
}

fs/xfs/xfs_bmap_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ xfs_bmap_rtalloc(struct xfs_bmalloca *ap)
3030
}
3131
#endif /* CONFIG_XFS_RT */
3232

33-
void xfs_bmap_punch_delalloc_range(struct xfs_inode *ip,
33+
void xfs_bmap_punch_delalloc_range(struct xfs_inode *ip, int whichfork,
3434
xfs_off_t start_byte, xfs_off_t end_byte);
3535

3636
struct kgetbmap {

fs/xfs/xfs_iomap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,8 @@ xfs_buffered_write_delalloc_punch(
12151215
loff_t length,
12161216
struct iomap *iomap)
12171217
{
1218-
xfs_bmap_punch_delalloc_range(XFS_I(inode), offset, offset + length);
1218+
xfs_bmap_punch_delalloc_range(XFS_I(inode), XFS_DATA_FORK, offset,
1219+
offset + length);
12191220
}
12201221

12211222
static int

0 commit comments

Comments
 (0)