From fd6819e541fa9806e1df364ca7a1174c01f5bf14 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Tue, 28 May 2024 21:13:30 -0700 Subject: [PATCH] xfs: enable realtime reflink Enable reflink for realtime devices, sort of. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_rtalloc.c | 6 ++++-- fs/xfs/xfs_super.c | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index db859d626272..2facc87a87f0 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -1224,9 +1224,11 @@ xfs_growfs_rt( return -EINVAL; /* Unsupported realtime features. */ - if (!xfs_has_rtgroups(mp) && xfs_has_rmapbt(mp)) + if (!xfs_has_rtgroups(mp) && (xfs_has_rmapbt(mp) || xfs_has_reflink(mp))) return -EOPNOTSUPP; - if (xfs_has_reflink(mp) || xfs_has_quota(mp)) + if (xfs_has_quota(mp)) + return -EOPNOTSUPP; + if (xfs_has_reflink(mp) && in->extsize != 1) return -EOPNOTSUPP; error = xfs_sb_validate_fsb_count(&mp->m_sb, in->newblocks); diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index b9c65a3f3543..02e16cb52429 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1741,14 +1741,27 @@ xfs_fs_fill_super( "EXPERIMENTAL realtime superblock feature in use. Use at your own risk!"); if (xfs_has_reflink(mp)) { - if (mp->m_sb.sb_rblocks) { + /* + * Reflink doesn't support rt extent sizes larger than a single + * block because we would have to perform unshare-around for + * rtext-unaligned write requests. + */ + if (xfs_has_realtime(mp) && mp->m_sb.sb_rextsize != 1) { xfs_alert(mp, - "reflink not compatible with realtime device!"); + "reflink not compatible with realtime extent size %u!", + mp->m_sb.sb_rextsize); error = -EINVAL; goto out_filestream_unmount; } - if (xfs_globals.always_cow) { + /* + * always-cow mode is not supported on filesystems with rt + * extent sizes larger than a single block because we'd have + * to perform write-around for unaligned writes because remap + * requests must be aligned to an rt extent. + */ + if (xfs_globals.always_cow && + (!xfs_has_realtime(mp) || mp->m_sb.sb_rextsize == 1)) { xfs_info(mp, "using DEBUG-only always_cow mode."); mp->m_always_cow = true; } -- 2.50.1