From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-api@vger.kernel.org
Subject: [PATCH 12/18] xfs: refactor reflink flag handling in xfs_swap_extent_forks
Date: Wed, 31 Mar 2021 18:09:53 -0700 [thread overview]
Message-ID: <161723939377.3149451.9062940592016276415.stgit@magnolia> (raw)
In-Reply-To: <161723932606.3149451.12366114306150243052.stgit@magnolia>
From: Darrick J. Wong <djwong@kernel.org>
Refactor the old data fork swap function to use the new reflink flag
helpers to propagate reflink flags between the two files.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/xfs_bmap_util.c | 58 +++++++++++++-----------------------------------
1 file changed, 16 insertions(+), 42 deletions(-)
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index bff8725082e8..7cd6a6d5fb00 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1404,17 +1404,21 @@ xfs_swap_change_owner(
STATIC int
xfs_swap_extent_forks(
struct xfs_trans **tpp,
- struct xfs_inode *ip,
- struct xfs_inode *tip)
+ struct xfs_swapext_req *req)
{
+ struct xfs_inode *ip = req->ip1;
+ struct xfs_inode *tip = req->ip2;
xfs_filblks_t aforkblks = 0;
xfs_filblks_t taforkblks = 0;
xfs_extnum_t junk;
uint64_t tmp;
+ unsigned int reflink_state;
int src_log_flags = XFS_ILOG_CORE;
int target_log_flags = XFS_ILOG_CORE;
int error;
+ reflink_state = xfs_swapext_reflink_prep(req);
+
/*
* Count the number of extended attribute blocks
*/
@@ -1494,36 +1498,7 @@ xfs_swap_extent_forks(
break;
}
- /* Do we have to swap reflink flags? */
- if ((ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK) ^
- (tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK)) {
- uint64_t f;
-
- f = ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
- ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
- ip->i_d.di_flags2 |= tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
- tip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
- tip->i_d.di_flags2 |= f & XFS_DIFLAG2_REFLINK;
- }
-
- /* Swap the cow forks. */
- if (xfs_sb_version_hasreflink(&ip->i_mount->m_sb)) {
- ASSERT(!ip->i_cowfp ||
- ip->i_cowfp->if_format == XFS_DINODE_FMT_EXTENTS);
- ASSERT(!tip->i_cowfp ||
- tip->i_cowfp->if_format == XFS_DINODE_FMT_EXTENTS);
-
- swap(ip->i_cowfp, tip->i_cowfp);
-
- if (ip->i_cowfp && ip->i_cowfp->if_bytes)
- xfs_inode_set_cowblocks_tag(ip);
- else
- xfs_inode_clear_cowblocks_tag(ip);
- if (tip->i_cowfp && tip->i_cowfp->if_bytes)
- xfs_inode_set_cowblocks_tag(tip);
- else
- xfs_inode_clear_cowblocks_tag(tip);
- }
+ xfs_swapext_reflink_finish(*tpp, req, reflink_state);
xfs_trans_log_inode(*tpp, ip, src_log_flags);
xfs_trans_log_inode(*tpp, tip, target_log_flags);
@@ -1554,6 +1529,11 @@ xfs_swap_extents(
struct xfs_inode *tip, /* tmp inode */
struct xfs_swapext *sxp)
{
+ struct xfs_swapext_req req = {
+ .ip1 = ip,
+ .ip2 = tip,
+ .whichfork = XFS_DATA_FORK,
+ };
struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp;
struct xfs_bstat *sbp = &sxp->sx_stat;
@@ -1689,17 +1669,11 @@ xfs_swap_extents(
* recovery is going to see the fork as owned by the swapped inode,
* not the pre-swapped inodes.
*/
- if (xfs_sb_version_hasrmapbt(&mp->m_sb)) {
- struct xfs_swapext_req req = {
- .ip1 = ip,
- .ip2 = tip,
- .whichfork = XFS_DATA_FORK,
- .blockcount = XFS_B_TO_FSB(ip->i_mount,
- i_size_read(VFS_I(ip))),
- };
+ req.blockcount = XFS_B_TO_FSB(ip->i_mount, i_size_read(VFS_I(ip)));
+ if (xfs_sb_version_hasrmapbt(&mp->m_sb))
error = xfs_swapext(&tp, &req);
- } else
- error = xfs_swap_extent_forks(&tp, ip, tip);
+ else
+ error = xfs_swap_extent_forks(&tp, &req);
if (error) {
trace_xfs_swap_extent_error(ip, error, _THIS_IP_);
goto out_trans_cancel;
next prev parent reply other threads:[~2021-04-01 1:10 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 1:08 [PATCHSET RFC v3 00/18] xfs: atomic file updates Darrick J. Wong
2021-04-01 1:08 ` [PATCH 01/18] vfs: introduce new file range exchange ioctl Darrick J. Wong
2021-04-01 1:44 ` Al Viro
2021-04-01 21:18 ` Darrick J. Wong
2021-04-01 3:32 ` Amir Goldstein
2021-04-02 0:37 ` Darrick J. Wong
2021-04-01 1:08 ` [PATCH 02/18] xfs: support two inodes in the defer capture structure Darrick J. Wong
2021-04-02 23:20 ` Allison Henderson
2021-04-01 1:09 ` [PATCH 03/18] xfs: allow setting and clearing of log incompat feature flags Darrick J. Wong
2021-04-02 23:20 ` Allison Henderson
2021-04-01 1:09 ` [PATCH 04/18] xfs: clear log incompat feature bits when the log is idle Darrick J. Wong
2021-04-02 23:20 ` Allison Henderson
2021-04-01 1:09 ` [PATCH 05/18] xfs: create a log incompat flag for atomic extent swapping Darrick J. Wong
2021-04-02 23:21 ` Allison Henderson
2021-04-01 1:09 ` [PATCH 06/18] xfs: introduce a swap-extent log intent item Darrick J. Wong
2021-04-05 23:08 ` Allison Henderson
2021-04-01 1:09 ` [PATCH 07/18] xfs: create deferred log items for extent swapping Darrick J. Wong
2021-04-01 1:09 ` [PATCH 08/18] xfs: add a ->xchg_file_range handler Darrick J. Wong
2021-04-01 1:09 ` [PATCH 09/18] xfs: add error injection to test swapext recovery Darrick J. Wong
2021-04-01 1:09 ` [PATCH 10/18] xfs: port xfs_swap_extents_rmap to our new code Darrick J. Wong
2021-04-01 1:09 ` [PATCH 11/18] xfs: consolidate all of the xfs_swap_extent_forks code Darrick J. Wong
2021-04-01 1:09 ` Darrick J. Wong [this message]
2021-04-01 1:09 ` [PATCH 13/18] xfs: allow xfs_swap_range to use older extent swap algorithms Darrick J. Wong
2021-04-01 1:10 ` [PATCH 14/18] xfs: remove old swap extents implementation Darrick J. Wong
2021-04-01 1:10 ` [PATCH 15/18] xfs: condense extended attributes after an atomic swap Darrick J. Wong
2021-04-01 1:10 ` [PATCH 16/18] xfs: condense directories " Darrick J. Wong
2021-04-01 1:10 ` [PATCH 17/18] xfs: make atomic extent swapping support realtime files Darrick J. Wong
2021-04-01 1:10 ` [PATCH 18/18] xfs: enable atomic swapext feature Darrick J. Wong
2021-04-01 3:56 ` [PATCHSET RFC v3 00/18] xfs: atomic file updates Amir Goldstein
2021-04-02 0:22 ` Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=161723939377.3149451.9062940592016276415.stgit@magnolia \
--to=djwong@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).