* [PATCH RFC] xfs: force all shared extent swap to use rmap shared path
@ 2026-11-25 14:59 cem
0 siblings, 0 replies; only message in thread
From: cem @ 2026-11-25 14:59 UTC (permalink / raw)
To: cem; +Cc: linux-xfs
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>
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
This is a second idea for the fix I sent earlier, please feel free to
ignore this patch. I am mostly interested on what Sashiko's review will
find on it.
fs/xfs/xfs_bmap_util.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 73e7db3203c0..2b6d93cb8e8f 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1303,16 +1303,20 @@ xfs_swap_extent_rmap(
xfs_filblks_t rlen;
int nimaps;
uint64_t tip_flags2;
+ uint64_t ip_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.
+ * If either file has shared blocks, flag both files as having shared
+ * blocks so that we get the shared-block rmap functions when we remap
+ * the extents to their new owners.
+ * The flags will be switch for real later.
*/
tip_flags2 = tip->i_diflags2;
- if (ip->i_diflags2 & XFS_DIFLAG2_REFLINK)
+ ip_flags2 = ip->i_diflags2;
+ if ((ip->i_diflags2 | tip->i_diflags2) & XFS_DIFLAG2_REFLINK) {
+ 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)));
@@ -1400,11 +1404,13 @@ xfs_swap_extent_rmap(
}
tip->i_diflags2 = tip_flags2;
+ ip->i_diflags2 = ip_flags2;
return 0;
out:
trace_xfs_swap_extent_rmap_error(ip, error, _RET_IP_);
tip->i_diflags2 = tip_flags2;
+ ip->i_diflags2 = ip_flags2;
return error;
}
--
2.56.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-25 14:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 14:59 [PATCH RFC] xfs: force all shared extent swap to use rmap shared path cem
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox