[PATCH 17/24] xfs: clear inode reflink flag when freeing blocks
Darrick J. Wong
darrick.wong at oracle.com
Wed Jul 29 17:34:47 CDT 2015
Clear the inode reflink flag when freeing or truncating all blocks
in a file.
Signed-off-by: Darrick J. Wong <darrick.wong at oracle.com>
---
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 345ea79..0091186 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1330,6 +1330,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 3da9f4d..1d97238 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1566,6 +1566,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.
*/
More information about the xfs
mailing list