summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2023-05-02 09:14:51 +1000
committerDave Chinner <dchinner@redhat.com>2023-05-02 09:14:51 +1000
commit1f1397b7218d7f8e53e33c6b58cbf9601cd2d8e6 (patch)
treeba31b944b970f221adae3cc8f530af1eebd3d364 /fs
parent397b2d7e0f3e28bbeaa05cf8e10d0fd601f446f4 (diff)
downloadlinux-stable-1f1397b7218d7f8e53e33c6b58cbf9601cd2d8e6.tar.gz
linux-stable-1f1397b7218d7f8e53e33c6b58cbf9601cd2d8e6.tar.bz2
linux-stable-1f1397b7218d7f8e53e33c6b58cbf9601cd2d8e6.zip
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_iomap.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 285885c308bd..18c8f168b153 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -1006,8 +1006,9 @@ xfs_buffered_write_iomap_begin(
if (eof)
imap.br_startoff = end_fsb; /* fake hole until the end */
- /* We never need to allocate blocks for zeroing a hole. */
- if ((flags & IOMAP_ZERO) && imap.br_startoff > offset_fsb) {
+ /* We never need to allocate blocks for zeroing or unsharing a hole. */
+ if ((flags & (IOMAP_UNSHARE | IOMAP_ZERO)) &&
+ imap.br_startoff > offset_fsb) {
xfs_hole_to_iomap(ip, iomap, offset_fsb, imap.br_startoff);
goto out_unlock;
}