diff mbox series

[1/4] xfs: don't allocate COW extents when unsharing a hole

Message ID 172796813277.1131942.5486112889531210260.stgit@frogsfrogsfrogs (mailing list archive)
State New
Headers show
Series [1/4] xfs: don't allocate COW extents when unsharing a hole | expand

Commit Message

Darrick J. Wong Oct. 3, 2024, 3:09 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

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>
---
 fs/xfs/xfs_iomap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christoph Hellwig Oct. 4, 2024, 12:07 p.m. UTC | #1
On Thu, Oct 03, 2024 at 08:09:01AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> 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")

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 1e11f48814c0..dc0443848485 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -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)