* [PATCH 0/2] xfs: force all shared extent swap to use rmap shared path
@ 2026-11-25 13:31 cem
2026-11-25 13:31 ` [PATCH 1/2] xfs: move _right_neighbor_result trace before erroring out cem
2026-11-25 13:31 ` [PATCH 2/2] xfs: force all shared extent swap to use rmap shared path cem
0 siblings, 2 replies; 5+ messages in thread
From: cem @ 2026-11-25 13:31 UTC (permalink / raw)
To: cem; +Cc: linux-xfs, hch, sandeen, dgc, aalbersh, bfoster, stable
From: Carlos Maiolino <cem@kernel.org>
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(-)
--
2.56.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] xfs: move _right_neighbor_result trace before erroring out
2026-11-25 13:31 [PATCH 0/2] xfs: force all shared extent swap to use rmap shared path cem
@ 2026-11-25 13:31 ` cem
2026-11-25 13:31 ` [PATCH 2/2] xfs: force all shared extent swap to use rmap shared path cem
1 sibling, 0 replies; 5+ messages in thread
From: cem @ 2026-11-25 13:31 UTC (permalink / raw)
To: cem; +Cc: linux-xfs, hch, sandeen, dgc, aalbersh, bfoster, stable
From: Carlos Maiolino <cem@kernel.org>
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.
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
fs/xfs/libxfs/xfs_rmap.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
index 14aef87837a9..5f88aa9f12cb 100644
--- a/fs/xfs/libxfs/xfs_rmap.c
+++ b/fs/xfs/libxfs/xfs_rmap.c
@@ -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;
}
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] xfs: force all shared extent swap to use rmap shared path
2026-11-25 13:31 [PATCH 0/2] xfs: force all shared extent swap to use rmap shared path cem
2026-11-25 13:31 ` [PATCH 1/2] xfs: move _right_neighbor_result trace before erroring out cem
@ 2026-11-25 13:31 ` cem
1 sibling, 0 replies; 5+ messages in thread
From: cem @ 2026-11-25 13:31 UTC (permalink / raw)
To: cem; +Cc: linux-xfs, hch, sandeen, dgc, aalbersh, bfoster, stable
From: Carlos Maiolino <cem@kernel.org>
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.
Reported-by: Lauri Gates <lauri.gates@gmail.com>
Fixes: 1f08af52e7c9 ("xfs: implement swapext for rmap filesystems")
Cc: stable@vger.kernel.org
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_bmap_util.c | 29 ++++++++---------------------
1 file changed, 8 insertions(+), 21 deletions(-)
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 73e7db3203c0..4704222d9544 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -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 ||
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 0/2] xfs: force all shared extent swap to use rmap shared path
@ 2026-11-25 13:26 cem
2026-11-25 13:31 ` Carlos Maiolino
0 siblings, 1 reply; 5+ messages in thread
From: cem @ 2026-11-25 13:26 UTC (permalink / raw)
To: cem; +Cc: linux-xfs, hch, sandeen, dgc, aalbersh, bfoster, stable
From: Carlos Maiolino <cem@kernel.org>
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(-)
--
2.56.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] xfs: force all shared extent swap to use rmap shared path
2026-11-25 13:26 [PATCH 0/2] " cem
@ 2026-11-25 13:31 ` Carlos Maiolino
0 siblings, 0 replies; 5+ messages in thread
From: Carlos Maiolino @ 2026-11-25 13:31 UTC (permalink / raw)
To: hch, sandeen, dgc, aalbersh, bfoster, stable
Sorry the noise you all, I made a typo in the list's address, I'll
resend it.
On Wed, Nov 25, 2026 at 02:26:27PM +0100, cem@kernel.org wrote:
> From: Carlos Maiolino <cem@kernel.org>
>
> 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(-)
>
> --
> 2.56.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-25 13:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 13:31 [PATCH 0/2] xfs: force all shared extent swap to use rmap shared path cem
2026-11-25 13:31 ` [PATCH 1/2] xfs: move _right_neighbor_result trace before erroring out cem
2026-11-25 13:31 ` [PATCH 2/2] xfs: force all shared extent swap to use rmap shared path cem
-- strict thread matches above, loose matches on Subject: below --
2026-11-25 13:26 [PATCH 0/2] " cem
2026-11-25 13:31 ` Carlos Maiolino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox