Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc6f7771 authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: don't unconditionally clear the reflink flag on zero-block files



If we have speculative cow preallocations hanging around in the cow
fork, don't let a truncate operation clear the reflink flag because if
we do then there's a chance we'll forget to free those extents when we
destroy the incore inode.

Reported-by: default avatarAmir Goldstein <amir73il@gmail.com>
Reviewed-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 2bd6bf03
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -1624,9 +1624,11 @@ xfs_itruncate_extents(
		goto out;

	/*
	 * Clear the reflink flag if we truncated everything.
	 * Clear the reflink flag if there are no data fork blocks and
	 * there are no extents staged in the cow fork.
	 */
	if (ip->i_d.di_nblocks == 0 && xfs_is_reflink_inode(ip)) {
	if (xfs_is_reflink_inode(ip) && ip->i_cnextents == 0) {
		if (ip->i_d.di_nblocks == 0)
			ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
		xfs_inode_clear_cowblocks_tag(ip);
	}