]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: enable realtime reflink
authorDarrick J. Wong <djwong@kernel.org>
Mon, 23 Sep 2024 20:42:55 +0000 (13:42 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 2 Oct 2024 01:11:09 +0000 (18:11 -0700)
Enable reflink for realtime devices, sort of.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/xfs_rtalloc.c
fs/xfs/xfs_super.c

index ccd071d56d18c4fb4fb46d7cf5169fb7347c292d..3d2c34e0890a95d1c8efed717d881cd5ed87f391 100644 (file)
@@ -1285,9 +1285,11 @@ xfs_growfs_rt(
 
        /* Unsupported realtime features. */
        error = -EOPNOTSUPP;
-       if (!xfs_has_rtgroups(mp) && xfs_has_rmapbt(mp))
+       if (!xfs_has_rtgroups(mp) && (xfs_has_rmapbt(mp) || xfs_has_reflink(mp)))
                goto out_unlock;
-       if (xfs_has_reflink(mp) || xfs_has_quota(mp))
+       if (xfs_has_quota(mp))
+               goto out_unlock;
+       if (xfs_has_reflink(mp) && in->extsize != 1)
                goto out_unlock;
 
        error = xfs_sb_validate_fsb_count(&mp->m_sb, in->newblocks);
index a7daff57888e2ce0ec45b0f3c26905b13ee33ff0..85efb8a9791983a490b3fe0e8f2f74b95ff8afd9 100644 (file)
@@ -1757,14 +1757,27 @@ xfs_fs_fill_super(
 "EXPERIMENTAL metadata directory 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;
                }