Skip to content

Commit 1f1397b

Browse files
Darrick J. Wongdgchinner
authored andcommitted
xfs: don't allocate into the data fork for an unshare request
For an unshare request, we only have to take action if the data fork has a shared mapping. We don't care if someone else set up a cow operation. If we find nothing in the data fork, return a hole to avoid allocating space. Note that fallocate will replace the delalloc reservation with an unwritten extent anyway, so this has no user-visible effects outside of avoiding unnecessary updates. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
1 parent 397b2d7 commit 1f1397b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

fs/xfs/xfs_iomap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,9 @@ xfs_buffered_write_iomap_begin(
10061006
if (eof)
10071007
imap.br_startoff = end_fsb; /* fake hole until the end */
10081008

1009-
/* We never need to allocate blocks for zeroing a hole. */
1010-
if ((flags & IOMAP_ZERO) && imap.br_startoff > offset_fsb) {
1009+
/* We never need to allocate blocks for zeroing or unsharing a hole. */
1010+
if ((flags & (IOMAP_UNSHARE | IOMAP_ZERO)) &&
1011+
imap.br_startoff > offset_fsb) {
10111012
xfs_hole_to_iomap(ip, iomap, offset_fsb, imap.br_startoff);
10121013
goto out_unlock;
10131014
}

0 commit comments

Comments
 (0)