xfs: don't allocate COW extents when unsharing a hole
authorDarrick J. Wong <djwong@kernel.org>
Thu, 3 Oct 2024 15:09:01 +0000 (08:09 -0700)
committerChristian Brauner <brauner@kernel.org>
Mon, 7 Oct 2024 11:51:46 +0000 (13:51 +0200)
It doesn't make sense to allocate a COW extent when unsharing a hole
because holes cannot be shared.

Fixes: 1f1397b7218d7 ("xfs: don't allocate into the data fork for an unshare request")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/172796813277.1131942.5486112889531210260.stgit@frogsfrogsfrogs
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/xfs/xfs_iomap.c

index 1e11f48..dc04438 100644 (file)
@@ -707,7 +707,7 @@ imap_needs_cow(
                return false;
 
        /* when zeroing we don't have to COW holes or unwritten extents */
-       if (flags & IOMAP_ZERO) {
+       if (flags & (IOMAP_UNSHARE | IOMAP_ZERO)) {
                if (!nimaps ||
                    imap->br_startblock == HOLESTARTBLOCK ||
                    imap->br_state == XFS_EXT_UNWRITTEN)