xfs: force all shared extent swap to use rmap shared path
Subsystems (2)
[email protected]
maintainercover xfs: force all shared extent swap to use rmap shared path
From: Carlos Maiolino <[email protected]>
This series fix an issue while swapping a shared extent between two files.
The first patch moves a trace point earlier in xfs_rmap, where it proved to be more useful at least while tracking this bug.
The second patch is the fix itself
Carlos Maiolino (2):
xfs: move _right_neighbor_result trace before erroring out
xfs: force all shared extent swap to use rmap shared path
fs/xfs/libxfs/xfs_rmap.c | 10 ++++++---- fs/xfs/xfs_bmap_util.c | 29 ++++++++--------------------- 2 files changed, 14 insertions(+), 25 deletions(-)
Signature · 1 line
2.56.1
[email protected]
maintainerPATCH 1/2 xfs: move _right_neighbor_result trace before erroring out
From: Carlos Maiolino <[email protected]>
The tracepoint doesn't help much if we find an invalid right record. Move it before we validate the record so it can still be printed even if we end up jumping to the error label.
--- fs/xfs/libxfs/xfs_rmap.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/xfs/libxfs/xfs_rmap.c +6 -4
@@ -1082,6 +1082,12 @@ xfs_rmap_map( error =xfs_rmap_get_rec (cur, >rec, &have_gt);if (error) goto out_error; + +trace_xfs_rmap_find_right_neighbor_result (cur, + gtrec.rm_startblock, gtrec.rm_blockcount, + gtrec.rm_owner, gtrec.rm_offset, + gtrec.rm_flags); +if (XFS_IS_CORRUPT (mp, have_gt !=1 )) {xfs_btree_mark_sick (cur); error = -EFSCORRUPTED ;
@@ -1092,10 +1098,6 @@ xfs_rmap_map( error = -EFSCORRUPTED ; goto out_error; } -trace_xfs_rmap_find_right_neighbor_result (cur, - gtrec.rm_startblock, gtrec.rm_blockcount, - gtrec.rm_owner, gtrec.rm_offset, - gtrec.rm_flags);if (!xfs_rmap_is_mergeable (>rec, owner, flags)) have_gt =0 ; }
Signature · 1 line
2.56.1
[email protected]
maintainerPATCH 2/2 xfs: force all shared extent swap to use rmap shared path
In reply to [email protected]From: Carlos Maiolino <[email protected]>
Currently when swapping inodes with shared extents in a rmap enabled FS, we enforce the rmap updates to use the rmap_shared path only when the target inode has shared extents, but we should also be using the rmap_shared path for the case when only the source inode's extent is shared.
--- fs/xfs/xfs_bmap_util.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-)
fs/xfs/xfs_bmap_util.c +8 -21
@@ -1302,17 +1302,6 @@ xfs_swap_extent_rmap(xfs_filblks_t ilen;xfs_filblks_t rlen;int nimaps; -uint64_t tip_flags2; - -/* -* If the source file has shared blocks, we must flag the donor -* file as having shared blocks so that we get the shared-block -* rmap functions when we go to fix up the rmaps. The flags -* will be switch for reals later. -*/ - tip_flags2 = tip->i_diflags2; -if (ip->i_diflags2 &XFS_DIFLAG2_REFLINK ) - tip->i_diflags2 |=XFS_DIFLAG2_REFLINK ; offset_fsb =0 ; end_fsb =XFS_B_TO_FSB (ip->i_mount,i_size_read (VFS_I (ip)));
@@ -1399,12 +1388,10 @@ xfs_swap_extent_rmap( offset_fsb += ilen; } - tip->i_diflags2 = tip_flags2;return 0 ; out:trace_xfs_swap_extent_rmap_error (ip, error, _RET_IP_); - tip->i_diflags2 = tip_flags2;return error; }
@@ -1705,14 +1692,6 @@ xfs_swap_extents( src_log_flags =XFS_ILOG_CORE ; target_log_flags =XFS_ILOG_CORE ; -if (xfs_has_rmapbt (mp)) - error =xfs_swap_extent_rmap (&tp, ip, tip); -else - error =xfs_swap_extent_forks (tp, ip, tip, &src_log_flags, - &target_log_flags); -if (error) - goto out_trans_cancel; -/* Either inode may now own shared blocks; flag both, with CoW forks. */ if ((ip->i_diflags2 | tip->i_diflags2) &XFS_DIFLAG2_REFLINK ) { ip->i_diflags2 |=XFS_DIFLAG2_REFLINK ;
@@ -1721,6 +1700,14 @@ xfs_swap_extents(xfs_ifork_init_cow (tip); } +if (xfs_has_rmapbt (mp)) + error =xfs_swap_extent_rmap (&tp, ip, tip); +else + error =xfs_swap_extent_forks (tp, ip, tip, &src_log_flags, + &target_log_flags); +if (error) + goto out_trans_cancel; +/* Swap the cow forks. */ if (xfs_has_reflink (mp)) { ASSERT(!ip->i_cowfp ||
Signature · 1 line
2.56.1
Carlos Maiolino
maintainerSorry the noise you all, I made a typo in the list's address, I'll resend it.
Quoted 21 lines · On Wed, Nov 25, 2026 at 02:26:27PM +0100, [email protected] wrote:
From: Carlos Maiolino <[email protected]>
This series fix an issue while swapping a shared extent between two files.
The first patch moves a trace point earlier in
xfs_rmap, where it proved to be more useful at least while tracking this bug.The second patch is the fix itself
Carlos Maiolino (2):
xfs: move_right_neighbor_resulttrace before erroring out
xfs: force all shared extent swap to use rmap shared pathfs/xfs/libxfs/xfs_rmap.c | 10 ++++++---- fs/xfs/xfs_bmap_util.c | 29 ++++++++--------------------- 2 files changed, 14 insertions(+), 25 deletions(-)Signature · 1 line
2.56.1