Skip to contentSkip to conversation

xfs: only cancel cow blocks when truncating the data fork

PATCH In review Darrick J. Wong 2 participants 2 messages Apr 10, 2018 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: only cancel cow blocks when truncating the data fork

From: Darrick J. Wong <[email protected]>

In xfs_itruncate_extents, only cancel cow blocks and clear the reflink flag if we were asked to truncate the data fork. Attr fork blocks cannot be shared, so this makes no sense.

---
 fs/xfs/xfs_inode.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
fs/xfs/xfs_inode.c +8 -6
index e7907d2..383258e 100644
@@ -1611,13 +1611,15 @@ xfs_itruncate_extents(
 			goto out;
 	}
 
-	/* Remove all pending CoW reservations. */
-	error = xfs_reflink_cancel_cow_blocks(ip, &tp, first_unmap_block,
-			last_block, true);
-	if (error)
-		goto out;
+	if (whichfork == XFS_DATA_FORK) {
+		/* Remove all pending CoW reservations. */
+		error = xfs_reflink_cancel_cow_blocks(ip, &tp,
+				first_unmap_block, last_block, true);
+		if (error)
+			goto out;
 
-	xfs_itruncate_clear_reflink_flags(ip);
+		xfs_itruncate_clear_reflink_flags(ip);
+	}
 
 	/*
 	 * Always re-log the inode so that our permanent transaction can keep