diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2017-09-18 12:41:18 -0400 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2017-10-04 00:27:55 -0400 |
commit | 52bfcdd7adbc26639bc7b2356ab9a3f5dad68ad6 (patch) | |
tree | fc23f5f901dee20a30fdb225b7110eb1635a7ca4 | |
parent | 5e5c943c1f257c2b3424fc3f8a7b18570152dab3 (diff) |
xfs: always swap the cow forks when swapping extents
Since the CoW fork exists as a secondary data structure to the data
fork, we must always swap cow forks during swapext. We also need to
swap the extent counts and reset the cowblocks tags.
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
-rw-r--r-- | fs/xfs/xfs_bmap_util.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index bc6c6e10a969..e9db7fc95b70 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c | |||
@@ -2122,11 +2122,31 @@ xfs_swap_extents( | |||
2122 | ip->i_d.di_flags2 |= tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK; | 2122 | ip->i_d.di_flags2 |= tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK; |
2123 | tip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; | 2123 | tip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; |
2124 | tip->i_d.di_flags2 |= f & XFS_DIFLAG2_REFLINK; | 2124 | tip->i_d.di_flags2 |= f & XFS_DIFLAG2_REFLINK; |
2125 | } | ||
2126 | |||
2127 | /* Swap the cow forks. */ | ||
2128 | if (xfs_sb_version_hasreflink(&mp->m_sb)) { | ||
2129 | xfs_extnum_t extnum; | ||
2130 | |||
2131 | ASSERT(ip->i_cformat == XFS_DINODE_FMT_EXTENTS); | ||
2132 | ASSERT(tip->i_cformat == XFS_DINODE_FMT_EXTENTS); | ||
2133 | |||
2134 | extnum = ip->i_cnextents; | ||
2135 | ip->i_cnextents = tip->i_cnextents; | ||
2136 | tip->i_cnextents = extnum; | ||
2137 | |||
2125 | cowfp = ip->i_cowfp; | 2138 | cowfp = ip->i_cowfp; |
2126 | ip->i_cowfp = tip->i_cowfp; | 2139 | ip->i_cowfp = tip->i_cowfp; |
2127 | tip->i_cowfp = cowfp; | 2140 | tip->i_cowfp = cowfp; |
2128 | xfs_inode_set_cowblocks_tag(ip); | 2141 | |
2129 | xfs_inode_set_cowblocks_tag(tip); | 2142 | if (ip->i_cowfp && ip->i_cnextents) |
2143 | xfs_inode_set_cowblocks_tag(ip); | ||
2144 | else | ||
2145 | xfs_inode_clear_cowblocks_tag(ip); | ||
2146 | if (tip->i_cowfp && tip->i_cnextents) | ||
2147 | xfs_inode_set_cowblocks_tag(tip); | ||
2148 | else | ||
2149 | xfs_inode_clear_cowblocks_tag(tip); | ||
2130 | } | 2150 | } |
2131 | 2151 | ||
2132 | xfs_trans_log_inode(tp, ip, src_log_flags); | 2152 | xfs_trans_log_inode(tp, ip, src_log_flags); |