xfs: only cancel cow blocks when truncating the data fork
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 10 Apr 2018 15:28:33 +0000 (08:28 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 10 Apr 2018 15:28:33 +0000 (08:28 -0700)
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.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_inode.c

index c09774ca53ae371d716b0d0703fcd940177a24e2..2b70c8b4cee2dd345b71ed48272c3d26969d104b 100644 (file)
@@ -1602,13 +1602,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