xfs
[Top] [All Lists]

[PATCH 62/76] xfs: clear inode reflink flag when freeing blocks

To: david@xxxxxxxxxxxxx, darrick.wong@xxxxxxxxxx
Subject: [PATCH 62/76] xfs: clear inode reflink flag when freeing blocks
From: "Darrick J. Wong" <darrick.wong@xxxxxxxxxx>
Date: Sat, 19 Dec 2015 01:03:19 -0800
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <20151219085622.12713.88678.stgit@xxxxxxxxxxxxxxxx>
References: <20151219085622.12713.88678.stgit@xxxxxxxxxxxxxxxx>
User-agent: StGit/0.17.1-dirty
Clear the inode reflink flag when freeing or truncating all blocks
in a file.

Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
---
 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 983d8f6..dd5a2f7 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1390,6 +1390,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, NULL);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 55a7e00..a323631 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.
         */

<Prev in Thread] Current Thread [Next in Thread>