From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Darrick J. Wong" Subject: [PATCH 49/58] xfs: clear inode reflink flag when freeing blocks Date: Tue, 06 Oct 2015 22:00:31 -0700 Message-ID: <20151007050031.30457.60740.stgit@birch.djwong.org> References: <20151007045443.30457.47038.stgit@birch.djwong.org> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, xfs@oss.sgi.com To: david@fromorbit.com, darrick.wong@oracle.com Return-path: Received: from aserp1040.oracle.com ([141.146.126.69]:36787 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752765AbbJGFAl (ORCPT ); Wed, 7 Oct 2015 01:00:41 -0400 In-Reply-To: <20151007045443.30457.47038.stgit@birch.djwong.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Clear the inode reflink flag when freeing or truncating all blocks in a file. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_bmap_util.c | 8 ++++++++ fs/xfs/xfs_inode.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index b054b28..b20d136 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1338,6 +1338,14 @@ xfs_free_file_space( } /* + * Clear the reflink flag if we freed everything. + */ + if (ip->i_d.di_nblocks == 0 && xfs_is_reflink_inode(ip)) { + ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); + } + + /* * complete the transaction */ error = xfs_bmap_finish(&tp, &free_list, &committed); diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index dc40a6d..61a468b 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1613,6 +1613,12 @@ xfs_itruncate_extents( } /* + * Clear the reflink flag if we truncated everything. + */ + if (ip->i_d.di_nblocks == 0 && xfs_is_reflink_inode(ip)) + ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; + + /* * Always re-log the inode so that our permanent transaction can keep * on rolling it forward in the log. */